@stdlib/iter-to-array-view 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/LICENSE CHANGED
@@ -175,307 +175,3 @@
175
175
  of your accepting any such warranty or additional liability.
176
176
 
177
177
  END OF TERMS AND CONDITIONS
178
-
179
-
180
-
181
- Boost Software License - Version 1.0 - August 17th, 2003
182
-
183
- Permission is hereby granted, free of charge, to any person or organization
184
- obtaining a copy of the software and accompanying documentation covered by this
185
- license (the "Software") to use, reproduce, display, distribute, execute, and
186
- transmit the Software, and to prepare derivative works of the Software, and to
187
- permit third-parties to whom the Software is furnished to do so, all subject to
188
- the following:
189
-
190
- The copyright notices in the Software and this entire statement, including the
191
- above license grant, this restriction and the following disclaimer, must be
192
- included in all copies of the Software, in whole or in part, and all derivative
193
- works of the Software, unless such copies or derivative works are solely in the
194
- form of machine-executable object code generated by a source language processor.
195
-
196
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
197
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
198
- FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
199
- COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
200
- OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
201
- OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
202
-
203
-
204
-
205
-
206
- DEPENDENCIES
207
-
208
- The library links against the following external libraries, which have their own
209
- licenses:
210
-
211
- * OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
212
- def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
213
-
214
- Copyright (c) 2011-2014, The OpenBLAS Project
215
- All rights reserved.
216
-
217
- Redistribution and use in source and binary forms, with or without
218
- modification, are permitted provided that the following conditions are
219
- met:
220
-
221
- 1. Redistributions of source code must retain the above copyright
222
- notice, this list of conditions and the following disclaimer.
223
-
224
- 2. Redistributions in binary form must reproduce the above copyright
225
- notice, this list of conditions and the following disclaimer in
226
- the documentation and/or other materials provided with the
227
- distribution.
228
-
229
- 3. Neither the name of the OpenBLAS project nor the names of
230
- its contributors may be used to endorse or promote products
231
- derived from this software without specific prior written
232
- permission.
233
-
234
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
235
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
237
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
238
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
240
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
243
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244
-
245
-
246
- * Electron <https://raw.githubusercontent.com/electron/electron/
247
- c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
248
-
249
- Copyright (c) 2013-2017 GitHub Inc.
250
-
251
- Permission is hereby granted, free of charge, to any person obtaining
252
- a copy of this software and associated documentation files (the
253
- "Software"), to deal in the Software without restriction, including
254
- without limitation the rights to use, copy, modify, merge, publish,
255
- distribute, sublicense, and/or sell copies of the Software, and to
256
- permit persons to whom the Software is furnished to do so, subject to
257
- the following conditions:
258
-
259
- The above copyright notice and this permission notice shall be
260
- included in all copies or substantial portions of the Software.
261
-
262
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
263
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
264
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
265
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
266
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
267
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
268
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
269
-
270
-
271
- * Boost <http://www.boost.org/LICENSE_1_0.txt>
272
-
273
- Boost Software License - Version 1.0 - August 17th, 2003
274
-
275
- Permission is hereby granted, free of charge, to any person or organization
276
- obtaining a copy of the software and accompanying documentation covered by
277
- this license (the "Software") to use, reproduce, display, distribute,
278
- execute, and transmit the Software, and to prepare derivative works of the
279
- Software, and to permit third-parties to whom the Software is furnished to
280
- do so, all subject to the following:
281
-
282
- The copyright notices in the Software and this entire statement, including
283
- the above license grant, this restriction and the following disclaimer,
284
- must be included in all copies of the Software, in whole or in part, and
285
- all derivative works of the Software, unless such copies or derivative
286
- works are solely in the form of machine-executable object code generated by
287
- a source language processor.
288
-
289
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
290
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
291
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
292
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
293
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
294
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
295
- DEALINGS IN THE SOFTWARE.
296
-
297
-
298
- * Cephes <http://www.netlib.org/cephes/readme>
299
-
300
- Copyright (c) 1984-2000 Stephen L. Moshier
301
-
302
- Some software in this archive may be from the book _Methods and Programs for
303
- Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
304
- or from the Cephes Mathematical Library, a commercial product. In either event,
305
- it is copyrighted by the author. What you see here may be used freely but it
306
- comes with no support or guarantee.
307
-
308
- Stephen L. Moshier
309
- moshier@na-net.ornl.gov
310
-
311
-
312
-
313
- ATTRIBUTION
314
-
315
- The library contains implementations from the following external libraries,
316
- which have their own licenses:
317
-
318
- * FreeBSD <https://svnweb.freebsd.org/>
319
-
320
- Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
321
-
322
- Developed at SunPro, a Sun Microsystems, Inc. business.
323
- Permission to use, copy, modify, and distribute this
324
- software is freely granted, provided that this notice
325
- is preserved.
326
-
327
-
328
- * FDLIBM <http://www.netlib.org/fdlibm/>
329
-
330
- Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
331
-
332
- Developed at SunPro, a Sun Microsystems, Inc. business.
333
- Permission to use, copy, modify, and distribute this
334
- software is freely granted, provided that this notice
335
- is preserved.
336
-
337
-
338
- * Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
339
-
340
- Copyright (c) 2009 The Go Authors. All rights reserved.
341
-
342
- Redistribution and use in source and binary forms, with or without
343
- modification, are permitted provided that the following conditions are
344
- met:
345
-
346
- * Redistributions of source code must retain the above copyright
347
- notice, this list of conditions and the following disclaimer.
348
- * Redistributions in binary form must reproduce the above
349
- copyright notice, this list of conditions and the following disclaimer
350
- in the documentation and/or other materials provided with the
351
- distribution.
352
- * Neither the name of Google Inc. nor the names of its
353
- contributors may be used to endorse or promote products derived from
354
- this software without specific prior written permission.
355
-
356
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
357
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
358
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
359
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
360
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
361
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
362
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
363
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
364
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
366
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
367
-
368
-
369
- * SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
370
-
371
- Public domain.
372
-
373
-
374
- * ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
375
-
376
- Copyright JS Foundation and other contributors, https://js.foundation
377
-
378
- Permission is hereby granted, free of charge, to any person obtaining a copy
379
- of this software and associated documentation files (the "Software"), to deal
380
- in the Software without restriction, including without limitation the rights
381
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
382
- copies of the Software, and to permit persons to whom the Software is
383
- furnished to do so, subject to the following conditions:
384
-
385
- The above copyright notice and this permission notice shall be included in
386
- all copies or substantial portions of the Software.
387
-
388
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
389
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
390
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
391
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
392
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
393
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
394
- THE SOFTWARE.
395
-
396
-
397
- * StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
398
- e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
399
-
400
- Copyright (c) 2015: Dahua Lin.
401
-
402
- Permission is hereby granted, free of charge, to any person obtaining
403
- a copy of this software and associated documentation files (the
404
- "Software"), to deal in the Software without restriction, including
405
- without limitation the rights to use, copy, modify, merge, publish,
406
- distribute, sublicense, and/or sell copies of the Software, and to
407
- permit persons to whom the Software is furnished to do so, subject to
408
- the following conditions:
409
-
410
- The above copyright notice and this permission notice shall be
411
- included in all copies or substantial portions of the Software.
412
-
413
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
414
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
415
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
416
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
417
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
418
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
419
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
420
-
421
-
422
- * SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
423
- SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
424
-
425
- The MIT License (MIT)
426
-
427
- Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
428
-
429
- https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
430
-
431
- Permission is hereby granted, free of charge, to any person obtaining a copy
432
- of this software and associated documentation files (the "Software"), to deal
433
- in the Software without restriction, including without limitation the rights
434
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
435
- copies of the Software, and to permit persons to whom the Software is
436
- furnished to do so, subject to the following conditions:
437
-
438
- The above copyright notice and this permission notice shall be included in all
439
- copies or substantial portions of the Software.
440
-
441
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
442
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
443
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
444
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
445
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
446
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
447
- SOFTWARE.
448
-
449
-
450
- * MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
451
- mt19937ar.c>
452
-
453
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
454
- All rights reserved.
455
-
456
- Redistribution and use in source and binary forms, with or without
457
- modification, are permitted provided that the following conditions
458
- are met:
459
-
460
- 1. Redistributions of source code must retain the above copyright
461
- notice, this list of conditions and the following disclaimer.
462
-
463
- 2. Redistributions in binary form must reproduce the above copyright
464
- notice, this list of conditions and the following disclaimer in the
465
- documentation and/or other materials provided with the distribution.
466
-
467
- 3. The names of its contributors may not be used to endorse or promote
468
- products derived from this software without specific prior written
469
- permission.
470
-
471
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
472
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
473
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
474
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
475
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
476
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
477
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
478
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
479
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
480
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
481
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md CHANGED
@@ -18,9 +18,20 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # iterator2arrayview
22
33
 
23
- [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
24
35
 
25
36
  > Fill an array-like object view with values returned from an iterator.
26
37
 
@@ -132,9 +143,9 @@ var arr = iterator2arrayview( iter, new Float64Array( 4 ), fcn );
132
143
 
133
144
  The invoked function is provided three arguments:
134
145
 
135
- - `value`: iterated value
136
- - `index`: destination index
137
- - `n`: iteration count (zero-based)
146
+ - **value**: iterated value.
147
+ - **index**: destination index.
148
+ - **n**: iteration count (zero-based).
138
149
 
139
150
  ```javascript
140
151
  var Uint8Array = require( '@stdlib/array-uint8' );
@@ -183,6 +194,7 @@ var count = ctx.count;
183
194
  ## Notes
184
195
 
185
196
  - Iteration stops when an output array view is full **or** an iterator finishes; whichever comes first.
197
+ - The function supports output array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array-complex64`][@stdlib/array/complex64]).
186
198
 
187
199
  </section>
188
200
 
@@ -229,6 +241,22 @@ for ( i = 0; i < arr.length; i++ ) {
229
241
 
230
242
  <!-- /.references -->
231
243
 
244
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
245
+
246
+ <section class="related">
247
+
248
+ * * *
249
+
250
+ ## See Also
251
+
252
+ - <span class="package-name">[`@stdlib/array-from-iterator`][@stdlib/array/from-iterator]</span><span class="delimiter">: </span><span class="description">create (or fill) an array from an iterator.</span>
253
+ - <span class="package-name">[`@stdlib/array-to-view-iterator`][@stdlib/array/to-view-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object view.</span>
254
+ - <span class="package-name">[`@stdlib/iter-to-array-view-right`][@stdlib/iter/to-array-view-right]</span><span class="delimiter">: </span><span class="description">fill an array-like object view from right to left with values returned from an iterator.</span>
255
+
256
+ </section>
257
+
258
+ <!-- /.related -->
259
+
232
260
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
233
261
 
234
262
 
@@ -255,7 +283,7 @@ See [LICENSE][stdlib-license].
255
283
 
256
284
  ## Copyright
257
285
 
258
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
286
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
259
287
 
260
288
  </section>
261
289
 
@@ -268,24 +296,48 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
268
296
  [npm-image]: http://img.shields.io/npm/v/@stdlib/iter-to-array-view.svg
269
297
  [npm-url]: https://npmjs.org/package/@stdlib/iter-to-array-view
270
298
 
271
- [test-image]: https://github.com/stdlib-js/iter-to-array-view/actions/workflows/test.yml/badge.svg
272
- [test-url]: https://github.com/stdlib-js/iter-to-array-view/actions/workflows/test.yml
299
+ [test-image]: https://github.com/stdlib-js/iter-to-array-view/actions/workflows/test.yml/badge.svg?branch=v0.1.0
300
+ [test-url]: https://github.com/stdlib-js/iter-to-array-view/actions/workflows/test.yml?query=branch:v0.1.0
273
301
 
274
302
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/iter-to-array-view/main.svg
275
303
  [coverage-url]: https://codecov.io/github/stdlib-js/iter-to-array-view?branch=main
276
304
 
305
+ <!--
306
+
277
307
  [dependencies-image]: https://img.shields.io/david/stdlib-js/iter-to-array-view.svg
278
308
  [dependencies-url]: https://david-dm.org/stdlib-js/iter-to-array-view/main
279
309
 
310
+ -->
311
+
280
312
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
281
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
313
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
282
314
 
283
315
  [stdlib]: https://github.com/stdlib-js/stdlib
284
316
 
285
317
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
286
318
 
319
+ [umd]: https://github.com/umdjs/umd
320
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
321
+
322
+ [deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno
323
+ [umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd
324
+ [esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm
325
+ [branches-url]: https://github.com/stdlib-js/iter-to-array-view/blob/main/branches.md
326
+
287
327
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE
288
328
 
329
+ [@stdlib/array/complex64]: https://www.npmjs.com/package/@stdlib/array-complex64
330
+
331
+ <!-- <related-links> -->
332
+
333
+ [@stdlib/array/from-iterator]: https://www.npmjs.com/package/@stdlib/array-from-iterator
334
+
335
+ [@stdlib/array/to-view-iterator]: https://www.npmjs.com/package/@stdlib/array-to-view-iterator
336
+
337
+ [@stdlib/iter/to-array-view-right]: https://www.npmjs.com/package/@stdlib/iter-to-array-view-right
338
+
339
+ <!-- </related-links> -->
340
+
289
341
  </section>
290
342
 
291
343
  <!-- /.links -->
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import iterator2arrayview from '../docs/types/index';
3
+ export = iterator2arrayview;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var d=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var c=d(function(F,o){
2
+ 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<r-1&&(i+=1,s=t.next(),!s.done);)f(e,i,a.call(l,s.value,i,i-n));return e}for(;i<r-1&&(i+=1,s=t.next(),!s.done);)f(e,i,s.value);return e}o.exports=x
3
+ });var E=c();module.exports=E;
4
+ /** @license Apache-2.0 */
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/main.js", "../lib/index.js"],
4
+ "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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar format = require( '@stdlib/string-format' );\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 <Float64Array>\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 <Float64Array>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "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",
6
+ "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"]
7
+ }
@@ -16,23 +16,22 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter';
24
- import { ArrayLike } from '@stdlib/types/array';
25
- import { Collection } from '@stdlib/types/object';
23
+ import { TypedIterator, TypedIterableIterator } from '@stdlib/types/iter';
24
+ import { Collection } from '@stdlib/types/array';
26
25
 
27
26
  // Define a union type representing both iterable and non-iterable iterators:
28
- type Iterator = Iter | IterableIterator;
27
+ type Iterator<T> = TypedIterator<T> | TypedIterableIterator<T>;
29
28
 
30
29
  /**
31
30
  * Map function invoked for each iterated value.
32
31
  *
33
32
  * @returns iterator value
34
33
  */
35
- type Nullary = () => any;
34
+ type Nullary<U, V> = ( this: V ) => U;
36
35
 
37
36
  /**
38
37
  * Map function invoked for each iterated value.
@@ -40,7 +39,7 @@ type Nullary = () => any;
40
39
  * @param value - iterated value
41
40
  * @returns iterator value
42
41
  */
43
- type Unary = ( value: any ) => any;
42
+ type Unary<T, U, V> = ( this: V, value: T ) => U;
44
43
 
45
44
  /**
46
45
  * Map function invoked for each iterated value.
@@ -49,7 +48,7 @@ type Unary = ( value: any ) => any;
49
48
  * @param index - iterated value index
50
49
  * @returns iterator value
51
50
  */
52
- type Binary = ( value: any, index: number ) => any;
51
+ type Binary<T, U, V> = ( this: V, value: T, index: number ) => U;
53
52
 
54
53
  /**
55
54
  * Map function invoked for each iterated value.
@@ -59,7 +58,7 @@ type Binary = ( value: any, index: number ) => any;
59
58
  * @param src - source array-like object
60
59
  * @returns iterator value
61
60
  */
62
- type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
61
+ type Ternary<T, U, V> = ( this: V, value: T, index: number, src: Collection<U> ) => U;
63
62
 
64
63
  /**
65
64
  * Map function invoked for each iterated value.
@@ -69,7 +68,7 @@ type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
69
68
  * @param src - source array-like object
70
69
  * @returns iterator value
71
70
  */
72
- type MapFunction = Nullary | Unary | Binary | Tertiary;
71
+ type MapFunction<T, U, V> = Nullary<U, V> | Unary<T, U, V> | Binary<T, U, V> | Ternary<T, U, V>;
73
72
 
74
73
  /**
75
74
  * Fills an array-like object view with values returned from an iterator.
@@ -91,7 +90,7 @@ type MapFunction = Nullary | Unary | Binary | Tertiary;
91
90
  * var arr = iterator2arrayview( iter, new Float64Array( 20 ) );
92
91
  * // returns <Float64Array>
93
92
  */
94
- declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
93
+ declare function iterator2arrayview<T = unknown, U = unknown, V = unknown>( iterator: Iterator<T>, out: Collection<U>, mapFcn?: MapFunction<T, U, V>, thisArg?: ThisParameterType<MapFunction<T, U, V>> ): Collection<U>;
95
94
 
96
95
  /**
97
96
  * Fills an array-like object view with values returned from an iterator.
@@ -114,7 +113,7 @@ declare function iterator2arrayview( iterator: Iterator, out: Collection, mapFcn
114
113
  * var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5 );
115
114
  * // returns <Float64Array>
116
115
  */
117
- declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
116
+ declare function iterator2arrayview<T = unknown, U = unknown, V = unknown>( iterator: Iterator<T>, out: Collection<U>, begin: number, mapFcn?: MapFunction<T, U, V>, thisArg?: ThisParameterType<MapFunction<T, U, V>> ): Collection<U>;
118
117
 
119
118
  /**
120
119
  * Fills an array-like object view with values returned from an iterator.
@@ -138,7 +137,7 @@ declare function iterator2arrayview( iterator: Iterator, out: Collection, begin:
138
137
  * var arr = iterator2arrayview( iter, new Float64Array( 20 ), 5, 8 );
139
138
  * // returns <Float64Array>
140
139
  */
141
- declare function iterator2arrayview( iterator: Iterator, out: Collection, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
140
+ declare function iterator2arrayview<T = unknown, U = unknown, V = unknown>( iterator: Iterator<T>, out: Collection<U>, begin: number, end: number, mapFcn?: MapFunction<T, U, V>, thisArg?: ThisParameterType<MapFunction<T, U, V>> ): Collection<U>;
142
141
 
143
142
 
144
143
  // EXPORTS //
package/lib/main.js CHANGED
@@ -24,7 +24,11 @@ var isFunction = require( '@stdlib/assert-is-function' );
24
24
  var isCollection = require( '@stdlib/assert-is-collection' );
25
25
  var isIteratorLike = require( '@stdlib/assert-is-iterator-like' );
26
26
  var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
27
- var hasOwnProp = require( '@stdlib/assert-has-own-property' );
27
+ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );
28
+ var accessorSetter = require( '@stdlib/array-base-accessor-setter' );
29
+ var setter = require( '@stdlib/array-base-setter' );
30
+ var dtype = require( '@stdlib/array-dtype' );
31
+ var format = require( '@stdlib/string-format' );
28
32
 
29
33
 
30
34
  // MAIN //
@@ -62,14 +66,16 @@ function iterator2arrayview( iterator, out ) {
62
66
  var begin;
63
67
  var end;
64
68
  var fcn;
69
+ var set;
70
+ var dt;
65
71
  var i;
66
72
  var v;
67
73
 
68
74
  if ( !isIteratorLike( iterator ) ) {
69
- throw new TypeError( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `' + iterator + '`.' );
75
+ throw new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );
70
76
  }
71
77
  if ( !isCollection( out ) ) {
72
- throw new TypeError( 'invalid argument. Second argument must be an array-like object. Value: `' + out + '`.' );
78
+ throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', out ) );
73
79
  }
74
80
  nargs = arguments.length;
75
81
  if ( nargs === 2 ) {
@@ -107,7 +113,7 @@ function iterator2arrayview( iterator, out ) {
107
113
  end = arguments[ 3 ];
108
114
  fcn = arguments[ 4 ];
109
115
  if ( !isFunction( fcn ) ) {
110
- throw new TypeError( 'invalid argument. Fifth argument must be a callback function. Value: `' + fcn + '`.' );
116
+ throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );
111
117
  }
112
118
  }
113
119
  } else { // nargs > 5
@@ -115,15 +121,15 @@ function iterator2arrayview( iterator, out ) {
115
121
  end = arguments[ 3 ];
116
122
  fcn = arguments[ 4 ];
117
123
  if ( !isFunction( fcn ) ) {
118
- throw new TypeError( 'invalid argument. Fifth argument must be a callback function. Value: `' + fcn + '`.' );
124
+ throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );
119
125
  }
120
126
  thisArg = arguments[ 5 ];
121
127
  }
122
128
  if ( !isInteger( begin ) ) {
123
- throw new TypeError( 'invalid argument. Third argument must be either an integer (starting index) or a callback function. Value: `' + begin + '`.' );
129
+ throw new TypeError( format( 'invalid argument. Third argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );
124
130
  }
125
131
  if ( !isInteger( end ) ) {
126
- throw new TypeError( 'invalid argument. Fourth argument must be either an integer (ending index) or a callback function. Value: `' + end + '`.' );
132
+ throw new TypeError( format( 'invalid argument. Fourth argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );
127
133
  }
128
134
  if ( end < 0 ) {
129
135
  end = out.length + end;
@@ -139,29 +145,31 @@ function iterator2arrayview( iterator, out ) {
139
145
  begin = 0;
140
146
  }
141
147
  }
148
+ dt = dtype( out );
149
+ if ( isAccessorArray( out ) ) {
150
+ set = accessorSetter( dt );
151
+ } else {
152
+ set = setter( dt );
153
+ }
142
154
  i = begin - 1;
143
155
  if ( fcn ) {
144
156
  while ( i < end-1 ) {
145
157
  i += 1;
146
158
  v = iterator.next();
147
- if ( hasOwnProp( v, 'value' ) ) {
148
- out[ i ] = fcn.call( thisArg, v.value, i, i-begin );
149
- }
150
159
  if ( v.done ) {
151
160
  break;
152
161
  }
162
+ set( out, i, fcn.call( thisArg, v.value, i, i-begin ) );
153
163
  }
154
164
  return out;
155
165
  }
156
166
  while ( i < end-1 ) {
157
167
  i += 1;
158
168
  v = iterator.next();
159
- if ( hasOwnProp( v, 'value' ) ) {
160
- out[ i ] = v.value;
161
- }
162
169
  if ( v.done ) {
163
170
  break;
164
171
  }
172
+ set( out, i, v.value );
165
173
  }
166
174
  return out;
167
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/iter-to-array-view",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "description": "Fill an array-like object view with values returned from an iterator.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,23 +37,31 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/assert-has-own-property": "^0.0.x",
41
- "@stdlib/assert-is-collection": "^0.0.x",
42
- "@stdlib/assert-is-function": "^0.0.x",
43
- "@stdlib/assert-is-integer": "^0.0.x",
44
- "@stdlib/assert-is-iterator-like": "^0.0.x",
45
- "@stdlib/types": "^0.0.x"
40
+ "@stdlib/array-base-accessor-setter": "^0.1.0",
41
+ "@stdlib/array-base-assert-is-accessor-array": "^0.1.0",
42
+ "@stdlib/array-base-setter": "^0.1.0",
43
+ "@stdlib/array-dtype": "^0.1.0",
44
+ "@stdlib/assert-is-collection": "^0.1.0",
45
+ "@stdlib/assert-is-function": "^0.1.0",
46
+ "@stdlib/assert-is-integer": "^0.1.0",
47
+ "@stdlib/assert-is-iterator-like": "^0.1.0",
48
+ "@stdlib/string-format": "^0.1.0",
49
+ "@stdlib/types": "^0.1.0",
50
+ "@stdlib/error-tools-fmtprodmsg": "^0.1.0"
46
51
  },
47
52
  "devDependencies": {
48
- "@stdlib/array-float64": "^0.0.x",
49
- "@stdlib/array-to-iterator": "^0.0.x",
50
- "@stdlib/bench": "^0.0.x",
51
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
52
- "@stdlib/random-iter-randu": "^0.0.x",
53
- "@stdlib/utils-noop": "^0.0.x",
53
+ "@stdlib/array-complex128": "^0.1.0",
54
+ "@stdlib/array-float64": "^0.1.0",
55
+ "@stdlib/array-to-iterator": "^0.0.6",
56
+ "@stdlib/bench": "^0.1.0",
57
+ "@stdlib/complex-float64": "^0.1.0",
58
+ "@stdlib/math-base-assert-is-nan": "^0.1.0",
59
+ "@stdlib/random-iter-randu": "^0.0.6",
60
+ "@stdlib/strided-base-reinterpret-complex128": "^0.1.0",
61
+ "@stdlib/utils-noop": "^0.1.0",
54
62
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
55
63
  "istanbul": "^0.4.1",
56
- "tap-spec": "5.x.x"
64
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
57
65
  },
58
66
  "engines": {
59
67
  "node": ">=0.10.0",
@@ -96,7 +104,7 @@
96
104
  "slice"
97
105
  ],
98
106
  "funding": {
99
- "type": "patreon",
100
- "url": "https://www.patreon.com/athan"
107
+ "type": "opencollective",
108
+ "url": "https://opencollective.com/stdlib"
101
109
  }
102
110
  }
package/docs/repl.txt DELETED
@@ -1,49 +0,0 @@
1
-
2
- {{alias}}( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] )
3
- Fills an array-like object view with values returned from an iterator.
4
-
5
- When invoked, an input function is provided three arguments:
6
-
7
- - value: iterated value
8
- - index: destination index (zero-based)
9
- - n: iteration index (zero-based)
10
-
11
- Iteration stops when an output array view is full or an iterator finishes;
12
- whichever comes first.
13
-
14
- Parameters
15
- ----------
16
- iterator: Object
17
- Source iterator.
18
-
19
- dest: ArrayLikeObject
20
- Output array-like object.
21
-
22
- begin: integer (optional)
23
- Starting index (inclusive). When negative, determined relative to the
24
- last element. Default: 0.
25
-
26
- end: integer (optional)
27
- Ending index (non-inclusive). When negative, determined relative to the
28
- last element. Default: dest.length.
29
-
30
- mapFcn: Function (optional)
31
- Function to invoke for each iterated value.
32
-
33
- thisArg: any (optional)
34
- Execution context.
35
-
36
- Returns
37
- -------
38
- out: ArrayLikeObject
39
- Output array.
40
-
41
- Examples
42
- --------
43
- > var it = {{alias:@stdlib/random/iter/randu}}({ 'iter': 10 });
44
- > var out = new {{alias:@stdlib/array/float64}}( 20 );
45
- > var arr = {{alias}}( it, out, 5, 15 )
46
-
47
- See Also
48
- --------
49
-
@@ -1,96 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2021 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import randu = require( '@stdlib/random-iter-randu' );
20
- import iterator2arrayview = require( './index' );
21
-
22
- /**
23
- * Multiplies a value by 10.
24
- *
25
- * @param v - iterated value
26
- * @returns new value
27
- */
28
- function times10( v: number ): number {
29
- return v * 10.0;
30
- }
31
-
32
-
33
- // TESTS //
34
-
35
- // The function returns a collection...
36
- {
37
- const iter = randu( { 'iter': 10 } );
38
- const out = new Float64Array( 10 );
39
- iterator2arrayview( iter, out ); // $ExpectType Collection
40
- iterator2arrayview( iter, out, times10 ); // $ExpectType Collection
41
- iterator2arrayview( iter, out, times10, {} ); // $ExpectType Collection
42
- iterator2arrayview( iter, out, 0, 10, times10 ); // $ExpectType Collection
43
- iterator2arrayview( iter, out, 0, 10, times10, {} ); // $ExpectType Collection
44
- }
45
-
46
- // The compiler throws an error if the function is provided a first argument which is not an iterator...
47
- {
48
- iterator2arrayview( 'abc', [] ); // $ExpectError
49
- iterator2arrayview( 123, [] ); // $ExpectError
50
- iterator2arrayview( true, [] ); // $ExpectError
51
- iterator2arrayview( false, [] ); // $ExpectError
52
- iterator2arrayview( [], [] ); // $ExpectError
53
- iterator2arrayview( {}, [] ); // $ExpectError
54
- iterator2arrayview( null, [] ); // $ExpectError
55
- iterator2arrayview( undefined, [] ); // $ExpectError
56
- }
57
-
58
- // The compiler throws an error if the function is provided a second argument which is not a collection...
59
- {
60
- const iter = randu( { 'iter': 10 } );
61
- iterator2arrayview( iter, 123 ); // $ExpectError
62
- iterator2arrayview( iter, {} ); // $ExpectError
63
- iterator2arrayview( iter, true ); // $ExpectError
64
- iterator2arrayview( iter, false ); // $ExpectError
65
- iterator2arrayview( iter, null ); // $ExpectError
66
- }
67
-
68
- // The compiler throws an error if the function is provided a third argument which is not a number or map function...
69
- {
70
- const iter = randu( { 'iter': 10 } );
71
- iterator2arrayview( iter, [], 'abc' ); // $ExpectError
72
- iterator2arrayview( iter, [], [] ); // $ExpectError
73
- iterator2arrayview( iter, [], {} ); // $ExpectError
74
- iterator2arrayview( iter, [], true ); // $ExpectError
75
- iterator2arrayview( iter, [], false ); // $ExpectError
76
- iterator2arrayview( iter, [], null ); // $ExpectError
77
- }
78
-
79
- // 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...
80
- {
81
- const iter = randu( { 'iter': 10 } );
82
- iterator2arrayview( iter, [], 2, 'abc' ); // $ExpectError
83
- iterator2arrayview( iter, [], 2, [] ); // $ExpectError
84
- iterator2arrayview( iter, [], 2, {} ); // $ExpectError
85
- iterator2arrayview( iter, [], 2, true ); // $ExpectError
86
- iterator2arrayview( iter, [], 2, false ); // $ExpectError
87
- iterator2arrayview( iter, [], 2, null ); // $ExpectError
88
- }
89
-
90
- // The compiler throws an error if the function is provided an unsupported number of arguments...
91
- {
92
- const iter = randu( { 'iter': 10 } );
93
- iterator2arrayview(); // $ExpectError
94
- iterator2arrayview( iter ); // $ExpectError
95
- iterator2arrayview( iter, [], 0, 10, times10, {}, 123 ); // $ExpectError
96
- }