From 4fa82a0269cec5caa30aef98598821dfeda1265a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:10:16 +0000 Subject: [PATCH 01/94] Auto-generated commit 106f8937dbce462d35773adbb7fb0847fe92790d --- index.d.ts | 146 +++ index.mjs | 4 + index.mjs.map | 1 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2840 insertions(+) create mode 100644 index.d.ts create mode 100644 index.mjs create mode 100644 index.mjs.map create mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..9ffa441 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,146 @@ +/* +* @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. +*/ + +// TypeScript Version: 2.0 + +/// + +import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; +import { ArrayLike } from '@stdlib/types/array'; +import { Collection } from '@stdlib/types/object'; + +// Define a union type representing both iterable and non-iterable iterators: +type Iterator = Iter | IterableIterator; + +/** +* Map function invoked for each iterated value. +* +* @returns iterator value +*/ +type Nullary = () => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @returns iterator value +*/ +type Unary = ( value: any ) => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @param index - iterated value index +* @returns iterator value +*/ +type Binary = ( value: any, index: number ) => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @param index - iterated value index +* @param src - source array-like object +* @returns iterator value +*/ +type Ternary = ( value: any, index: number, src: ArrayLike ) => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @param index - iterated value index +* @param src - source array-like object +* @returns iterator value +*/ +type MapFunction = Nullary | Unary | Binary | Ternary; + +/** +* Fills an array-like object view with values returned from an iterator. +* +* @param iterator - source iterator +* @param out - output array +* @param mapFcn - function to invoke for each iterated value +* @param thisArg - execution context +* @returns output array +* +* @example +* var randu = require( `@stdlib/random/iter/randu` ); +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var iter = randu({ +* 'iter': 10 +* }); +* +* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); +* // returns +*/ +declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length + +/** +* Fills an array-like object view with values returned from an iterator. +* +* @param iterator - source iterator +* @param out - output array +* @param begin - starting index (inclusive) (default: 0) +* @param mapFcn - function to invoke for each iterated value +* @param thisArg - execution context +* @returns output array +* +* @example +* var randu = require( `@stdlib/random/iter/randu` ); +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var iter = randu({ +* 'iter': 10 +* }); +* +* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); +* // returns +*/ +declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length + +/** +* Fills an array-like object view with values returned from an iterator. +* +* @param iterator - source iterator +* @param out - output array +* @param begin - starting index (inclusive) (default: 0) +* @param end - ending index (non-inclusive) (default: out.length) +* @param mapFcn - function to invoke for each iterated value +* @param thisArg - execution context +* @returns output array +* +* @example +* var randu = require( `@stdlib/random/iter/randu` ); +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var iter = randu({ +* 'iter': 10 +* }); +* +* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); +* // returns +*/ +declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length + + +// EXPORTS // + +export = iterator2arrayview; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..79aceda --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var a=e,l=t,o=r,m=n.isPrimitive,d=i,u=s;var g=function(e,t){var r,n,i,s,g,h,f,c;if(!o(e))throw new TypeError(u("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",e));if(!l(t))throw new TypeError(u("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(2===(n=arguments.length))i=0,s=t.length;else if(3===n)a(arguments[2])?(i=0,g=arguments[2]):i=arguments[2],s=t.length;else if(4===n)a(arguments[2])?(i=0,s=t.length,g=arguments[2],r=arguments[3]):a(arguments[3])?(i=arguments[2],s=t.length,g=arguments[3]):(i=arguments[2],s=arguments[3]);else if(5===n){if(i=arguments[2],a(arguments[3]))s=t.length,g=arguments[3],r=arguments[4];else if(s=arguments[3],!a(g=arguments[4]))throw new TypeError(u("invalid argument. Fifth argument must be a callback function. Value: `%s`.",g))}else{if(i=arguments[2],s=arguments[3],!a(g=arguments[4]))throw new TypeError(u("invalid argument. Fifth argument must be a callback function. Value: `%s`.",g));r=arguments[5]}if(!m(i))throw new TypeError(u("invalid argument. Third argument must be either an integer (starting index) or a callback function. Value: `%s`.",i));if(!m(s))throw new TypeError(u("invalid argument. Fourth argument must be either an integer (ending index) or a callback function. Value: `%s`.",s));if(s<0?(s=t.length+s)<0&&(s=0):s>t.length&&(s=t.length),i<0&&(i=t.length+i)<0&&(i=0),h=d(t).setter,f=i-1,g){for(;f\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a callback function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a callback function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a callback function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a callback function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isFunction","require$$0","isCollection","require$$1","isIteratorLike","require$$2","isInteger","require$$3","isPrimitive","arraylike2object","require$$4","format","require$$5","lib","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","TypeError","arguments","length","setter","next","done","call","value"],"mappings":";;8gBAsBA,IAAIA,EAAaC,EACbC,EAAeC,EACfC,EAAiBC,EACjBC,EAAYC,EAAuCC,YACnDC,EAAmBC,EACnBC,EAASC,EA+Ib,IC7HAC,EDcA,SAA6BC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMnB,EAAgBU,GACrB,MAAM,IAAIU,UAAWb,EAAQ,+FAAgGG,IAE9H,IAAMZ,EAAca,GACnB,MAAM,IAAIS,UAAWb,EAAQ,+EAAgFI,IAG9G,GAAe,KADfE,EAAQQ,UAAUC,QAEjBR,EAAQ,EACRC,EAAMJ,EAAIW,YACJ,GAAe,IAAVT,EACNjB,EAAYyB,UAAW,KAC3BP,EAAQ,EACRE,EAAMK,UAAW,IAEjBP,EAAQO,UAAW,GAEpBN,EAAMJ,EAAIW,YACJ,GAAe,IAAVT,EACNjB,EAAYyB,UAAW,KAC3BP,EAAQ,EACRC,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,GACjBT,EAAUS,UAAW,IACVzB,EAAYyB,UAAW,KAClCP,EAAQO,UAAW,GACnBN,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,KAEjBP,EAAQO,UAAW,GACnBN,EAAMM,UAAW,SAEZ,GAAe,IAAVR,GAEX,GADAC,EAAQO,UAAW,GACdzB,EAAYyB,UAAW,IAC3BN,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,GACjBT,EAAUS,UAAW,QAIrB,GAFAN,EAAMM,UAAW,IAEXzB,EADNoB,EAAMK,UAAW,IAEhB,MAAM,IAAID,UAAWb,EAAQ,6EAA8ES,QAGvG,CAIN,GAHAF,EAAQO,UAAW,GACnBN,EAAMM,UAAW,IAEXzB,EADNoB,EAAMK,UAAW,IAEhB,MAAM,IAAID,UAAWb,EAAQ,6EAA8ES,IAE5GJ,EAAUS,UAAW,GAEtB,IAAMnB,EAAWY,GAChB,MAAM,IAAIM,UAAWb,EAAQ,mHAAoHO,IAElJ,IAAMZ,EAAWa,GAChB,MAAM,IAAIK,UAAWb,EAAQ,kHAAmHQ,IAkBjJ,GAhBKA,EAAM,GACVA,EAAMJ,EAAIW,OAASP,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIW,SACrBP,EAAMJ,EAAIW,QAENR,EAAQ,IACZA,EAAQH,EAAIW,OAASR,GACR,IACZA,EAAQ,GAGVG,EAAMZ,EAAkBM,GAAMY,OAC9BL,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASc,QACNC,OAGPR,EAAKN,EAAKO,EAAGF,EAAIU,KAAMd,EAASO,EAAEQ,MAAOT,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASc,QACNC,OAGPR,EAAKN,EAAKO,EAAGC,EAAEQ,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e520036 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 55243a693bde68e47ad332cd4260a00e85a1984c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 11 May 2022 20:45:45 +0000 Subject: [PATCH 02/94] Auto-generated commit --- .editorconfig | 181 ---- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 -- .github/workflows/bundle.yml | 496 --------- .github/workflows/cancel.yml | 56 -- .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 -- .github/workflows/npm_downloads.yml | 108 -- .github/workflows/productionize.yml | 160 --- .github/workflows/publish.yml | 157 --- .github/workflows/test.yml | 92 -- .github/workflows/test_bundles.yml | 158 --- .github/workflows/test_coverage.yml | 123 --- .github/workflows/test_install.yml | 83 -- .gitignore | 178 ---- .npmignore | 227 ----- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---------- README.md | 77 +- benchmark/benchmark.js | 83 -- branches.md | 53 - docs/repl.txt | 49 - docs/types/index.d.ts | 146 --- docs/types/test.ts | 96 -- examples/index.js | 38 - index.mjs | 2 +- index.mjs.map | 2 +- lib/index.js | 46 - lib/main.js | 171 ---- package.json | 65 +- stats.html | 2 +- test/test.js | 1108 --------------------- 37 files changed, 40 insertions(+), 4699 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/bundle.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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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/bundle.yml b/.github/workflows/bundle.yml deleted file mode 100644 index a9b11b8..0000000 --- a/.github/workflows/bundle.yml +++ /dev/null @@ -1,496 +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: bundle - -# Workflow triggers: -on: - # Allow workflow to be manually run: - workflow_dispatch: - - # Run workflow upon completion of `productionize` workflow: - workflow_run: - workflows: ["productionize"] - types: [completed] - -# Workflow jobs: -jobs: - - # 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 - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 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';/ - }" - - # 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 - - # 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 branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, checkout branch and rebase on `main`: - - name: 'If `deno` exists, checkout branch and rebase on `main`' - if: steps.deno-branch-exists.outputs.remote-exists - continue-on-error: true - run: | - git checkout -b deno origin/deno - git rebase main -s recursive -X ours - while [ $? -ne 0 ]; do - git rebase --skip - done - - # If `deno` does not exist, checkout `main` and create `deno` branch: - - name: 'If `deno` does not exist, checkout `main` and create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout main - git checkout -b deno - - # 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 rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs 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: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno --force - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) bundle: - - name: 'Create Universal Module Definition (UMD) bundle' - id: umd-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'umd' - 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\/bundle.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ed08d87..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/index.mjs b/index.mjs index 79aceda..5728a53 100644 --- a/index.mjs +++ b/index.mjs @@ -1,4 +1,4 @@ // Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 /// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var a=e,l=t,o=r,m=n.isPrimitive,d=i,u=s;var g=function(e,t){var r,n,i,s,g,h,f,c;if(!o(e))throw new TypeError(u("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",e));if(!l(t))throw new TypeError(u("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(2===(n=arguments.length))i=0,s=t.length;else if(3===n)a(arguments[2])?(i=0,g=arguments[2]):i=arguments[2],s=t.length;else if(4===n)a(arguments[2])?(i=0,s=t.length,g=arguments[2],r=arguments[3]):a(arguments[3])?(i=arguments[2],s=t.length,g=arguments[3]):(i=arguments[2],s=arguments[3]);else if(5===n){if(i=arguments[2],a(arguments[3]))s=t.length,g=arguments[3],r=arguments[4];else if(s=arguments[3],!a(g=arguments[4]))throw new TypeError(u("invalid argument. Fifth argument must be a callback function. Value: `%s`.",g))}else{if(i=arguments[2],s=arguments[3],!a(g=arguments[4]))throw new TypeError(u("invalid argument. Fifth argument must be a callback function. Value: `%s`.",g));r=arguments[5]}if(!m(i))throw new TypeError(u("invalid argument. Third argument must be either an integer (starting index) or a callback function. Value: `%s`.",i));if(!m(s))throw new TypeError(u("invalid argument. Fourth argument must be either an integer (ending index) or a callback function. Value: `%s`.",s));if(s<0?(s=t.length+s)<0&&(s=0):s>t.length&&(s=t.length),i<0&&(i=t.length+i)<0&&(i=0),h=d(t).setter,f=i-1,g){for(;ft.length&&(s=t.length),n<0&&(n=t.length+n)<0&&(n=0),g=h(t).setter,p=n-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a callback function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a callback function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a callback function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a callback function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isFunction","require$$0","isCollection","require$$1","isIteratorLike","require$$2","isInteger","require$$3","isPrimitive","arraylike2object","require$$4","format","require$$5","lib","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","TypeError","arguments","length","setter","next","done","call","value"],"mappings":";;8gBAsBA,IAAIA,EAAaC,EACbC,EAAeC,EACfC,EAAiBC,EACjBC,EAAYC,EAAuCC,YACnDC,EAAmBC,EACnBC,EAASC,EA+Ib,IC7HAC,EDcA,SAA6BC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMnB,EAAgBU,GACrB,MAAM,IAAIU,UAAWb,EAAQ,+FAAgGG,IAE9H,IAAMZ,EAAca,GACnB,MAAM,IAAIS,UAAWb,EAAQ,+EAAgFI,IAG9G,GAAe,KADfE,EAAQQ,UAAUC,QAEjBR,EAAQ,EACRC,EAAMJ,EAAIW,YACJ,GAAe,IAAVT,EACNjB,EAAYyB,UAAW,KAC3BP,EAAQ,EACRE,EAAMK,UAAW,IAEjBP,EAAQO,UAAW,GAEpBN,EAAMJ,EAAIW,YACJ,GAAe,IAAVT,EACNjB,EAAYyB,UAAW,KAC3BP,EAAQ,EACRC,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,GACjBT,EAAUS,UAAW,IACVzB,EAAYyB,UAAW,KAClCP,EAAQO,UAAW,GACnBN,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,KAEjBP,EAAQO,UAAW,GACnBN,EAAMM,UAAW,SAEZ,GAAe,IAAVR,GAEX,GADAC,EAAQO,UAAW,GACdzB,EAAYyB,UAAW,IAC3BN,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,GACjBT,EAAUS,UAAW,QAIrB,GAFAN,EAAMM,UAAW,IAEXzB,EADNoB,EAAMK,UAAW,IAEhB,MAAM,IAAID,UAAWb,EAAQ,6EAA8ES,QAGvG,CAIN,GAHAF,EAAQO,UAAW,GACnBN,EAAMM,UAAW,IAEXzB,EADNoB,EAAMK,UAAW,IAEhB,MAAM,IAAID,UAAWb,EAAQ,6EAA8ES,IAE5GJ,EAAUS,UAAW,GAEtB,IAAMnB,EAAWY,GAChB,MAAM,IAAIM,UAAWb,EAAQ,mHAAoHO,IAElJ,IAAMZ,EAAWa,GAChB,MAAM,IAAIK,UAAWb,EAAQ,kHAAmHQ,IAkBjJ,GAhBKA,EAAM,GACVA,EAAMJ,EAAIW,OAASP,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIW,SACrBP,EAAMJ,EAAIW,QAENR,EAAQ,IACZA,EAAQH,EAAIW,OAASR,GACR,IACZA,EAAQ,GAGVG,EAAMZ,EAAkBM,GAAMY,OAC9BL,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASc,QACNC,OAGPR,EAAKN,EAAKO,EAAGF,EAAIU,KAAMd,EAASO,EAAEQ,MAAOT,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASc,QACNC,OAGPR,EAAKN,EAAKO,EAAGC,EAAEQ,OAEhB,OAAOhB"} \ No newline at end of file +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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 isFunction = require( '@stdlib/assert-is-function' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isIteratorLike = require( '@stdlib/assert-is-iterator-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar format = require( '@stdlib/error-tools-fmtprodmsg' );\n\n\n// MAIN //\n\n/**\n* Fills an array-like object view with values returned from an iterator.\n*\n* @param {Iterator} iterator - source iterator\n* @param {Collection} out - output array\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end=out.length] - ending index (non-inclusive)\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an iterator\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer (starting index) or a callback function\n* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function\n* @throws {TypeError} fifth argument must be a function\n* @returns {Collection} output array\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isFunction","require$$0","isCollection","require$$1","isIteratorLike","require$$2","isInteger","require$$3","isPrimitive","arraylike2object","require$$4","format","require$$5","lib","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","TypeError","arguments","length","setter","next","done","call","value"],"mappings":";;uhBAsBA,IAAIA,EAAaC,EACbC,EAAeC,EACfC,EAAiBC,EACjBC,EAAYC,EAAuCC,YACnDC,EAAmBC,EACnBC,EAASC,EA+Ib,IC7HAC,EDcA,SAA6BC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMnB,EAAgBU,GACrB,MAAM,IAAIU,UAAWb,EAAQ,QAASG,IAEvC,IAAMZ,EAAca,GACnB,MAAM,IAAIS,UAAWb,EAAQ,QAASI,IAGvC,GAAe,KADfE,EAAQQ,UAAUC,QAEjBR,EAAQ,EACRC,EAAMJ,EAAIW,YACJ,GAAe,IAAVT,EACNjB,EAAYyB,UAAW,KAC3BP,EAAQ,EACRE,EAAMK,UAAW,IAEjBP,EAAQO,UAAW,GAEpBN,EAAMJ,EAAIW,YACJ,GAAe,IAAVT,EACNjB,EAAYyB,UAAW,KAC3BP,EAAQ,EACRC,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,GACjBT,EAAUS,UAAW,IACVzB,EAAYyB,UAAW,KAClCP,EAAQO,UAAW,GACnBN,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,KAEjBP,EAAQO,UAAW,GACnBN,EAAMM,UAAW,SAEZ,GAAe,IAAVR,GAEX,GADAC,EAAQO,UAAW,GACdzB,EAAYyB,UAAW,IAC3BN,EAAMJ,EAAIW,OACVN,EAAMK,UAAW,GACjBT,EAAUS,UAAW,QAIrB,GAFAN,EAAMM,UAAW,IAEXzB,EADNoB,EAAMK,UAAW,IAEhB,MAAM,IAAID,UAAWb,EAAQ,QAASS,QAGlC,CAIN,GAHAF,EAAQO,UAAW,GACnBN,EAAMM,UAAW,IAEXzB,EADNoB,EAAMK,UAAW,IAEhB,MAAM,IAAID,UAAWb,EAAQ,QAASS,IAEvCJ,EAAUS,UAAW,GAEtB,IAAMnB,EAAWY,GAChB,MAAM,IAAIM,UAAWb,EAAQ,0GAA2GO,IAEzI,IAAMZ,EAAWa,GAChB,MAAM,IAAIK,UAAWb,EAAQ,yGAA0GQ,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIW,OAASP,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIW,SACrBP,EAAMJ,EAAIW,QAENR,EAAQ,IACZA,EAAQH,EAAIW,OAASR,GACR,IACZA,EAAQ,GAGVG,EAAMZ,EAAkBM,GAAMY,OAC9BL,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASc,QACNC,OAGPR,EAAKN,EAAKO,EAAGF,EAAIU,KAAMd,EAASO,EAAEQ,MAAOT,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASc,QACNC,OAGPR,EAAKN,EAAKO,EAAGC,EAAEQ,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index db22cae..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 73d35b7..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html index e520036..d43aa50 100644 --- a/stats.html +++ b/stats.html @@ -2669,7 +2669,7 @@ - - - - From 35da3633b850b926a8cb69e631e17fbb59914ade Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 16:59:45 +0000 Subject: [PATCH 05/94] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1108 --------- 37 files changed, 2732 insertions(+), 4599 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c8b6f69..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:40:39.205Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.9.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '0 8 * * 6' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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' - uses: actions/upload-artifact@v2 - 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' - uses: distributhor/workflow-webhook@v2 - 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 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 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 rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs 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 or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..888b6fc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;siBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7897c5f --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 1db811902df5b144a372e6283364fdaa815efb84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:49:29 +0000 Subject: [PATCH 06/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 73d35b7..87f746c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 6a017c64a84c284433fb9b228e46a197fa6b676b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:13:56 +0000 Subject: [PATCH 07/94] Remove files --- index.d.ts | 146 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2840 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 888b6fc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;siBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7897c5f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8ec621c1c62cae387596184855787cb825c298aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:14:38 +0000 Subject: [PATCH 08/94] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1108 --------- 36 files changed, 2732 insertions(+), 4564 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.9.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '0 8 * * 6' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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' - uses: actions/upload-artifact@v2 - 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' - uses: distributhor/workflow-webhook@v2 - 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 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 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 or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..888b6fc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;siBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e30fd17 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 1340a767de46cb75f4bb19f6569073407a956f23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:57:02 +0000 Subject: [PATCH 09/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 73d35b7..87f746c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From de4fa38da912386b64697754926fa1a4f22e3e12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:40:46 +0000 Subject: [PATCH 10/94] Remove files --- index.d.ts | 146 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2840 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 888b6fc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;siBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e30fd17..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f2f1d5a875b135dc11dbc697cfe0e652a3a874c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:41:39 +0000 Subject: [PATCH 11/94] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1108 --------- 37 files changed, 2732 insertions(+), 4638 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index dfedeed..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:42:54.644Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.9.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '0 8 * * 6' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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' - uses: actions/upload-artifact@v2 - 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' - uses: distributhor/workflow-webhook@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7c3f1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..249dd83 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 785415570811aed907c43d9640dfff778cde3190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:48:59 +0000 Subject: [PATCH 12/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 73d35b7..87f746c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 98e5716056d46ac0c2b13b91b9c2f354ba6f2ae4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:16:04 +0000 Subject: [PATCH 13/94] Remove files --- index.d.ts | 146 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2840 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7c3f1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 249dd83..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0247fe6399e839103dcb4efd6bd76f9f4ebe6165 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:16:57 +0000 Subject: [PATCH 14/94] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1108 --------- 37 files changed, 2732 insertions(+), 4654 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ecbfe12..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:42:59.311Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.9.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '0 8 * * 6' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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' - uses: actions/upload-artifact@v2 - 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' - uses: distributhor/workflow-webhook@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7c3f1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8369b57 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From f288a1a1a8c2c4c11ade80e90ca3de02b2d978ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:17:29 +0000 Subject: [PATCH 15/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 73d35b7..87f746c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From a65ccf7dc0dd6fac3b14b81ed1585e2da45016e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 23:54:33 +0000 Subject: [PATCH 16/94] Remove files --- index.d.ts | 146 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2840 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7c3f1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8369b57..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 91db1b3f606e738c80e936776585341f0b8cff30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 23:55:27 +0000 Subject: [PATCH 17/94] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1108 --------- 37 files changed, 2732 insertions(+), 4654 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1f5076f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:10:31.121Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.9.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '0 8 * * 6' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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' - uses: actions/upload-artifact@v2 - 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' - uses: distributhor/workflow-webhook@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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' - uses: actions/setup-node@v2 - with: - node-version: 16 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7c3f1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ae2ec85 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 07674ea6d1ce7ac2d089759b5211fab4dbc67e78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:01:42 +0000 Subject: [PATCH 18/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 73d35b7..87f746c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 15aa49cf780a70412108a51778c753fbe38bbb28 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:06:08 +0000 Subject: [PATCH 19/94] Remove files --- index.d.ts | 146 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2840 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7c3f1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,GAEtB,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,EAER,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ae2ec85..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a914ee06d9669a98563394e6e9458f406ba4c1be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:06:58 +0000 Subject: [PATCH 20/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1108 ------ 37 files changed, 4087 insertions(+), 4654 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d400639..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:56:03.570Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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' - uses: actions/checkout@v3 - - # 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 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7c3f1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,EACrB,CACD,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,CACP,CACD,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..139c209 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 1c982fb8dedf3536fdd2c41f4b7732e49c365189 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:41:25 +0000 Subject: [PATCH 21/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 73d35b7..87f746c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 5cd6eab0aec9df096fe8035c5e4318d21bb5ca04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:40:22 +0000 Subject: [PATCH 22/94] Remove files --- index.d.ts | 146 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4195 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7c3f1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,EACrB,CACD,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,CACP,CACD,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 139c209..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 41ab4214fae67abb21b85d4cd17afcaa660ad0b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:41:24 +0000 Subject: [PATCH 23/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1108 ------ 37 files changed, 4087 insertions(+), 4675 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 224ec8b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:57:03.384Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +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: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7c3f1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,EACrB,CACD,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,CACP,CACD,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 87f746c..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4474ba5 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 651bfbfecdefa1231a54d679a2746edaa6cf59a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 02:46:18 +0000 Subject: [PATCH 24/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index db22cae..77936ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -68,10 +68,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -109,7 +109,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -117,7 +117,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index dd1a518..33512a6 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From cd45a72cc784dbd797c88f0e6e6f885565f3f1f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:43:42 +0000 Subject: [PATCH 25/94] Remove files --- index.d.ts | 146 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4195 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7c3f1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,EACrB,CACD,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,CACP,CACD,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4474ba5..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From cf6199b6c9bf70a01de762f18aaea00d96c5c4cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:44:33 +0000 Subject: [PATCH 26/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 171 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1108 ------ 37 files changed, 4087 insertions(+), 4680 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 64e465b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:45:44.448Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +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: - -# 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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - 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)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9937d7f..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c1fcb63..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index ed08d87..9ffa441 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7c3f1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,EACrB,CACD,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,CACP,CACD,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 77936ac..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - set = arraylike2object( out ).setter; - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 33512a6..36b7176 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2e443c7 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From edb3a194e4859c4277bf301086f13b7c429e3508 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 23:35:09 +0000 Subject: [PATCH 27/94] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..56a07c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Cv4J', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Cv3A', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } } } else { // nargs > 5 @@ -121,7 +121,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Cv3D', fcn ) ); } thisArg = arguments[ 5 ]; } diff --git a/package.json b/package.json index 660171a..fafea21 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 4d96aceb6904fd54115fa28dd0ddb08aac7f0688 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 23:35:40 +0000 Subject: [PATCH 28/94] Remove files --- index.d.ts | 146 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4195 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 9ffa441..0000000 --- a/index.d.ts +++ /dev/null @@ -1,146 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7c3f1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function o(o,l){var d,h,m,a,f,g,p,j;if(!r(o))throw new TypeError(i("0Cv4J",o));if(!t(l))throw new TypeError(i("0Cv3A",l));if(2===(h=arguments.length))m=0,a=l.length;else if(3===h)e(arguments[2])?(m=0,f=arguments[2]):m=arguments[2],a=l.length;else if(4===h)e(arguments[2])?(m=0,a=l.length,f=arguments[2],d=arguments[3]):e(arguments[3])?(m=arguments[2],a=l.length,f=arguments[3]):(m=arguments[2],a=arguments[3]);else if(5===h){if(m=arguments[2],e(arguments[3]))a=l.length,f=arguments[3],d=arguments[4];else if(a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f))}else{if(m=arguments[2],a=arguments[3],!e(f=arguments[4]))throw new TypeError(i("0Cv3D",f));d=arguments[5]}if(!n(m))throw new TypeError(i("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",m));if(!n(a))throw new TypeError(i("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",a));if(a<0?(a=l.length+a)<0&&(a=0):a>l.length&&(a=l.length),m<0&&(m=l.length+m)<0&&(m=0),g=s(l).setter,p=m-1,f){for(;p\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tset = arraylike2object( out ).setter;\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","arraylike2object","setter","next","done","call","value"],"mappings":";;6iBA2DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBV,GACrB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMa,EAAcZ,GACnB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,KADfE,EAAQW,UAAUC,QAEjBX,EAAQ,EACRC,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRE,EAAMQ,UAAW,IAEjBV,EAAQU,UAAW,GAEpBT,EAAMJ,EAAIc,YACJ,GAAe,IAAVZ,EACNa,EAAYF,UAAW,KAC3BV,EAAQ,EACRC,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,IACVE,EAAYF,UAAW,KAClCV,EAAQU,UAAW,GACnBT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,KAEjBV,EAAQU,UAAW,GACnBT,EAAMS,UAAW,SAEZ,GAAe,IAAVX,GAEX,GADAC,EAAQU,UAAW,GACdE,EAAYF,UAAW,IAC3BT,EAAMJ,EAAIc,OACVT,EAAMQ,UAAW,GACjBZ,EAAUY,UAAW,QAIrB,GAFAT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,QAGlC,CAIN,GAHAF,EAAQU,UAAW,GACnBT,EAAMS,UAAW,IAEXE,EADNV,EAAMQ,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASN,IAEvCJ,EAAUY,UAAW,EACrB,CACD,IAAMG,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,0GAA2GR,IAEzI,IAAMa,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,yGAA0GP,IAkBxI,GAhBKA,EAAM,GACVA,EAAMJ,EAAIc,OAASV,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIc,SACrBV,EAAMJ,EAAIc,QAENX,EAAQ,IACZA,EAAQH,EAAIc,OAASX,GACR,IACZA,EAAQ,GAGVG,EAAMW,EAAkBjB,GAAMkB,OAC9BX,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQE,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGF,EAAIgB,KAAMpB,EAASO,EAAEc,MAAOf,EAAGA,EAAEJ,IAE/C,OAAOH,CACP,CACD,KAAQO,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIT,EAASoB,QACNC,OAGPd,EAAKN,EAAKO,EAAGC,EAAEc,OAEhB,OAAOtB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2e443c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6e3c7631d02e0fe063633609012718e12920492b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 23:36:50 +0000 Subject: [PATCH 29/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1108 ---- 36 files changed, 6220 insertions(+), 4843 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 4173493..cdf0dd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1907045 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(m,a){var h,f,g,j,p,v,c,u,b;if(!r(m))throw new TypeError(l("0Cv4J",m));if(!t(a))throw new TypeError(l("0Cv3A",a));if(2===(f=arguments.length))g=0,j=a.length;else if(3===f)e(arguments[2])?(g=0,p=arguments[2]):g=arguments[2],j=a.length;else if(4===f)e(arguments[2])?(g=0,j=a.length,p=arguments[2],h=arguments[3]):e(arguments[3])?(g=arguments[2],j=a.length,p=arguments[3]):(g=arguments[2],j=arguments[3]);else if(5===f){if(g=arguments[2],e(arguments[3]))j=a.length,p=arguments[3],h=arguments[4];else if(j=arguments[3],!e(p=arguments[4]))throw new TypeError(l("0Cv3D",p))}else{if(g=arguments[2],j=arguments[3],!e(p=arguments[4]))throw new TypeError(l("0Cv3D",p));h=arguments[5]}if(!s(g))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",g));if(!s(j))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",j));if(j<0?(j=a.length+j)<0&&(j=0):j>a.length&&(j=a.length),g<0&&(g=a.length+g)<0&&(g=0),c=d(a),v=i(a)?n(c):o(c),u=g-1,p){for(;u\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;q0BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 56a07c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Cv4J', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Cv3A', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Cv3D', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index fafea21..a7dfe08 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.0.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-base-setter": "^0.0.1", - "@stdlib/array-dtype": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float64": "^0.0.8", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a58f444 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 327a4db..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 36265095ec21493c8e2efa3acca5b2c1d9fa0f50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:34:17 +0000 Subject: [PATCH 30/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 660171a..fafea21 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 4d069a8e4ddc783fc4b6d17ab937b32dc94688df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:50:27 +0000 Subject: [PATCH 31/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 cdf0dd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1907045..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(m,a){var h,f,g,j,p,v,c,u,b;if(!r(m))throw new TypeError(l("0Cv4J",m));if(!t(a))throw new TypeError(l("0Cv3A",a));if(2===(f=arguments.length))g=0,j=a.length;else if(3===f)e(arguments[2])?(g=0,p=arguments[2]):g=arguments[2],j=a.length;else if(4===f)e(arguments[2])?(g=0,j=a.length,p=arguments[2],h=arguments[3]):e(arguments[3])?(g=arguments[2],j=a.length,p=arguments[3]):(g=arguments[2],j=arguments[3]);else if(5===f){if(g=arguments[2],e(arguments[3]))j=a.length,p=arguments[3],h=arguments[4];else if(j=arguments[3],!e(p=arguments[4]))throw new TypeError(l("0Cv3D",p))}else{if(g=arguments[2],j=arguments[3],!e(p=arguments[4]))throw new TypeError(l("0Cv3D",p));h=arguments[5]}if(!s(g))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",g));if(!s(j))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",j));if(j<0?(j=a.length+j)<0&&(j=0):j>a.length&&(j=a.length),g<0&&(g=a.length+g)<0&&(g=0),c=d(a),v=i(a)?n(c):o(c),u=g-1,p){for(;u\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Cv4J', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Cv3A', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Cv3D', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;q0BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a58f444..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0b2505cf45e04d838d3ed6cd096ae6cc937baf4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:51:30 +0000 Subject: [PATCH 32/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1108 ---- 39 files changed, 6220 insertions(+), 4843 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 435f829..42ce716 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7efc793 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,c,v,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),v=l(h),c=i(h)?n(v):o(v),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;8zBA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index fafea21..a7dfe08 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.0.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-base-setter": "^0.0.1", - "@stdlib/array-dtype": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float64": "^0.0.8", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..033ada7 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 3cccd8b5c1852ee109d84eae797d2fc655685aa3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 10:12:23 +0000 Subject: [PATCH 33/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 660171a..fafea21 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 8548358fbbafd335db634a481021969cc12aa42a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 10:22:17 +0000 Subject: [PATCH 34/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 42ce716..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7efc793..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,c,v,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),v=l(h),c=i(h)?n(v):o(v),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;8zBA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 033ada7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7a2443b9bb4e434bc7ffbfce8f9424f148c055d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 10:23:10 +0000 Subject: [PATCH 35/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1108 ---- 39 files changed, 6220 insertions(+), 4843 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -263,7 +256,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -323,15 +316,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..30a6c6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,c,v,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),v=l(h),c=i(h)?n(v):o(v),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;q0BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index fafea21..a7dfe08 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.0.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-base-setter": "^0.0.1", - "@stdlib/array-dtype": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float64": "^0.0.8", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3c9f208 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 8ea3cd7891cdcae4115f478bd885154d27ccb1be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:52:34 +0000 Subject: [PATCH 36/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 35d4768..24cd71d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.0", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 2ae950c60ff4dfc4ffd64c76c93f258ab9cbc2df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:13:40 +0000 Subject: [PATCH 37/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 30a6c6b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,c,v,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),v=l(h),c=i(h)?n(v):o(v),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;q0BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3c9f208..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0400dc365f4837b42c0b5838d65a9c38b83c1adb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:15:42 +0000 Subject: [PATCH 38/94] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1108 ---- 40 files changed, 6220 insertions(+), 4878 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 .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 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 868cc38..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - 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/iter/to-array-view) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 c3403a8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +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: '13 1 * * 0' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -274,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -334,15 +327,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5b568e0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 24cd71d..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float64": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.0", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/utils-noop": "^0.1.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dda41b1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From c882c37f8727733fa303f3bbbffd522374ad9081 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:28:34 +0000 Subject: [PATCH 39/94] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33bbefe..0bba0c3 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.1.0-esm/index.mjs'; ``` #### iterator2arrayview( iterator, dest\[, begin\[, end]]\[, mapFcn\[, thisArg]] ) @@ -208,7 +208,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.1.0-esm/index.mjs'; function scale( v, i ) { return v * (i+1); From 21e90331d38db65a3e87dcba2a9bb1171266e70f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:28:34 +0000 Subject: [PATCH 40/94] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bba0c3..e9ef455 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/iter-to-array-view/tags). For example, + ```javascript import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.1.0-esm/index.mjs'; ``` @@ -208,7 +213,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.1.0-esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; function scale( v, i ) { return v * (i+1); From 7b8d565982c31bdae6df22d90b7050a4c5bb5147 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 16:58:23 +0000 Subject: [PATCH 41/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index b542b61..f735851 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.0", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 9d246afee4414e28afe45dc8f985fa3edc518789 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:12:34 +0000 Subject: [PATCH 42/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5b568e0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dda41b1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 29ce1d4a568d94789d9a3d04231bb7d817f62ad0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:16:12 +0000 Subject: [PATCH 43/94] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1108 ---- test/test.js | 1108 ---- 42 files changed, 6220 insertions(+), 6045 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 .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 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index afda2eb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:27:44.672Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 7ad4a86..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/iter/to-array-view) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 9a142a6..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: '13 1 * * 0' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -274,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -334,15 +327,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5b568e0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index f735851..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float64": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.0", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/utils-noop": "^0.1.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..091b597 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index ee6a888..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 6e2afb5cee65f1689a6e3d0a1a0067b79808977c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:03:39 +0000 Subject: [PATCH 44/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 14f1734..20531a4 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From e28043da9a5cc0df3d7b02e8b5d50240aa830a2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:26:43 +0000 Subject: [PATCH 45/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5b568e0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 091b597..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3ee24781cef0f0b7ef326f01473496962e1c339d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:29:56 +0000 Subject: [PATCH 46/94] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1108 ---- test/test.js | 1108 ---- 41 files changed, 6220 insertions(+), 6044 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 .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 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 7ad4a86..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/iter/to-array-view) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 9a142a6..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: '13 1 * * 0' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -274,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -334,15 +327,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db729e4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 20531a4..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float64": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..71b0ad0 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index ee6a888..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From e2f358513e7fa212cb072e825fd98482abeddc26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:46:53 +0000 Subject: [PATCH 47/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 6d9f66d..259e7c6 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 12739f611b8c1a730de1dcaa9e92f5649a0746f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:21:12 +0000 Subject: [PATCH 48/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index db729e4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 71b0ad0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d5715d8cd1b84252d80655292abaa0ef4fce520f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:24:46 +0000 Subject: [PATCH 49/94] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ---- 42 files changed, 6220 insertions(+), 4978 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 .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 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 -insert_final_newline = false - -# 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 = false - -# 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 `tslint.json` files: -[tslint.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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8d76739..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:47:37.882Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 7ad4a86..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/iter/to-array-view) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 9a142a6..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: '13 1 * * 0' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -274,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -334,15 +327,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db729e4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 259e7c6..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..211fe5e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + 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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 7dc190e4c958a7043adc9c3d84e8f6c17be1b109 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 13:54:27 +0000 Subject: [PATCH 50/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..29c728b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146,G5', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y,Ix', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131,Lk', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1Ll', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1Lm', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 69b1b23..577be41 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 475dae2b5258a55c87fce86d1d631ea32c878722 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:02:20 +0000 Subject: [PATCH 51/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index db729e4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 211fe5e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a6ee093864c31b9302d4ae76b6ae7b65e9a01bfa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:05:00 +0000 Subject: [PATCH 52/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ---- 42 files changed, 6220 insertions(+), 4973 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 .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 benchmark/benchmark.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e3dfd07..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:52:09.645Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 7ad4a86..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/iter/to-array-view) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 9a142a6..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: '13 1 * * 0' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -274,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -334,15 +327,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 633c4c7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db729e4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 29c728b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146,G5', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y,Ix', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131,Lk', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1Ll', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1Lm', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 577be41..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..73265ac --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + 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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 69246f8b4d8c2d316d9d92c6443efba5b0bd9547 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:16:57 +0000 Subject: [PATCH 53/94] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c47b178..13ba5c8 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From c9882d4c89bbec0576116771048df4b655e07ec8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:56:21 +0000 Subject: [PATCH 54/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index db729e4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,x,y;if(!r(m))throw new TypeError(d("0Q146,G5",m));if(!s(h))throw new TypeError(d("0Q12y,Ix",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131,Lk",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1Ll",j));if(!t(p))throw new TypeError(d("0Q1Lm",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),x=j-1,g){for(;x\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146,G5', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y,Ix', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131,Lk', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1Ll', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1Lm', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAE1C,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,WAAYZ,IAG1C,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,QAGrC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,WAAYP,IAE1CJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 73265ac..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0e6daa69ac7f32b56d77ec75e6d18678d8050971 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:56:52 +0000 Subject: [PATCH 55/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ---- 43 files changed, 6220 insertions(+), 4979 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f329e02..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:21:09.224Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 30656c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 7ad4a86..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/iter/to-array-view) 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 c92f5c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 349c54c..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: '13 1 * * 0' - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 + + ```
@@ -274,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -334,15 +327,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 089ddbb..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 559764f..2d7a3d3 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c043a24 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function m(m,d){var h,g,u,f,j,p,c,v,b;if(!r(m))throw new TypeError(l("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",m));if(!t(d))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",d));if(2===(g=arguments.length))u=0,f=d.length;else if(3===g)e(arguments[2])?(u=0,j=arguments[2]):u=arguments[2],f=d.length;else if(4===g)e(arguments[2])?(u=0,f=d.length,j=arguments[2],h=arguments[3]):e(arguments[3])?(u=arguments[2],f=d.length,j=arguments[3]):(u=arguments[2],f=arguments[3]);else if(5===g){if(u=arguments[2],e(arguments[3]))f=d.length,j=arguments[3],h=arguments[4];else if(f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j))}else{if(u=arguments[2],f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j));h=arguments[5]}if(!s(u))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",u));if(!s(f))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",f));if(f<0?(f=d.length+f)<0&&(f=0):f>d.length&&(f=d.length),u<0&&(u=d.length+u)<0&&(u=0),c=o(d),p=n(d)?i(c):a(c),v=u-1,j){for(;v\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;s2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,+FAAgGb,IAE9H,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,+EAAgFZ,IAG9G,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,QAG9F,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,IAEnGJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index f3f088c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 13ba5c8..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "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.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8cf0bf5 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + 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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From c62906743f1142cd5a664ba636a420dc9856506e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:51:05 +0000 Subject: [PATCH 56/94] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c47b178..13ba5c8 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 275fe655276c027058ca2c1b1e038d4defe0b7c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:12:04 +0000 Subject: [PATCH 57/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 2d7a3d3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c043a24..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function m(m,d){var h,g,u,f,j,p,c,v,b;if(!r(m))throw new TypeError(l("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",m));if(!t(d))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",d));if(2===(g=arguments.length))u=0,f=d.length;else if(3===g)e(arguments[2])?(u=0,j=arguments[2]):u=arguments[2],f=d.length;else if(4===g)e(arguments[2])?(u=0,f=d.length,j=arguments[2],h=arguments[3]):e(arguments[3])?(u=arguments[2],f=d.length,j=arguments[3]):(u=arguments[2],f=arguments[3]);else if(5===g){if(u=arguments[2],e(arguments[3]))f=d.length,j=arguments[3],h=arguments[4];else if(f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j))}else{if(u=arguments[2],f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j));h=arguments[5]}if(!s(u))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",u));if(!s(f))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",f));if(f<0?(f=d.length+f)<0&&(f=0):f>d.length&&(f=d.length),u<0&&(u=d.length+u)<0&&(u=0),c=o(d),p=n(d)?i(c):a(c),v=u-1,j){for(;v\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;s2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,+FAAgGb,IAE9H,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,+EAAgFZ,IAG9G,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,QAG9F,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,IAEnGJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8cf0bf5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 925ce39f88276138ffcb57fe3c83ff264f8cd3f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:12:24 +0000 Subject: [PATCH 58/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ---- 43 files changed, 6220 insertions(+), 4984 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f55d6da..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:12:19.407Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 30656c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 7ad4a86..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/iter/to-array-view) 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 c92f5c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 349c54c..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: '13 1 * * 0' - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c043a24 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function m(m,d){var h,g,u,f,j,p,c,v,b;if(!r(m))throw new TypeError(l("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",m));if(!t(d))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",d));if(2===(g=arguments.length))u=0,f=d.length;else if(3===g)e(arguments[2])?(u=0,j=arguments[2]):u=arguments[2],f=d.length;else if(4===g)e(arguments[2])?(u=0,f=d.length,j=arguments[2],h=arguments[3]):e(arguments[3])?(u=arguments[2],f=d.length,j=arguments[3]):(u=arguments[2],f=arguments[3]);else if(5===g){if(u=arguments[2],e(arguments[3]))f=d.length,j=arguments[3],h=arguments[4];else if(f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j))}else{if(u=arguments[2],f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j));h=arguments[5]}if(!s(u))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",u));if(!s(f))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",f));if(f<0?(f=d.length+f)<0&&(f=0):f>d.length&&(f=d.length),u<0&&(u=d.length+u)<0&&(u=0),c=o(d),p=n(d)?i(c):a(c),v=u-1,j){for(;v\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;s2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,+FAAgGb,IAE9H,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,+EAAgFZ,IAG9G,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,QAG9F,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,IAEnGJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index f3f088c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 13ba5c8..82e7893 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "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.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..233d54a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + 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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 7e2a812fb5fcb3258b53f09c07c694015a8348d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 00:52:37 +0000 Subject: [PATCH 59/94] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 430114e..ecc6d4b 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.0", "@stdlib/assert-is-integer": "^0.2.0", "@stdlib/assert-is-iterator-like": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From d3b8df14469eca202164a507ec5374e2be2c5001 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:15:37 +0000 Subject: [PATCH 60/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c043a24..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function m(m,d){var h,g,u,f,j,p,c,v,b;if(!r(m))throw new TypeError(l("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",m));if(!t(d))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",d));if(2===(g=arguments.length))u=0,f=d.length;else if(3===g)e(arguments[2])?(u=0,j=arguments[2]):u=arguments[2],f=d.length;else if(4===g)e(arguments[2])?(u=0,f=d.length,j=arguments[2],h=arguments[3]):e(arguments[3])?(u=arguments[2],f=d.length,j=arguments[3]):(u=arguments[2],f=arguments[3]);else if(5===g){if(u=arguments[2],e(arguments[3]))f=d.length,j=arguments[3],h=arguments[4];else if(f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j))}else{if(u=arguments[2],f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j));h=arguments[5]}if(!s(u))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",u));if(!s(f))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",f));if(f<0?(f=d.length+f)<0&&(f=0):f>d.length&&(f=d.length),u<0&&(u=d.length+u)<0&&(u=0),c=o(d),p=n(d)?i(c):a(c),v=u-1,j){for(;v\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;s2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,+FAAgGb,IAE9H,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,+EAAgFZ,IAG9G,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,QAG9F,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,IAEnGJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 233d54a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ac77716e3e34054ebb49cbdae0bfd9312606eb6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:16:59 +0000 Subject: [PATCH 61/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ---- 42 files changed, 6220 insertions(+), 4987 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 2ac64f0..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: '13 1 * * 0' - - # 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dabd7a1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.0-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function m(m,d){var h,g,u,f,j,p,c,v,b;if(!r(m))throw new TypeError(l("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",m));if(!t(d))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",d));if(2===(g=arguments.length))u=0,f=d.length;else if(3===g)e(arguments[2])?(u=0,j=arguments[2]):u=arguments[2],f=d.length;else if(4===g)e(arguments[2])?(u=0,f=d.length,j=arguments[2],h=arguments[3]):e(arguments[3])?(u=arguments[2],f=d.length,j=arguments[3]):(u=arguments[2],f=arguments[3]);else if(5===g){if(u=arguments[2],e(arguments[3]))f=d.length,j=arguments[3],h=arguments[4];else if(f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j))}else{if(u=arguments[2],f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j));h=arguments[5]}if(!s(u))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",u));if(!s(f))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",f));if(f<0?(f=d.length+f)<0&&(f=0):f>d.length&&(f=d.length),u<0&&(u=d.length+u)<0&&(u=0),c=o(d),p=n(d)?i(c):a(c),v=u-1,j){for(;v\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;s2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,+FAAgGb,IAE9H,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,+EAAgFZ,IAG9G,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,QAG9F,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,IAEnGJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index f3f088c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index ecc6d4b..d57f0b8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Fill an array-like object view with values returned from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.0", - "@stdlib/array-base-setter": "^0.2.0", - "@stdlib/array-dtype": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/assert-is-integer": "^0.2.0", - "@stdlib/assert-is-iterator-like": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/complex-float64": "^0.2.0", - "@stdlib/math-base-assert-is-nan": "^0.2.0", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.0", - "@stdlib/utils-noop": "^0.2.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.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dacd14d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + 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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 18a1fe7644a8f4d78b86e53864b4f71625011889 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:13:57 +0000 Subject: [PATCH 62/94] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59ef54e..edb47f1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.0-esm/index.mjs'; ``` #### iterator2arrayview( iterator, dest\[, begin\[, end]]\[, mapFcn\[, thisArg]] ) @@ -208,7 +208,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.0-esm/index.mjs'; function scale( v, i ) { return v * (i+1); From d92f1b2211051ef6f5d361dfc23856cb48b2a165 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:13:58 +0000 Subject: [PATCH 63/94] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index edb47f1..e7efa86 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/iter-to-array-view/tags). For example, + ```javascript import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.0-esm/index.mjs'; ``` @@ -208,7 +213,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.0-esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; function scale( v, i ) { return v * (i+1); From 16aeebbb4dc6b833381f0ada8fd0953ccb9e4977 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:37:08 +0000 Subject: [PATCH 64/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 6222b30..5afc132 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-integer": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From cf29e9c75b26582c807fa7c9ae8ac910a468d246 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:43:53 +0000 Subject: [PATCH 65/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dabd7a1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.0-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function m(m,d){var h,g,u,f,j,p,c,v,b;if(!r(m))throw new TypeError(l("invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.",m));if(!t(d))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",d));if(2===(g=arguments.length))u=0,f=d.length;else if(3===g)e(arguments[2])?(u=0,j=arguments[2]):u=arguments[2],f=d.length;else if(4===g)e(arguments[2])?(u=0,f=d.length,j=arguments[2],h=arguments[3]):e(arguments[3])?(u=arguments[2],f=d.length,j=arguments[3]):(u=arguments[2],f=arguments[3]);else if(5===g){if(u=arguments[2],e(arguments[3]))f=d.length,j=arguments[3],h=arguments[4];else if(f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j))}else{if(u=arguments[2],f=arguments[3],!e(j=arguments[4]))throw new TypeError(l("invalid argument. Fifth argument must be a function. Value: `%s`.",j));h=arguments[5]}if(!s(u))throw new TypeError(l("invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.",u));if(!s(f))throw new TypeError(l("invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.",f));if(f<0?(f=d.length+f)<0&&(f=0):f>d.length&&(f=d.length),u<0&&(u=d.length+u)<0&&(u=0),c=o(d),p=n(d)?i(c):a(c),v=u-1,j){for(;v\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;s2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,+FAAgGb,IAE9H,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,+EAAgFZ,IAG9G,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,QAG9F,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,oEAAqEP,IAEnGJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,0GAA2GT,IAEzI,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,yGAA0GR,IAuBxI,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dacd14d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5db6f2b3a8379b5be4405b8ed1626107da6f92bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:44:10 +0000 Subject: [PATCH 66/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 42 files changed, 4885 insertions(+), 4982 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9614013 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 5afc132..7752fbf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.0", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7d481c3 --- /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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 4838028d9d5254f6f0a3f9e14e53c3e553a50056 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:26:53 +0000 Subject: [PATCH 67/94] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d68004..e87ffd5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.1-esm/index.mjs'; ``` #### iterator2arrayview( iterator, dest\[, begin\[, end]]\[, mapFcn\[, thisArg]] ) @@ -208,7 +208,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.1-esm/index.mjs'; function scale( v, i ) { return v * (i+1); From 49d765001e41ee5b0465c80e7b89cd9b6569c336 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:26:54 +0000 Subject: [PATCH 68/94] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e87ffd5..ab84719 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/iter-to-array-view/tags). For example, + ```javascript import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.1-esm/index.mjs'; ``` @@ -208,7 +213,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.1-esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; function scale( v, i ) { return v * (i+1); From 73b81cd61336ef5424da825fa881b66a89251749 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:07:58 +0000 Subject: [PATCH 69/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index dc3a65b..263f129 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-integer": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 1bf5200aa63b7db4aeb64a47de16fdbbe57d4426 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:47:47 +0000 Subject: [PATCH 70/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9614013..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7d481c3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1bb4736eea4a650aedf9aa7de56ff4bccadf4bd7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:48:08 +0000 Subject: [PATCH 71/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 43 files changed, 4885 insertions(+), 4984 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 45c386e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T05:52:49.247Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2167517 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 263f129..7752fbf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..af585cc --- /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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 084acf8cb608d0e422c7f0212eb89520005e908c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:26:43 +0000 Subject: [PATCH 72/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index dc3a65b..263f129 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-integer": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 62153f903aa393aa2b21048e7a224c890c799522 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:54:06 +0000 Subject: [PATCH 73/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2167517..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index af585cc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3f3959d4a584c1c5844f67c0ce8c9dfc34c90f5c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:54:20 +0000 Subject: [PATCH 74/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 43 files changed, 4885 insertions(+), 4987 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bfa15c2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:10:05.649Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2167517 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 263f129..7752fbf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..af585cc --- /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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 378610722851590e36244363833a8ddcad1d2ad9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:40:53 +0000 Subject: [PATCH 75/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index dc3a65b..263f129 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-integer": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 3833cf656c5ec0149dff6253d0165185a5eee070 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:05:13 +0000 Subject: [PATCH 76/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2167517..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index af585cc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 53c58ae8f38fcc16dae4e1290ef1516d2eb187aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:05:27 +0000 Subject: [PATCH 77/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 42 files changed, 4885 insertions(+), 4988 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2167517 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 263f129..7752fbf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..af585cc --- /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/test.js b/test/test.js deleted file mode 100644 index e2cc927..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From d74fa0f45ac6ed7e333c0eb4bc1f50e81cba1f04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:07:40 +0000 Subject: [PATCH 78/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index 8c68138..f812e1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From e29249eb089be758456f95d9ba72ca7dcccfd237 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:29:59 +0000 Subject: [PATCH 79/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2167517..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index af585cc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a31cc8b8f5b43b0586ac1759813a4a4fba76f4c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:30:14 +0000 Subject: [PATCH 80/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .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 | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 222 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 42 files changed, 4885 insertions(+), 5218 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4b740b7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index f812e1f..5224f1d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ae9a059 --- /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/test.js b/test/test.js deleted file mode 100644 index a522280..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From df99e09a9a7883bec4f2d7c1fd4790ccff6ea827 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:42:01 +0000 Subject: [PATCH 81/94] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f8da861..4731767 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.2-esm/index.mjs'; ``` #### iterator2arrayview( iterator, dest\[, begin\[, end]]\[, mapFcn\[, thisArg]] ) @@ -208,7 +208,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.2-esm/index.mjs'; function scale( v, i ) { return v * (i+1); From 179a0dbb114ac92cabcd47bc20a0d793ca4faae6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:42:01 +0000 Subject: [PATCH 82/94] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4731767..7b4237c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/iter-to-array-view/tags). For example, + ```javascript import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.2-esm/index.mjs'; ``` @@ -208,7 +213,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@v0.2.2-esm/index.mjs'; +import iterator2arrayview from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-to-array-view@esm/index.mjs'; function scale( v, i ) { return v * (i+1); From cf96085b9983e6183ad2555e595893b8cc6e7e46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:17:22 +0000 Subject: [PATCH 83/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index e6d1dac..c80c9c1 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 4b437dfec82ef66f4519041a11c45e1ed0aa166c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:11:27 +0000 Subject: [PATCH 84/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4b740b7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ae9a059..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a0d91c512ab81636feabb73b1e7585287b88897c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:11:43 +0000 Subject: [PATCH 85/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .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 | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 43 files changed, 4885 insertions(+), 5145 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 26e1c7b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T06:02:52.721Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4b740b7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index c80c9c1..5224f1d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ae9a059 --- /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/test.js b/test/test.js deleted file mode 100644 index a522280..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 26f4672d40235c51e49e283d63332ed1a3cdbf51 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:39:11 +0000 Subject: [PATCH 86/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index e3de6ca..96b2851 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 5c637e00f21c6ada758cef67f6d0ca7e90978fd7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:10:34 +0000 Subject: [PATCH 87/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4b740b7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ae9a059..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dd7c9d5631b9de54c8687d01fb813dd50cb43c2e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:10:49 +0000 Subject: [PATCH 88/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .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 | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 222 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 43 files changed, 4885 insertions(+), 5219 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b0ac955..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:30:35.945Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 53781b3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value - - index: destination index (zero-based) - - n: iteration index (zero-based) - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4b740b7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 96b2851..5224f1d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ae9a059 --- /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/test.js b/test/test.js deleted file mode 100644 index a522280..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 16aa2f4835c3c4ed2751b0cf220d0d48469f72ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:34:22 +0000 Subject: [PATCH 89/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index e3de6ca..96b2851 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 29284cf65d882583a345dc63fe41471c819e20b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:52:45 +0000 Subject: [PATCH 90/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4b740b7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ae9a059..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 98ba7e6f0bf4764bab08f294bdfc9306449caa02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:53:05 +0000 Subject: [PATCH 91/94] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .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 | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 256 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ----- 42 files changed, 4885 insertions(+), 5252 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 .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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4b3ded3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value. - - index: destination index (zero-based). - - n: iteration index (zero-based). - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4b740b7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index 96b2851..5224f1d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ae9a059 --- /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/test.js b/test/test.js deleted file mode 100644 index a522280..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 1f7f38da582d3d6003e02b354b9c40abb2a376b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:06:32 +0000 Subject: [PATCH 92/94] Transform error messages --- lib/main.js | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index f3f088c..2381fd5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -72,10 +72,10 @@ function iterator2arrayview( iterator, out ) { var v; if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '0Q146', iterator ) ); } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0Q12y', out ) ); } nargs = arguments.length; if ( nargs === 2 ) { @@ -113,7 +113,7 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } } } else { // nargs > 5 @@ -121,15 +121,15 @@ function iterator2arrayview( iterator, out ) { end = arguments[ 3 ]; fcn = arguments[ 4 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0Q131', fcn ) ); } thisArg = arguments[ 5 ]; } if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); + throw new TypeError( format( '0Q1E2', begin ) ); } if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); + throw new TypeError( format( '0Q1E3', end ) ); } if ( end < 0 ) { end = out.length + end; diff --git a/package.json b/package.json index d2ad73b..f4c60eb 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From b2bd3f995cf16b28f6fd61a457117ae0513c0361 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:35:50 +0000 Subject: [PATCH 93/94] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 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 5143e93..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = TypedIterator | TypedIterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( this: V, value: T, index: number, src: Collection ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ) ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: out.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 ); -* // returns -*/ -declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2arrayview; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4b740b7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ae9a059..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ef7ddf2882ca62c0ad6c5090948fcd5d968d4138 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:36:35 +0000 Subject: [PATCH 94/94] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .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 | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 256 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 79 +- SECURITY.md | 5 - benchmark/benchmark.js | 83 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 49 - docs/types/test.ts | 96 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 180 - package.json | 69 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1108 ---- 44 files changed, 4885 insertions(+), 5357 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.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8f6b5dd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-03T00:57:28.987Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1e22766..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/iter/to-array-view) 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/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 7ad4a86..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/iter/to-array-view) 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 7e92b38..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: '13 1 * * 0' - - # 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -276,7 +267,7 @@ for ( i = 0; i < arr.length; i++ ) { ## 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]. @@ -339,15 +330,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator +[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator +[@stdlib/array/to-view-iterator]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm -[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right +[@stdlib/iter/to-array-view-right]: https://github.com/stdlib-js/iter-to-array-view-right/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.js b/benchmark/benchmark.js deleted file mode 100644 index 10b760f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var pkg = require( './../package.json' ).name; -var iterator2arrayview = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var out; - var arr; - var it; - var i; - - it = randu(); // infinite iterator which can be reused - out = new Float64Array( 4 ); // short array - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2arrayview( it, out, transform ); - if ( isnan( arr[ i%out.length ] ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( arr[ 0 ] ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d52f2ee..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/iter/to-array-view" -%% click B href "https://github.com/stdlib-js/iter-to-array-view/tree/main" -%% click C href "https://github.com/stdlib-js/iter-to-array-view/tree/production" -%% click D href "https://github.com/stdlib-js/iter-to-array-view/tree/esm" -%% click E href "https://github.com/stdlib-js/iter-to-array-view/tree/deno" -%% click F href "https://github.com/stdlib-js/iter-to-array-view/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/to-array-view -[production-url]: https://github.com/stdlib-js/iter-to-array-view/tree/production -[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno -[deno-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd -[umd-readme]: https://github.com/stdlib-js/iter-to-array-view/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm -[esm-readme]: https://github.com/stdlib-js/iter-to-array-view/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 8e9f52a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2arrayview from '../docs/types/index'; -export = iterator2arrayview; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9273729..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){ -var u=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),h=require('@stdlib/assert-is-integer/dist').isPrimitive,p=require('@stdlib/array-base-assert-is-accessor-array/dist'),q=require('@stdlib/array-base-accessor-setter/dist'),y=require('@stdlib/array-base-setter/dist'),T=require('@stdlib/array-dtype/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function x(t,e){var l,m,n,r,a,f,v,i,s;if(!b(t))throw new TypeError(g('0Q146',t));if(!w(e))throw new TypeError(g('0Q12y',e));if(m=arguments.length,m===2)n=0,r=e.length;else if(m===3)u(arguments[2])?(n=0,a=arguments[2]):n=arguments[2],r=e.length;else if(m===4)u(arguments[2])?(n=0,r=e.length,a=arguments[2],l=arguments[3]):u(arguments[3])?(n=arguments[2],r=e.length,a=arguments[3]):(n=arguments[2],r=arguments[3]);else if(m===5){if(n=arguments[2],u(arguments[3]))r=e.length,a=arguments[3],l=arguments[4];else if(r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a))}else{if(n=arguments[2],r=arguments[3],a=arguments[4],!u(a))throw new TypeError(g('0Q131',a));l=arguments[5]}if(!h(n))throw new TypeError(g('0Q1E2',n));if(!h(r))throw new TypeError(g('0Q1E3',r));if(r<0?(r=e.length+r,r<0&&(r=0)):r>e.length&&(r=e.length),n<0&&(n=e.length+n,n<0&&(n=0)),v=T(e),p(e)?f=q(v):f=y(v),i=n-1,a){for(;i\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2arrayview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Fill an array-like object view with values returned from an iterator.\n*\n* @module @stdlib/iter-to-array-view\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var iterator2arrayview = require( '@stdlib/iter-to-array-view' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EAgC9C,SAASC,EAAoBC,EAAUC,EAAM,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EAEJ,GAAK,CAACjB,EAAgBQ,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,CAACT,EAAcU,CAAI,EACvB,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAI,CAAE,EAGpH,GADAE,EAAQ,UAAU,OACbA,IAAU,EACdC,EAAQ,EACRC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRE,EAAM,UAAW,CAAE,GAEnBF,EAAQ,UAAW,CAAE,EAEtBC,EAAMJ,EAAI,eACCE,IAAU,EAChBb,EAAY,UAAW,CAAE,CAAE,GAC/Bc,EAAQ,EACRC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,GACZZ,EAAY,UAAW,CAAE,CAAE,GACtCc,EAAQ,UAAW,CAAE,EACrBC,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,IAEnBF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,WAETF,IAAU,GAErB,GADAC,EAAQ,UAAW,CAAE,EAChBd,EAAY,UAAW,CAAE,CAAE,EAC/Be,EAAMJ,EAAI,OACVK,EAAM,UAAW,CAAE,EACnBJ,EAAU,UAAW,CAAE,UAEvBG,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,MAGpG,CAIN,GAHAF,EAAQ,UAAW,CAAE,EACrBC,EAAM,UAAW,CAAE,EACnBC,EAAM,UAAW,CAAE,EACd,CAAChB,EAAYgB,CAAI,EACrB,MAAM,IAAI,UAAWR,EAAQ,oEAAqEQ,CAAI,CAAE,EAEzGJ,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAACT,EAAWW,CAAM,EACtB,MAAM,IAAI,UAAWN,EAAQ,0GAA2GM,CAAM,CAAE,EAEjJ,GAAK,CAACX,EAAWY,CAAI,EACpB,MAAM,IAAI,UAAWP,EAAQ,yGAA0GO,CAAI,CAAE,EAuB9I,GArBKA,EAAM,GACVA,EAAMJ,EAAI,OAASI,EACdA,EAAM,IACVA,EAAM,IAEIA,EAAMJ,EAAI,SACrBI,EAAMJ,EAAI,QAENG,EAAQ,IACZA,EAAQH,EAAI,OAASG,EAChBA,EAAQ,IACZA,EAAQ,IAGVI,EAAKX,EAAOI,CAAI,EACXP,EAAiBO,CAAI,EACzBM,EAAMZ,EAAgBa,CAAG,EAEzBD,EAAMX,EAAQY,CAAG,EAElB,EAAIJ,EAAQ,EACPE,EAAM,CACV,KAAQ,EAAID,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGK,EAAI,KAAMJ,EAASO,EAAE,MAAO,EAAG,EAAEL,CAAM,CAAE,EAEvD,OAAOH,CACR,CACA,KAAQ,EAAII,EAAI,IACf,GAAK,EACLI,EAAIT,EAAS,KAAK,EACb,CAAAS,EAAE,OAGPF,EAAKN,EAAK,EAAGQ,EAAE,KAAM,EAEtB,OAAOR,CACR,CAKAZ,EAAO,QAAUU,IC3IjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isInteger", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2arrayview", "iterator", "out", "thisArg", "nargs", "begin", "end", "fcn", "set", "dt", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4b3ded3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,49 +0,0 @@ - -{{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] ) - Fills an array-like object view with values returned from an iterator. - - When invoked, an input function is provided three arguments: - - - value: iterated value. - - index: destination index (zero-based). - - n: iteration index (zero-based). - - Iteration stops when an output array view is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - dest: ArrayLikeObject - Output array-like object. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: dest.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 }); - > var out = new {{alias:@stdlib/array/float64}}( 20 ); - > var arr = {{alias}}( it, out, 5, 15 ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6284b97..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import randu = require( '@stdlib/random-iter-randu' ); -import iterator2arrayview = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns a collection... -{ - const iter = randu( { 'iter': 10 } ); - const out = new Float64Array( 10 ); - iterator2arrayview( iter, out ); // $ExpectType Collection - iterator2arrayview( iter, out, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection - iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2arrayview( 'abc', [] ); // $ExpectError - iterator2arrayview( 123, [] ); // $ExpectError - iterator2arrayview( true, [] ); // $ExpectError - iterator2arrayview( false, [] ); // $ExpectError - iterator2arrayview( [], [] ); // $ExpectError - iterator2arrayview( {}, [] ); // $ExpectError - iterator2arrayview( null, [] ); // $ExpectError - iterator2arrayview( undefined, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, 123 ); // $ExpectError - iterator2arrayview( iter, {} ); // $ExpectError - iterator2arrayview( iter, true ); // $ExpectError - iterator2arrayview( iter, false ); // $ExpectError - iterator2arrayview( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 'abc' ); // $ExpectError - iterator2arrayview( iter, [], [] ); // $ExpectError - iterator2arrayview( iter, [], {} ); // $ExpectError - iterator2arrayview( iter, [], true ); // $ExpectError - iterator2arrayview( iter, [], false ); // $ExpectError - iterator2arrayview( iter, [], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `begin` argument and a fourth argument which is not a number or map function... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError - iterator2arrayview( iter, [], 2, [] ); // $ExpectError - iterator2arrayview( iter, [], 2, {} ); // $ExpectError - iterator2arrayview( iter, [], 2, true ); // $ExpectError - iterator2arrayview( iter, [], 2, false ); // $ExpectError - iterator2arrayview( iter, [], 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu( { 'iter': 10 } ); - iterator2arrayview(); // $ExpectError - iterator2arrayview( iter ); // $ExpectError - iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 550cb36..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2arrayview = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -var it = randu(); - -// Fill an array view with scaled iterator values: -var arr = iterator2arrayview( it, new Float64Array( 100 ), 40, 60, scale ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 27faeba..5143e93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4f0adaa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(m,h){var a,f,j,p,g,v,c,y,b;if(!r(m))throw new TypeError(d("0Q146",m));if(!s(h))throw new TypeError(d("0Q12y",h));if(2===(f=arguments.length))j=0,p=h.length;else if(3===f)e(arguments[2])?(j=0,g=arguments[2]):j=arguments[2],p=h.length;else if(4===f)e(arguments[2])?(j=0,p=h.length,g=arguments[2],a=arguments[3]):e(arguments[3])?(j=arguments[2],p=h.length,g=arguments[3]):(j=arguments[2],p=arguments[3]);else if(5===f){if(j=arguments[2],e(arguments[3]))p=h.length,g=arguments[3],a=arguments[4];else if(p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g))}else{if(j=arguments[2],p=arguments[3],!e(g=arguments[4]))throw new TypeError(d("0Q131",g));a=arguments[5]}if(!t(j))throw new TypeError(d("0Q1E2",j));if(!t(p))throw new TypeError(d("0Q1E3",p));if(p<0?(p=h.length+p)<0&&(p=0):p>h.length&&(p=h.length),j<0&&(j=h.length+j)<0&&(j=0),c=l(h),v=i(h)?n(c):o(c),y=j-1,g){for(;y\n*/\nfunction iterator2arrayview( iterator, out ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar begin;\n\tvar end;\n\tvar fcn;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '0Q146', iterator ) );\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0Q12y', out ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tbegin = 0;\n\t\tend = out.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t}\n\t\tend = out.length;\n\t} else if ( nargs === 4 ) {\n\t\tif ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t\tthisArg = arguments[ 3 ];\n\t\t} else if ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 2 ];\n\t\t\tend = arguments[ 3 ];\n\t\t}\n\t} else if ( nargs === 5 ) {\n\t\tbegin = arguments[ 2 ];\n\t\tif ( isFunction( arguments[ 3 ] ) ) {\n\t\t\tend = out.length;\n\t\t\tfcn = arguments[ 3 ];\n\t\t\tthisArg = arguments[ 4 ];\n\t\t} else {\n\t\t\tend = arguments[ 3 ];\n\t\t\tfcn = arguments[ 4 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t\t}\n\t\t}\n\t} else { // nargs > 5\n\t\tbegin = arguments[ 2 ];\n\t\tend = arguments[ 3 ];\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( '0Q131', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( '0Q1E2', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( '0Q1E3', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = out.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > out.length ) {\n\t\tend = out.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = out.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\ti = begin - 1;\n\tif ( fcn ) {\n\t\twhile ( i < end-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i, i-begin ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < end-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2arrayview;\n"],"names":["iterator2arrayview","iterator","out","thisArg","nargs","begin","end","fcn","set","dt","i","v","isIteratorLike","TypeError","format","isCollection","arguments","length","isFunction","isInteger","dtype","isAccessorArray","accessorSetter","setter","next","done","call","value"],"mappings":";;+2BA8DA,SAASA,EAAoBC,EAAUC,GACtC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAgBX,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAGvC,GAAe,KADfE,EAAQY,UAAUC,QAEjBZ,EAAQ,EACRC,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRE,EAAMS,UAAW,IAEjBX,EAAQW,UAAW,GAEpBV,EAAMJ,EAAIe,YACJ,GAAe,IAAVb,EACNc,EAAYF,UAAW,KAC3BX,EAAQ,EACRC,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,IACVE,EAAYF,UAAW,KAClCX,EAAQW,UAAW,GACnBV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,KAEjBX,EAAQW,UAAW,GACnBV,EAAMU,UAAW,SAEZ,GAAe,IAAVZ,GAEX,GADAC,EAAQW,UAAW,GACdE,EAAYF,UAAW,IAC3BV,EAAMJ,EAAIe,OACVV,EAAMS,UAAW,GACjBb,EAAUa,UAAW,QAIrB,GAFAV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,QAGlC,CAIN,GAHAF,EAAQW,UAAW,GACnBV,EAAMU,UAAW,IAEXE,EADNX,EAAMS,UAAW,IAEhB,MAAM,IAAIH,UAAWC,EAAQ,QAASP,IAEvCJ,EAAUa,UAAW,EACrB,CACD,IAAMG,EAAWd,GAChB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAuBvC,GArBKA,EAAM,GACVA,EAAMJ,EAAIe,OAASX,GACR,IACVA,EAAM,GAEIA,EAAMJ,EAAIe,SACrBX,EAAMJ,EAAIe,QAENZ,EAAQ,IACZA,EAAQH,EAAIe,OAASZ,GACR,IACZA,EAAQ,GAGVI,EAAKW,EAAOlB,GAEXM,EADIa,EAAiBnB,GACfoB,EAAgBb,GAEhBc,EAAQd,GAEfC,EAAIL,EAAQ,EACPE,EAAM,CACV,KAAQG,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGH,EAAImB,KAAMvB,EAASQ,EAAEgB,MAAOjB,EAAGA,EAAEL,IAE/C,OAAOH,CACP,CACD,KAAQQ,EAAIJ,EAAI,IACfI,GAAK,IACLC,EAAIV,EAASuB,QACNC,OAGPjB,EAAKN,EAAKQ,EAAGC,EAAEgB,OAEhB,OAAOzB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f061bd2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill an array-like object view with values returned from an iterator. -* -* @module @stdlib/iter-to-array-view -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var iterator2arrayview = require( '@stdlib/iter-to-array-view' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2381fd5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Fills an array-like object view with values returned from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} out - output array -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=out.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an iterator -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer (starting index) or a callback function -* @throws {TypeError} fourth argument must be an integer (ending index) or a callback function -* @throws {TypeError} fifth argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 ); -* // returns -*/ -function iterator2arrayview( iterator, out ) { - var thisArg; - var nargs; - var begin; - var end; - var fcn; - var set; - var dt; - var i; - var v; - - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '0Q146', iterator ) ); - } - if ( !isCollection( out ) ) { - throw new TypeError( format( '0Q12y', out ) ); - } - nargs = arguments.length; - if ( nargs === 2 ) { - begin = 0; - end = out.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 2 ]; - } - end = out.length; - } else if ( nargs === 4 ) { - if ( isFunction( arguments[ 2 ] ) ) { - begin = 0; - end = out.length; - fcn = arguments[ 2 ]; - thisArg = arguments[ 3 ]; - } else if ( isFunction( arguments[ 3 ] ) ) { - begin = arguments[ 2 ]; - end = out.length; - fcn = arguments[ 3 ]; - } else { - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - } - } else if ( nargs === 5 ) { - begin = arguments[ 2 ]; - if ( isFunction( arguments[ 3 ] ) ) { - end = out.length; - fcn = arguments[ 3 ]; - thisArg = arguments[ 4 ]; - } else { - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - } - } else { // nargs > 5 - begin = arguments[ 2 ]; - end = arguments[ 3 ]; - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0Q131', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( '0Q1E2', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( '0Q1E3', end ) ); - } - if ( end < 0 ) { - end = out.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > out.length ) { - end = out.length; - } - if ( begin < 0 ) { - begin = out.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - i = begin - 1; - if ( fcn ) { - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i, i-begin ) ); - } - return out; - } - while ( i < end-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2arrayview; diff --git a/package.json b/package.json index f4c60eb..5224f1d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Fill an array-like object view with values returned from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ae9a059 --- /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/test.js b/test/test.js deleted file mode 100644 index a522280..0000000 --- a/test/test.js +++ /dev/null @@ -1,1108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var iterator2arrayview = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2arrayview, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator', 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() { - iterator2arrayview( value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end)', 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (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() { - iterator2arrayview( value, new Float64Array( 10 ), noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an iterator (begin + end + 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() { - iterator2arrayview( value, new Float64Array( 10 ), 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin)', 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() { - iterator2arrayview( randu(), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end)', 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() { - iterator2arrayview( randu(), value, 1, 5 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + end + 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() { - iterator2arrayview( randu(), value, 1, 5, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an 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() { - iterator2arrayview( randu(), value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (begin + 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() { - iterator2arrayview( randu(), value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is neither an integer nor a callback function', function test( t ) { - var values; - var i; - - 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function (context)', 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() { - iterator2arrayview( randu(), new Float64Array( 10 ), 1, 5, value, {} ); // eslint-disable-line max-len - }; - } -}); - -tape( 'the function fills an array-like object with values returned from an iterator', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object with values returned from an iterator (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ), - new Complex128( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 6 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 1, 2 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin < 0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000 ); - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 5, 6 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4 ); - expected = new Float64Array( [ 0, 0, 1, 2, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -1000 ); - expected = new Float64Array( [ 1, 2, 3, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function fills an array-like object view with values returned from an iterator (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 0, -100 ); - expected = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Complex128Array( values.length ); - actual = iterator2arrayview( it, out, clbk ); - expected = new Float64Array( [ 1, 0, 2, 1, 3, 2, 4, 3 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function clbk( v, i ) { - return new Complex128( v, i ); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4000, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 25, 36 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, 4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value (begin<0 + end<0)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, -6, -4, scale ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - return v * (n+1); - } -}); - -tape( 'the function stops filling an array-like object once an iterator ends', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function stops filling an array-like object once an iterator ends (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2arrayview( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2arrayview( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 9, 16, 0, 0 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (begin + end)', function test( t ) { - var expected; - var actual; - var values; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( 8 ); - actual = iterator2arrayview( it, out, 2, 4, scale, ctx ); - expected = new Float64Array( [ 0, 0, 1, 4, 0, 0, 0, 0 ] ); - - t.equal( ctx.count, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i, n ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (n+1); - } -}); - -tape( 'the function supports infinite iterators', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (begin + end)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6 ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 5, scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports infinite iterators (begin + end + callback)', function test( t ) { - var out = iterator2arrayview( randu(), new Float64Array( 10 ), 2, 6, scale ); // eslint-disable-line max-len - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -});