@stdlib/utils-map 0.0.1 → 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 +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +23 -11
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +14 -14
- package/lib/array.js +6 -6
- package/lib/assign.js +5 -4
- package/lib/main.js +3 -2
- package/lib/ndarray.js +6 -6
- package/package.json +34 -32
- package/docs/repl.txt +0 -106
- package/docs/types/test.ts +0 -270
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-
|
|
1
|
+
Copyright (c) 2016-2023 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ 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
|
# map
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -231,7 +242,7 @@ The applied function is provided the same arguments as with [`map`](#fcn-map).
|
|
|
231
242
|
// returns 20.0
|
|
232
243
|
```
|
|
233
244
|
|
|
234
|
-
- When applying a function to [`ndarray`][@stdlib/ndarray/ctor]-like objects, performance will be best for [`ndarray`][@stdlib/ndarray/ctor]-like objects which are single-segment contiguous. For non-contiguous arrays, see [`@stdlib/ndarray
|
|
245
|
+
- When applying a function to [`ndarray`][@stdlib/ndarray/ctor]-like objects, performance will be best for [`ndarray`][@stdlib/ndarray/ctor]-like objects which are single-segment contiguous. For non-contiguous arrays, see [`@stdlib/ndarray-base/unary`][@stdlib/ndarray/base/unary].
|
|
235
246
|
|
|
236
247
|
- Both [`map`](#fcn-map) and [`map.assign`](#method-map-assign) do **not** skip `undefined` elements.
|
|
237
248
|
|
|
@@ -325,7 +336,7 @@ See [LICENSE][stdlib-license].
|
|
|
325
336
|
|
|
326
337
|
## Copyright
|
|
327
338
|
|
|
328
|
-
Copyright © 2016-
|
|
339
|
+
Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
329
340
|
|
|
330
341
|
</section>
|
|
331
342
|
|
|
@@ -338,8 +349,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
338
349
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/utils-map.svg
|
|
339
350
|
[npm-url]: https://npmjs.org/package/@stdlib/utils-map
|
|
340
351
|
|
|
341
|
-
[test-image]: https://github.com/stdlib-js/utils-map/actions/workflows/test.yml/badge.svg
|
|
342
|
-
[test-url]: https://github.com/stdlib-js/utils-map/actions/workflows/test.yml
|
|
352
|
+
[test-image]: https://github.com/stdlib-js/utils-map/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
353
|
+
[test-url]: https://github.com/stdlib-js/utils-map/actions/workflows/test.yml?query=branch:v0.1.0
|
|
343
354
|
|
|
344
355
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-map/main.svg
|
|
345
356
|
[coverage-url]: https://codecov.io/github/stdlib-js/utils-map?branch=main
|
|
@@ -351,19 +362,20 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
351
362
|
|
|
352
363
|
-->
|
|
353
364
|
|
|
365
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
366
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
367
|
+
|
|
368
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
369
|
+
|
|
370
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
371
|
+
|
|
354
372
|
[umd]: https://github.com/umdjs/umd
|
|
355
373
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
356
374
|
|
|
357
375
|
[deno-url]: https://github.com/stdlib-js/utils-map/tree/deno
|
|
358
376
|
[umd-url]: https://github.com/stdlib-js/utils-map/tree/umd
|
|
359
377
|
[esm-url]: https://github.com/stdlib-js/utils-map/tree/esm
|
|
360
|
-
|
|
361
|
-
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
362
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
363
|
-
|
|
364
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
365
|
-
|
|
366
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
378
|
+
[branches-url]: https://github.com/stdlib-js/utils-map/blob/main/branches.md
|
|
367
379
|
|
|
368
380
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/utils-map/main/LICENSE
|
|
369
381
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var d=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var b=d(function(sr,O){
|
|
2
|
+
var T=require('@stdlib/ndarray-base-vind2bind/dist'),V="throw";function J(r,e,i,a){var t,n,v,o,s,y,c,m,f,w,k,j,h,p,E,F,u;if(s=r.length,f=r.shape,w=e.shape,t=r.data,n=e.data,k=r.strides,j=e.strides,h=r.offset,p=e.offset,v=r.order,o=e.order,y=r.accessors[0],c=e.accessors[1],m=r.ref,f.length===0){c(n,p,i.call(a,y(t,h),0,m));return}for(u=0;u<s;u++)E=T(f,k,h,v,u,V),F=T(w,j,p,o,u,V),c(n,F,i.call(a,y(t,E),u,m))}O.exports=J
|
|
3
|
+
});var q=d(function(ur,x){
|
|
4
|
+
function K(r,e,i,a){var t,n,v,o,s;for(t=r.data,n=e.data,v=r.accessors[0],o=e.accessors[1],s=0;s<t.length;s++)o(n,s,i.call(a,v(t,s),s,t))}x.exports=K
|
|
5
|
+
});var C=d(function(vr,z){
|
|
6
|
+
var N=require('@stdlib/assert-is-array-like-object/dist'),P=require('@stdlib/assert-is-ndarray-like/dist'),Q=require('@stdlib/assert-is-function/dist'),U=require('@stdlib/array-base-zeros/dist'),L=require('@stdlib/ndarray-base-ndarraylike2object/dist'),I=require('@stdlib/array-base-arraylike2object/dist'),W=require('@stdlib/ndarray-zeros/dist'),R=require('@stdlib/error-tools-fmtprodmsg/dist'),X=b(),Y=q();function Z(r,e,i){var a;if(!Q(e))throw new TypeError(R('1VT2H',e));if(P(r))return r=L(r),a=W(r.shape,{dtype:"generic",order:r.order}),X(r,L(a),e,i),a;if(N(r))return a=U(r.length),Y(I(r),I(a),e,i),a;throw new TypeError(R('1VTBH',r))}z.exports=Z
|
|
7
|
+
});var G=d(function(or,B){
|
|
8
|
+
var D=require('@stdlib/assert-is-array-like-object/dist'),g=require('@stdlib/assert-is-ndarray-like/dist'),_=require('@stdlib/assert-is-function/dist'),M=require('@stdlib/ndarray-base-ndarraylike2object/dist'),S=require('@stdlib/array-base-arraylike2object/dist'),$=require('@stdlib/ndarray-base-maybe-broadcast-array/dist'),A=require('@stdlib/ndarray-base-assert-is-read-only/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),rr=b(),er=q();function ar(r,e,i,a){var t,n;if(!_(i))throw new TypeError(l('1VT3N',i));if(g(r)){if(!g(e))throw new TypeError(l('1VTBF',e));if(A(e))throw new Error(format('1VT1g'));return e=M(e),n=e.shape,t=M($(r,n)),t.ref=r,r=t,rr(r,e,i,a),e.ref}if(D(r)){if(!D(e)||g(e))throw new TypeError(l('1VTBG',e));if(r.length!==e.length)throw new RangeError(format('1VT1h'));return er(S(r),S(e),i,a),e}throw new TypeError(l('1VTBH',r))}B.exports=ar
|
|
9
|
+
});var ir=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),H=C(),tr=G();ir(H,"assign",tr);module.exports=H;
|
|
10
|
+
/** @license Apache-2.0 */
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/ndarray.js", "../lib/array.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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 vind2bind = require( '@stdlib/ndarray-base-vind2bind' );\n\n\n// VARIABLES //\n\nvar MODE = 'throw';\n\n\n// MAIN //\n\n/**\n* Applies a function to each element in an ndarray and assigns the result to an element in an output ndarray.\n*\n* @private\n* @param {Object} x - object containing input ndarray meta data\n* @param {string} x.ref - reference to original input ndarray-like object\n* @param {string} x.dtype - data type\n* @param {Collection} x.data - data buffer\n* @param {NonNegativeInteger} x.length - number of elements\n* @param {NonNegativeIntegerArray} x.shape - dimensions\n* @param {IntegerArray} x.strides - stride lengths\n* @param {NonNegativeInteger} x.offset - index offset\n* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style)\n* @param {Array<Function>} x.accessors - accessors for accessing data buffer elements\n* @param {Object} y - object containing output ndarray meta data\n* @param {string} y.dtype - data type\n* @param {Collection} y.data - data buffer\n* @param {NonNegativeInteger} y.length - number of elements\n* @param {NonNegativeIntegerArray} y.shape - dimensions\n* @param {IntegerArray} y.strides - stride lengths\n* @param {NonNegativeInteger} y.offset - index offset\n* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)\n* @param {Array<Function>} y.accessors - accessors for accessing data buffer elements\n* @param {Function} fcn - function to apply\n* @param {*} thisArg - function execution context\n* @returns {void}\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var Complex64 = require( '@stdlib/complex-float32' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n*\n* function scale( z ) {\n* return new Complex64( realf(z)*10.0, imagf(z)*10.0 );\n* }\n*\n* // Create data buffers:\n* var xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var ybuf = new Complex64Array( 4 );\n*\n* // Define the shape of the input and output arrays:\n* var shape = [ 2, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 2, 1 ];\n* var sy = [ 2, 1 ];\n*\n* // Define the index offsets:\n* var ox = 0;\n* var oy = 0;\n*\n* // Define getters and setters:\n* function getter( buf, idx ) {\n* return buf.get( idx );\n* }\n*\n* function setter( buf, idx, value ) {\n* buf.set( value, idx );\n* }\n*\n* // Create the input and output ndarray-like objects:\n* var x = {\n* 'ref': null,\n* 'dtype': 'complex64',\n* 'data': xbuf,\n* 'length': 4,\n* 'shape': shape,\n* 'strides': sx,\n* 'offset': ox,\n* 'order': 'row-major',\n* 'accessors': [ getter, setter ]\n* };\n* x.ref = x;\n*\n* var y = {\n* 'ref': null,\n* 'dtype': 'complex64',\n* 'data': ybuf,\n* 'length': 4,\n* 'shape': shape,\n* 'strides': sy,\n* 'offset': oy,\n* 'order': 'row-major',\n* 'accessors': [ getter, setter ]\n* };\n*\n* // Apply the unary function:\n* map( x, y, naryFunction( scale, 1 ) );\n*\n* var v = y.data.get( 0 );\n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 20.0\n*/\nfunction map( x, y, fcn, thisArg ) {\n\tvar xbuf;\n\tvar ybuf;\n\tvar ordx;\n\tvar ordy;\n\tvar len;\n\tvar get;\n\tvar set;\n\tvar ref;\n\tvar shx;\n\tvar shy;\n\tvar sx;\n\tvar sy;\n\tvar ox;\n\tvar oy;\n\tvar ix;\n\tvar iy;\n\tvar i;\n\n\t// Cache the total number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Cache the input array shape:\n\tshx = x.shape;\n\tshy = y.shape;\n\n\t// Cache references to the input and output ndarray data buffers:\n\txbuf = x.data;\n\tybuf = y.data;\n\n\t// Cache references to the respective stride arrays:\n\tsx = x.strides;\n\tsy = y.strides;\n\n\t// Cache the indices of the first indexed elements in the respective ndarrays:\n\tox = x.offset;\n\toy = y.offset;\n\n\t// Cache the respective array orders:\n\tordx = x.order;\n\tordy = y.order;\n\n\t// Cache accessors:\n\tget = x.accessors[ 0 ];\n\tset = y.accessors[ 1 ];\n\n\t// Cache the reference to the original input array:\n\tref = x.ref;\n\n\t// Check for a zero-dimensional array...\n\tif ( shx.length === 0 ) {\n\t\tset( ybuf, oy, fcn.call( thisArg, get( xbuf, ox ), 0, ref ) );\n\t\treturn;\n\t}\n\t// Iterate over each element based on the linear **view** index, regardless as to how the data is stored in memory (note: this has negative performance implications for non-contiguous ndarrays due to a lack of data locality)...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tix = vind2bind( shx, sx, ox, ordx, i, MODE );\n\t\tiy = vind2bind( shy, sy, oy, ordy, i, MODE );\n\t\tset( ybuf, iy, fcn.call( thisArg, get( xbuf, ix ), i, ref ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = map;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to each element in an array and assigns the result to an element in an output array.\n*\n* @private\n* @param {Object} x - object containing input array data\n* @param {ArrayLikeObject} x.data - input array data\n* @param {Array<Function>} x.accessors - input array accessors\n* @param {Object} y - object containing output array data\n* @param {ArrayLikeObject} y.data - output array data\n* @param {Array<Function>} y.accessors - output array accessors\n* @param {Function} fcn - function to apply\n* @param {*} thisArg - function execution context\n* @returns {void}\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n*\n* // Define getters and setters:\n* function getter( buf, idx ) {\n* return buf[ idx ];\n* }\n*\n* function setter( buf, idx, value ) {\n* buf[ idx ] = value;\n* }\n*\n* // Create the input and output array objects:\n* var x = {\n* 'data': [ -1, -2, -3, -4, -5, -6 ],\n* 'accessors': [ getter, setter ]\n* };\n* var y = {\n* 'data': [ 0, 0, 0, 0, 0, 0 ],\n* 'accessors': [ getter, setter ]\n* };\n*\n* map( x, y, naryFunction( abs, 1 ) );\n*\n* var data = y.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nfunction map( x, y, fcn, thisArg ) {\n\tvar xbuf;\n\tvar ybuf;\n\tvar get;\n\tvar set;\n\tvar i;\n\n\t// Cache references to the input and output data:\n\txbuf = x.data;\n\tybuf = y.data;\n\n\t// Cache accessors:\n\tget = x.accessors[ 0 ];\n\tset = y.accessors[ 1 ];\n\n\t// Iterate over each element...\n\tfor ( i = 0; i < xbuf.length; i++ ) {\n\t\tset( ybuf, i, fcn.call( thisArg, get( xbuf, i ), i, xbuf ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = map;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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 isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar ndzeros = require( '@stdlib/ndarray-zeros' );\nvar format = require( '@stdlib/string-format' );\nvar ndarrayFcn = require( './ndarray.js' );\nvar arrayFcn = require( './array.js' );\n\n\n// MAIN //\n\n/**\n* Applies a function to each element in an array and assigns the result to an element in a new array.\n*\n* ## Notes\n*\n* - The applied function is provided the following arguments:\n*\n* - **value**: array element.\n* - **index**: element index.\n* - **arr**: input array.\n*\n* @param {(ArrayLikeObject|ndarray)} arr - input array\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @throws {TypeError} first argument must be an array-like object or an ndarray\n* @throws {TypeError} second argument must be a function\n* @returns {(Array|ndarray)} output array\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n*\n* var arr = [ -1, -2, -3, -4, -5, -6 ];\n*\n* var out = map( arr, naryFunction( abs, 1 ) );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var opts = {\n* 'dtype': 'generic'\n* };\n* var arr = array( [ [ -1, -2, -3 ], [ -4, -5, -6 ] ], opts );\n*\n* var out = map( arr, naryFunction( abs, 1 ) );\n* // returns <ndarray>\n*\n* var data = out.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nfunction map( arr, fcn, thisArg ) {\n\tvar out;\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tif ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like\n\t\tarr = ndarraylike2object( arr );\n\t\tout = ndzeros( arr.shape, {\n\t\t\t'dtype': 'generic',\n\t\t\t'order': arr.order\n\t\t});\n\t\tndarrayFcn( arr, ndarraylike2object( out ), fcn, thisArg );\n\t\treturn out;\n\t}\n\tif ( isArrayLikeObject( arr ) ) {\n\t\tout = zeros( arr.length );\n\t\tarrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = map;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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 isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar broadcast = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' );\nvar format = require( '@stdlib/string-format' );\nvar ndarrayFcn = require( './ndarray.js' );\nvar arrayFcn = require( './array.js' );\n\n\n// MAIN //\n\n/**\n* Applies a function to each element in an array and assigns the result to an element in an output array.\n*\n* ## Notes\n*\n* - The applied function is provided the following arguments:\n*\n* - **value**: array element.\n* - **index**: element index.\n* - **arr**: input array.\n*\n* @param {(ArrayLikeObject|ndarray)} arr - input array\n* @param {(ArrayLikeObject|ndarray)} out - output array\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @throws {TypeError} first argument must be an array-like object or an ndarray\n* @throws {TypeError} second argument must be an array-like object or an ndarray\n* @throws {TypeError} third argument must be a function\n* @throws {TypeError} input and output arrays must be either both array-like objects or both ndarrays\n* @throws {RangeError} input and output arrays must have the same length\n* @throws {Error} input and output ndarrays must be broadcast compatible\n* @throws {Error} cannot write to a read-only ndarray\n* @returns {(ArrayLikeObject|ndarray)} output array\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n*\n* var arr = [ -1, -2, -3, -4, -5, -6 ];\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* map( arr, out, naryFunction( abs, 1 ) );\n*\n* console.log( out );\n* // => [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var opts = {\n* 'dtype': 'generic',\n* 'shape': [ 2, 3 ]\n* };\n* var arr = array( [ [ -1, -2, -3 ], [ -4, -5, -6 ] ], opts );\n* var out = array( opts );\n*\n* map( arr, out, naryFunction( abs, 1 ) );\n*\n* var data = out.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nfunction map( arr, out, fcn, thisArg ) {\n\tvar tmp;\n\tvar sh;\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tif ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like\n\t\tif ( !isndarrayLike( out ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `%s`.', out ) );\n\t\t}\n\t\tif ( isReadOnly( out ) ) {\n\t\t\tthrow new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' );\n\t\t}\n\t\tout = ndarraylike2object( out );\n\t\tsh = out.shape;\n\n\t\ttmp = ndarraylike2object( broadcast( arr, sh ) );\n\t\ttmp.ref = arr;\n\t\tarr = tmp;\n\n\t\tndarrayFcn( arr, out, fcn, thisArg );\n\t\treturn out.ref;\n\t}\n\tif ( isArrayLikeObject( arr ) ) {\n\t\tif ( !isArrayLikeObject( out ) || isndarrayLike( out ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `%s`.', out ) );\n\t\t}\n\t\tif ( arr.length !== out.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Input and output arrays must have the same length.' );\n\t\t}\n\t\tarrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = map;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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* Apply a function to each element in an array and assign the result to an element in an output array.\n*\n* @module @stdlib/utils-map\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n* var map = require( '@stdlib/utils-map' );\n*\n* var arr = [ -1, -2, -3, -4, -5, -6 ];\n*\n* var out = map( arr, naryFunction( abs, 1 ) );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n* var array = require( '@stdlib/ndarray-array' );\n* var map = require( '@stdlib/utils-map' );\n*\n* var opts = {\n* 'dtype': 'generic'\n* };\n* var arr = array( [ [ -1, -2, -3 ], [ -4, -5, -6 ] ], opts );\n*\n* var out = map( arr, naryFunction( abs, 1 ) );\n* // returns <ndarray>\n*\n* var data = out.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n* var map = require( '@stdlib/utils-map' );\n*\n* var arr = [ -1, -2, -3, -4, -5, -6 ];\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* map.assign( arr, out, naryFunction( abs, 1 ) );\n*\n* console.log( out );\n* // => [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var naryFunction = require( '@stdlib/utils-nary-function' );\n* var abs = require( '@stdlib/math-base-special-abs' );\n* var array = require( '@stdlib/ndarray-array' );\n* var map = require( '@stdlib/utils-map' );\n*\n* var opts = {\n* 'dtype': 'generic',\n* 'shape': [ 2, 3 ]\n* };\n* var arr = array( [ [ -1, -2, -3 ], [ -4, -5, -6 ] ], opts );\n* var out = array( opts );\n*\n* map.assign( arr, out, naryFunction( abs, 1 ) );\n*\n* var data = out.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,gCAAiC,EAKtDC,EAAO,QAwGX,SAASC,EAAKC,EAAGC,EAAGC,EAAKC,EAAU,CAClC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAiCJ,GA9BAZ,EAAMR,EAAE,OAGRY,EAAMZ,EAAE,MACRa,EAAMZ,EAAE,MAGRG,EAAOJ,EAAE,KACTK,EAAOJ,EAAE,KAGTa,EAAKd,EAAE,QACPe,EAAKd,EAAE,QAGPe,EAAKhB,EAAE,OACPiB,EAAKhB,EAAE,OAGPK,EAAON,EAAE,MACTO,EAAON,EAAE,MAGTQ,EAAMT,EAAE,UAAW,CAAE,EACrBU,EAAMT,EAAE,UAAW,CAAE,EAGrBU,EAAMX,EAAE,IAGHY,EAAI,SAAW,EAAI,CACvBF,EAAKL,EAAMY,EAAIf,EAAI,KAAMC,EAASM,EAAKL,EAAMY,CAAG,EAAG,EAAGL,CAAI,CAAE,EAC5D,MACD,CAEA,IAAMS,EAAI,EAAGA,EAAIZ,EAAKY,IACrBF,EAAKrB,EAAWe,EAAKE,EAAIE,EAAIV,EAAMc,EAAGtB,CAAK,EAC3CqB,EAAKtB,EAAWgB,EAAKE,EAAIE,EAAIV,EAAMa,EAAGtB,CAAK,EAC3CY,EAAKL,EAAMc,EAAIjB,EAAI,KAAMC,EAASM,EAAKL,EAAMc,CAAG,EAAGE,EAAGT,CAAI,CAAE,CAE9D,CAKAf,EAAO,QAAUG,ICpMjB,IAAAsB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAgEA,SAASC,EAAKC,EAAGC,EAAGC,EAAKC,EAAU,CAClC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAWJ,IARAJ,EAAOJ,EAAE,KACTK,EAAOJ,EAAE,KAGTK,EAAMN,EAAE,UAAW,CAAE,EACrBO,EAAMN,EAAE,UAAW,CAAE,EAGfO,EAAI,EAAGA,EAAIJ,EAAK,OAAQI,IAC7BD,EAAKF,EAAMG,EAAGN,EAAI,KAAMC,EAASG,EAAKF,EAAMI,CAAE,EAAGA,EAAGJ,CAAK,CAAE,CAE7D,CAKAN,EAAO,QAAUC,ICxFjB,IAAAU,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,4BAA6B,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAqB,QAAS,yCAA0C,EACxEC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,QAAS,uBAAwB,EAC3CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAa,IACbC,EAAW,IAgDf,SAASC,EAAKC,EAAKC,EAAKC,EAAU,CACjC,IAAIC,EACJ,GAAK,CAACZ,EAAYU,CAAI,EACrB,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAI,CAAE,EAE1G,GAAKX,EAAeU,CAAI,EACvB,OAAAA,EAAMP,EAAoBO,CAAI,EAC9BG,EAAMR,EAASK,EAAI,MAAO,CACzB,MAAS,UACT,MAASA,EAAI,KACd,CAAC,EACDH,EAAYG,EAAKP,EAAoBU,CAAI,EAAGF,EAAKC,CAAQ,EAClDC,EAER,GAAKd,EAAmBW,CAAI,EAC3B,OAAAG,EAAMX,EAAOQ,EAAI,MAAO,EACxBF,EAAUJ,EAAkBM,CAAI,EAAGN,EAAkBS,CAAI,EAAGF,EAAKC,CAAQ,EAClEC,EAER,MAAM,IAAI,UAAWP,EAAQ,4FAA6FI,CAAI,CAAE,CACjI,CAKAZ,EAAO,QAAUW,ICxGjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,qCAAsC,EACnEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,4BAA6B,EACnDC,EAAqB,QAAS,yCAA0C,EACxEC,EAAmB,QAAS,qCAAsC,EAClEC,EAAY,QAAS,4CAA6C,EAClEC,EAAa,QAAS,0CAA2C,EACjEC,EAAS,QAAS,uBAAwB,EAC1CC,GAAa,IACbC,GAAW,IA0Df,SAASC,GAAKC,EAAKC,EAAKC,EAAKC,EAAU,CACtC,IAAIC,EACAC,EACJ,GAAK,CAACd,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWN,EAAQ,oEAAqEM,CAAI,CAAE,EAEzG,GAAKZ,EAAeU,CAAI,EAAI,CAC3B,GAAK,CAACV,EAAeW,CAAI,EACxB,MAAM,IAAI,UAAWL,EAAQ,6GAA8GK,CAAI,CAAE,EAElJ,GAAKN,EAAYM,CAAI,EACpB,MAAM,IAAI,MAAO,6FAA8F,EAEhH,OAAAA,EAAMT,EAAoBS,CAAI,EAC9BI,EAAKJ,EAAI,MAETG,EAAMZ,EAAoBE,EAAWM,EAAKK,CAAG,CAAE,EAC/CD,EAAI,IAAMJ,EACVA,EAAMI,EAENP,GAAYG,EAAKC,EAAKC,EAAKC,CAAQ,EAC5BF,EAAI,GACZ,CACA,GAAKZ,EAAmBW,CAAI,EAAI,CAC/B,GAAK,CAACX,EAAmBY,CAAI,GAAKX,EAAeW,CAAI,EACpD,MAAM,IAAI,UAAWL,EAAQ,iIAAkIK,CAAI,CAAE,EAEtK,GAAKD,EAAI,SAAWC,EAAI,OACvB,MAAM,IAAI,WAAY,uEAAwE,EAE/F,OAAAH,GAAUL,EAAkBO,CAAI,EAAGP,EAAkBQ,CAAI,EAAGC,EAAKC,CAAQ,EAClEF,CACR,CACA,MAAM,IAAI,UAAWL,EAAQ,4FAA6FI,CAAI,CAAE,CACjI,CAKAZ,EAAO,QAAUW,KC1CjB,IAAIO,GAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAS,IAKbF,GAAaC,EAAM,SAAUC,EAAO,EAKpC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_ndarray", "__commonJSMin", "exports", "module", "vind2bind", "MODE", "map", "x", "y", "fcn", "thisArg", "xbuf", "ybuf", "ordx", "ordy", "len", "get", "set", "ref", "shx", "shy", "sx", "sy", "ox", "oy", "ix", "iy", "i", "require_array", "__commonJSMin", "exports", "module", "map", "x", "y", "fcn", "thisArg", "xbuf", "ybuf", "get", "set", "i", "require_main", "__commonJSMin", "exports", "module", "isArrayLikeObject", "isndarrayLike", "isFunction", "zeros", "ndarraylike2object", "arraylike2object", "ndzeros", "format", "ndarrayFcn", "arrayFcn", "map", "arr", "fcn", "thisArg", "out", "require_assign", "__commonJSMin", "exports", "module", "isArrayLikeObject", "isndarrayLike", "isFunction", "ndarraylike2object", "arraylike2object", "broadcast", "isReadOnly", "format", "ndarrayFcn", "arrayFcn", "map", "arr", "out", "fcn", "thisArg", "tmp", "sh", "setReadOnly", "main", "assign"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
23
|
-
import { Collection } from '@stdlib/types/
|
|
24
|
-
import {
|
|
23
|
+
import { Collection } from '@stdlib/types/array';
|
|
24
|
+
import { typedndarray } from '@stdlib/types/ndarray';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Callback invoked for each array element.
|
|
28
28
|
*
|
|
29
29
|
* @returns result
|
|
30
30
|
*/
|
|
31
|
-
type Nullary = () =>
|
|
31
|
+
type Nullary<U, V> = ( this: V ) => U;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Callback invoked for each array element.
|
|
@@ -36,7 +36,7 @@ type Nullary = () => any;
|
|
|
36
36
|
* @param value - array element
|
|
37
37
|
* @returns result
|
|
38
38
|
*/
|
|
39
|
-
type Unary = ( value:
|
|
39
|
+
type Unary<T, U, V> = ( this: V, value: T ) => U;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Callback invoked for each array element.
|
|
@@ -45,7 +45,7 @@ type Unary = ( value: any ) => any;
|
|
|
45
45
|
* @param index - element index
|
|
46
46
|
* @returns result
|
|
47
47
|
*/
|
|
48
|
-
type Binary = ( value:
|
|
48
|
+
type Binary<T, U, V> = ( this: V, value: T, index: number ) => U;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Callback invoked for each array element.
|
|
@@ -55,7 +55,7 @@ type Binary = ( value: any, index: number ) => any;
|
|
|
55
55
|
* @param arr - array
|
|
56
56
|
* @returns result
|
|
57
57
|
*/
|
|
58
|
-
type Ternary = ( value:
|
|
58
|
+
type Ternary<T, U, V> = ( this: V, value: T, index: number, arr: typedndarray<T> ) => U;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Callback invoked for each array element.
|
|
@@ -65,7 +65,7 @@ type Ternary = ( value: any, index: number, arr: ndarray ) => any;
|
|
|
65
65
|
* @param arr - array
|
|
66
66
|
* @returns result
|
|
67
67
|
*/
|
|
68
|
-
type ArrayTernary = ( value:
|
|
68
|
+
type ArrayTernary<T, U, V> = ( this: V, value: T, index: number, arr: Collection<T> ) => U;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Callback invoked for each array element.
|
|
@@ -75,7 +75,7 @@ type ArrayTernary = ( value: any, index: number, arr: Collection ) => any;
|
|
|
75
75
|
* @param arr - array
|
|
76
76
|
* @returns result
|
|
77
77
|
*/
|
|
78
|
-
type Callback = Nullary | Unary | Binary | Ternary
|
|
78
|
+
type Callback<T, U, V> = Nullary<U, V> | Unary<T, U, V> | Binary<T, U, V> | Ternary<T, U, V>;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Callback invoked for each array element.
|
|
@@ -85,7 +85,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
|
|
|
85
85
|
* @param arr - array
|
|
86
86
|
* @returns result
|
|
87
87
|
*/
|
|
88
|
-
type ArrayCallback = Nullary | Unary | Binary | ArrayTernary
|
|
88
|
+
type ArrayCallback<T, U, V> = Nullary<U, V> | Unary<T, U, V> | Binary<T, U, V> | ArrayTernary<T, U, V>;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Interface describing the main export.
|
|
@@ -125,7 +125,7 @@ interface Routine {
|
|
|
125
125
|
* var data = out.data;
|
|
126
126
|
* // returns [ 1, 2, 3, 4, 5, 6 ]
|
|
127
127
|
*/
|
|
128
|
-
( arr:
|
|
128
|
+
<T = unknown, U = unknown, V = unknown>( arr: typedndarray<T>, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): typedndarray<U>;
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Applies a function to each element in an array and assigns the result to an element in a new array.
|
|
@@ -152,7 +152,7 @@ interface Routine {
|
|
|
152
152
|
* var out = map( arr, naryFunction( abs, 1 ) );
|
|
153
153
|
* // returns [ 1, 2, 3, 4, 5, 6 ]
|
|
154
154
|
*/
|
|
155
|
-
( arr: Collection
|
|
155
|
+
<T = unknown, U = unknown, V = unknown>( arr: Collection<T>, fcn: ArrayCallback<T, U, V>, thisArg?: ThisParameterType<ArrayCallback<T, U, V>> ): Array<U>;
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Applies a function to each element in an array and assigns the result to an element in an output array.
|
|
@@ -188,7 +188,7 @@ interface Routine {
|
|
|
188
188
|
* var data = out.data;
|
|
189
189
|
* // returns [ 1, 2, 3, 4, 5, 6 ]
|
|
190
190
|
*/
|
|
191
|
-
assign( arr:
|
|
191
|
+
assign<T = unknown, U = unknown, V = unknown>( arr: typedndarray<T>, out: typedndarray<U>, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): typedndarray<U>;
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Applies a function to each element in an array and assigns the result to an element in an output array.
|
|
@@ -219,7 +219,7 @@ interface Routine {
|
|
|
219
219
|
* console.log( out );
|
|
220
220
|
* // => [ 1, 2, 3, 4, 5, 6 ]
|
|
221
221
|
*/
|
|
222
|
-
assign( arr: Collection
|
|
222
|
+
assign<T = unknown, U = unknown, V = unknown>( arr: Collection<T>, out: Collection<U>, fcn: ArrayCallback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): Collection<U>;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
package/lib/array.js
CHANGED
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
* @private
|
|
27
27
|
* @param {Object} x - object containing input array data
|
|
28
28
|
* @param {ArrayLikeObject} x.data - input array data
|
|
29
|
-
* @param {Function} x.
|
|
29
|
+
* @param {Array<Function>} x.accessors - input array accessors
|
|
30
30
|
* @param {Object} y - object containing output array data
|
|
31
31
|
* @param {ArrayLikeObject} y.data - output array data
|
|
32
|
-
* @param {Function} y.
|
|
32
|
+
* @param {Array<Function>} y.accessors - output array accessors
|
|
33
33
|
* @param {Function} fcn - function to apply
|
|
34
34
|
* @param {*} thisArg - function execution context
|
|
35
35
|
* @returns {void}
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
* // Create the input and output array objects:
|
|
51
51
|
* var x = {
|
|
52
52
|
* 'data': [ -1, -2, -3, -4, -5, -6 ],
|
|
53
|
-
* '
|
|
53
|
+
* 'accessors': [ getter, setter ]
|
|
54
54
|
* };
|
|
55
55
|
* var y = {
|
|
56
56
|
* 'data': [ 0, 0, 0, 0, 0, 0 ],
|
|
57
|
-
* '
|
|
57
|
+
* 'accessors': [ getter, setter ]
|
|
58
58
|
* };
|
|
59
59
|
*
|
|
60
60
|
* map( x, y, naryFunction( abs, 1 ) );
|
|
@@ -74,8 +74,8 @@ function map( x, y, fcn, thisArg ) {
|
|
|
74
74
|
ybuf = y.data;
|
|
75
75
|
|
|
76
76
|
// Cache accessors:
|
|
77
|
-
get = x.
|
|
78
|
-
set = y.
|
|
77
|
+
get = x.accessors[ 0 ];
|
|
78
|
+
set = y.accessors[ 1 ];
|
|
79
79
|
|
|
80
80
|
// Iterate over each element...
|
|
81
81
|
for ( i = 0; i < xbuf.length; i++ ) {
|
package/lib/assign.js
CHANGED
|
@@ -27,6 +27,7 @@ var ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );
|
|
|
27
27
|
var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
|
|
28
28
|
var broadcast = require( '@stdlib/ndarray-base-maybe-broadcast-array' );
|
|
29
29
|
var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' );
|
|
30
|
+
var format = require( '@stdlib/string-format' );
|
|
30
31
|
var ndarrayFcn = require( './ndarray.js' );
|
|
31
32
|
var arrayFcn = require( './array.js' );
|
|
32
33
|
|
|
@@ -90,11 +91,11 @@ function map( arr, out, fcn, thisArg ) {
|
|
|
90
91
|
var tmp;
|
|
91
92
|
var sh;
|
|
92
93
|
if ( !isFunction( fcn ) ) {
|
|
93
|
-
throw new TypeError( 'invalid argument. Third argument must be a function. Value:
|
|
94
|
+
throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) );
|
|
94
95
|
}
|
|
95
96
|
if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like
|
|
96
97
|
if ( !isndarrayLike( out ) ) {
|
|
97
|
-
throw new TypeError( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value:
|
|
98
|
+
throw new TypeError( format( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `%s`.', out ) );
|
|
98
99
|
}
|
|
99
100
|
if ( isReadOnly( out ) ) {
|
|
100
101
|
throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' );
|
|
@@ -111,7 +112,7 @@ function map( arr, out, fcn, thisArg ) {
|
|
|
111
112
|
}
|
|
112
113
|
if ( isArrayLikeObject( arr ) ) {
|
|
113
114
|
if ( !isArrayLikeObject( out ) || isndarrayLike( out ) ) {
|
|
114
|
-
throw new TypeError( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value:
|
|
115
|
+
throw new TypeError( format( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `%s`.', out ) );
|
|
115
116
|
}
|
|
116
117
|
if ( arr.length !== out.length ) {
|
|
117
118
|
throw new RangeError( 'invalid arguments. Input and output arrays must have the same length.' );
|
|
@@ -119,7 +120,7 @@ function map( arr, out, fcn, thisArg ) {
|
|
|
119
120
|
arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len
|
|
120
121
|
return out;
|
|
121
122
|
}
|
|
122
|
-
throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value:
|
|
123
|
+
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
|
package/lib/main.js
CHANGED
|
@@ -27,6 +27,7 @@ var zeros = require( '@stdlib/array-base-zeros' );
|
|
|
27
27
|
var ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );
|
|
28
28
|
var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
|
|
29
29
|
var ndzeros = require( '@stdlib/ndarray-zeros' );
|
|
30
|
+
var format = require( '@stdlib/string-format' );
|
|
30
31
|
var ndarrayFcn = require( './ndarray.js' );
|
|
31
32
|
var arrayFcn = require( './array.js' );
|
|
32
33
|
|
|
@@ -79,7 +80,7 @@ var arrayFcn = require( './array.js' );
|
|
|
79
80
|
function map( arr, fcn, thisArg ) {
|
|
80
81
|
var out;
|
|
81
82
|
if ( !isFunction( fcn ) ) {
|
|
82
|
-
throw new TypeError( 'invalid argument. Second argument must be a function. Value:
|
|
83
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );
|
|
83
84
|
}
|
|
84
85
|
if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like
|
|
85
86
|
arr = ndarraylike2object( arr );
|
|
@@ -95,7 +96,7 @@ function map( arr, fcn, thisArg ) {
|
|
|
95
96
|
arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len
|
|
96
97
|
return out;
|
|
97
98
|
}
|
|
98
|
-
throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value:
|
|
99
|
+
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
|
package/lib/ndarray.js
CHANGED
|
@@ -43,7 +43,7 @@ var MODE = 'throw';
|
|
|
43
43
|
* @param {IntegerArray} x.strides - stride lengths
|
|
44
44
|
* @param {NonNegativeInteger} x.offset - index offset
|
|
45
45
|
* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style)
|
|
46
|
-
* @param {Function} x.
|
|
46
|
+
* @param {Array<Function>} x.accessors - accessors for accessing data buffer elements
|
|
47
47
|
* @param {Object} y - object containing output ndarray meta data
|
|
48
48
|
* @param {string} y.dtype - data type
|
|
49
49
|
* @param {Collection} y.data - data buffer
|
|
@@ -52,7 +52,7 @@ var MODE = 'throw';
|
|
|
52
52
|
* @param {IntegerArray} y.strides - stride lengths
|
|
53
53
|
* @param {NonNegativeInteger} y.offset - index offset
|
|
54
54
|
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
|
|
55
|
-
* @param {Function} y.
|
|
55
|
+
* @param {Array<Function>} y.accessors - accessors for accessing data buffer elements
|
|
56
56
|
* @param {Function} fcn - function to apply
|
|
57
57
|
* @param {*} thisArg - function execution context
|
|
58
58
|
* @returns {void}
|
|
@@ -102,7 +102,7 @@ var MODE = 'throw';
|
|
|
102
102
|
* 'strides': sx,
|
|
103
103
|
* 'offset': ox,
|
|
104
104
|
* 'order': 'row-major',
|
|
105
|
-
* '
|
|
105
|
+
* 'accessors': [ getter, setter ]
|
|
106
106
|
* };
|
|
107
107
|
* x.ref = x;
|
|
108
108
|
*
|
|
@@ -115,7 +115,7 @@ var MODE = 'throw';
|
|
|
115
115
|
* 'strides': sy,
|
|
116
116
|
* 'offset': oy,
|
|
117
117
|
* 'order': 'row-major',
|
|
118
|
-
* '
|
|
118
|
+
* 'accessors': [ getter, setter ]
|
|
119
119
|
* };
|
|
120
120
|
*
|
|
121
121
|
* // Apply the unary function:
|
|
@@ -172,8 +172,8 @@ function map( x, y, fcn, thisArg ) {
|
|
|
172
172
|
ordy = y.order;
|
|
173
173
|
|
|
174
174
|
// Cache accessors:
|
|
175
|
-
get = x.
|
|
176
|
-
set = y.
|
|
175
|
+
get = x.accessors[ 0 ];
|
|
176
|
+
set = y.accessors[ 1 ];
|
|
177
177
|
|
|
178
178
|
// Cache the reference to the original input array:
|
|
179
179
|
ref = x.ref;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/utils-map",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Apply a function to each element in an array and assign the result to an element in an output array.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,39 +37,41 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/array-base-arraylike2object": "^0.0
|
|
41
|
-
"@stdlib/array-base-zeros": "^0.0
|
|
42
|
-
"@stdlib/assert-is-array-like-object": "^0.0
|
|
43
|
-
"@stdlib/assert-is-function": "^0.0
|
|
44
|
-
"@stdlib/assert-is-ndarray-like": "^0.0
|
|
45
|
-
"@stdlib/ndarray-base-assert-is-read-only": "^0.0
|
|
46
|
-
"@stdlib/ndarray-base-maybe-broadcast-array": "^0.0
|
|
47
|
-
"@stdlib/ndarray-base-ndarraylike2object": "^0.0
|
|
48
|
-
"@stdlib/ndarray-base-vind2bind": "^0.0
|
|
49
|
-
"@stdlib/ndarray-zeros": "^0.0
|
|
50
|
-
"@stdlib/
|
|
51
|
-
"@stdlib/
|
|
40
|
+
"@stdlib/array-base-arraylike2object": "^0.1.0",
|
|
41
|
+
"@stdlib/array-base-zeros": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-array-like-object": "^0.1.0",
|
|
43
|
+
"@stdlib/assert-is-function": "^0.1.0",
|
|
44
|
+
"@stdlib/assert-is-ndarray-like": "^0.1.0",
|
|
45
|
+
"@stdlib/ndarray-base-assert-is-read-only": "^0.1.0",
|
|
46
|
+
"@stdlib/ndarray-base-maybe-broadcast-array": "^0.1.0",
|
|
47
|
+
"@stdlib/ndarray-base-ndarraylike2object": "^0.1.0",
|
|
48
|
+
"@stdlib/ndarray-base-vind2bind": "^0.1.0",
|
|
49
|
+
"@stdlib/ndarray-zeros": "^0.1.0",
|
|
50
|
+
"@stdlib/string-format": "^0.1.0",
|
|
51
|
+
"@stdlib/types": "^0.1.0",
|
|
52
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
|
|
53
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"@stdlib/array-base-filled": "^0.0
|
|
55
|
-
"@stdlib/array-complex64": "^0.0
|
|
56
|
-
"@stdlib/array-filled-by": "^0.0.
|
|
57
|
-
"@stdlib/array-float64": "^0.0
|
|
58
|
-
"@stdlib/assert-is-array": "^0.0
|
|
59
|
-
"@stdlib/bench": "^0.0
|
|
60
|
-
"@stdlib/complex-float32": "^0.0
|
|
61
|
-
"@stdlib/complex-imagf": "^0.0
|
|
62
|
-
"@stdlib/complex-realf": "^0.0
|
|
63
|
-
"@stdlib/math-base-special-abs": "^0.0
|
|
64
|
-
"@stdlib/math-base-special-abs2": "^0.0
|
|
65
|
-
"@stdlib/math-base-special-pow": "^0.0
|
|
66
|
-
"@stdlib/ndarray-array": "^0.0.
|
|
67
|
-
"@stdlib/ndarray-ctor": "^0.0
|
|
68
|
-
"@stdlib/random-base-discrete-uniform": "^0.0.
|
|
69
|
-
"@stdlib/utils-nary-function": "^0.0
|
|
56
|
+
"@stdlib/array-base-filled": "^0.1.0",
|
|
57
|
+
"@stdlib/array-complex64": "^0.1.0",
|
|
58
|
+
"@stdlib/array-filled-by": "^0.0.2",
|
|
59
|
+
"@stdlib/array-float64": "^0.1.0",
|
|
60
|
+
"@stdlib/assert-is-array": "^0.1.0",
|
|
61
|
+
"@stdlib/bench": "^0.1.0",
|
|
62
|
+
"@stdlib/complex-float32": "^0.1.0",
|
|
63
|
+
"@stdlib/complex-imagf": "^0.1.0",
|
|
64
|
+
"@stdlib/complex-realf": "^0.1.0",
|
|
65
|
+
"@stdlib/math-base-special-abs": "^0.1.0",
|
|
66
|
+
"@stdlib/math-base-special-abs2": "^0.1.0",
|
|
67
|
+
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
68
|
+
"@stdlib/ndarray-array": "^0.0.9",
|
|
69
|
+
"@stdlib/ndarray-ctor": "^0.1.0",
|
|
70
|
+
"@stdlib/random-base-discrete-uniform": "^0.0.6",
|
|
71
|
+
"@stdlib/utils-nary-function": "^0.1.0",
|
|
70
72
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
71
73
|
"istanbul": "^0.4.1",
|
|
72
|
-
"tap-
|
|
74
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
73
75
|
},
|
|
74
76
|
"engines": {
|
|
75
77
|
"node": ">=0.10.0",
|
|
@@ -112,7 +114,7 @@
|
|
|
112
114
|
"fcn"
|
|
113
115
|
],
|
|
114
116
|
"funding": {
|
|
115
|
-
"type": "
|
|
116
|
-
"url": "https://
|
|
117
|
+
"type": "opencollective",
|
|
118
|
+
"url": "https://opencollective.com/stdlib"
|
|
117
119
|
}
|
|
118
120
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( arr, fcn[, thisArg] )
|
|
3
|
-
Applies a function to each element in an array and assigns the result to an
|
|
4
|
-
element in a new array.
|
|
5
|
-
|
|
6
|
-
The applied function is provided the following arguments:
|
|
7
|
-
|
|
8
|
-
- value: array element.
|
|
9
|
-
- index: element index.
|
|
10
|
-
- arr: input array.
|
|
11
|
-
|
|
12
|
-
The returned output array always has a "generic" data type. For example, if
|
|
13
|
-
provided an array-like object, the function returns a generic array. If
|
|
14
|
-
provided an ndarray, the function returns an ndarray having a "generic" data
|
|
15
|
-
type.
|
|
16
|
-
|
|
17
|
-
Parameters
|
|
18
|
-
----------
|
|
19
|
-
arr: ArrayLikeObject|ndarray
|
|
20
|
-
Input array.
|
|
21
|
-
|
|
22
|
-
fcn: Function
|
|
23
|
-
Function to apply.
|
|
24
|
-
|
|
25
|
-
thisArg: any (optional)
|
|
26
|
-
Input function context.
|
|
27
|
-
|
|
28
|
-
Returns
|
|
29
|
-
-------
|
|
30
|
-
out: Array|ndarray
|
|
31
|
-
Output array.
|
|
32
|
-
|
|
33
|
-
Examples
|
|
34
|
-
--------
|
|
35
|
-
// array-like object:
|
|
36
|
-
> var f = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
|
|
37
|
-
> var arr = [ -1, -2, -3, -4, -5, -6 ];
|
|
38
|
-
> var out = {{alias}}( arr, f )
|
|
39
|
-
[ 1, 2, 3, 4, 5, 6 ]
|
|
40
|
-
|
|
41
|
-
// ndarray:
|
|
42
|
-
> arr = {{alias:@stdlib/ndarray/array}}( arr, { 'shape': [ 2, 3 ] } );
|
|
43
|
-
> out = {{alias}}( arr, f );
|
|
44
|
-
> var v = out.get( 1, 1 )
|
|
45
|
-
5
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{{alias}}.assign( arr, out, fcn[, thisArg] )
|
|
49
|
-
Applies a function to each element in an array and assigns the result to an
|
|
50
|
-
element in an output array.
|
|
51
|
-
|
|
52
|
-
The applied function is provided the following arguments:
|
|
53
|
-
|
|
54
|
-
- value: array element.
|
|
55
|
-
- index: element index.
|
|
56
|
-
- arr: input array.
|
|
57
|
-
|
|
58
|
-
Input and output arrays must be either both array-like objects or both
|
|
59
|
-
ndarray-like objects.
|
|
60
|
-
|
|
61
|
-
If input and output arrays are array-like objects, the arrays must have the
|
|
62
|
-
same number of elements.
|
|
63
|
-
|
|
64
|
-
If input and output arrays are both ndarray-like objects, the arrays *must*
|
|
65
|
-
be broadcast compatible.
|
|
66
|
-
|
|
67
|
-
Parameters
|
|
68
|
-
----------
|
|
69
|
-
arr: ArrayLikeObject|ndarray
|
|
70
|
-
Input array.
|
|
71
|
-
|
|
72
|
-
out: ArrayLikeObject|ndarray
|
|
73
|
-
Output array.
|
|
74
|
-
|
|
75
|
-
fcn: Function
|
|
76
|
-
Function to apply.
|
|
77
|
-
|
|
78
|
-
thisArg: any (optional)
|
|
79
|
-
Input function context.
|
|
80
|
-
|
|
81
|
-
Returns
|
|
82
|
-
-------
|
|
83
|
-
out: Array|ndarray
|
|
84
|
-
Output array.
|
|
85
|
-
|
|
86
|
-
Examples
|
|
87
|
-
--------
|
|
88
|
-
// array-like object:
|
|
89
|
-
> var f = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
|
|
90
|
-
> var arr = [ -1, -2, -3, -4, -5, -6 ];
|
|
91
|
-
> var out = [ 0, 0, 0, 0, 0, 0 ];
|
|
92
|
-
> {{alias}}.assign( arr, out, f );
|
|
93
|
-
> out
|
|
94
|
-
[ 1, 2, 3, 4, 5, 6 ]
|
|
95
|
-
|
|
96
|
-
// ndarray:
|
|
97
|
-
> var opts = { 'shape': [ 2, 3 ] };
|
|
98
|
-
> arr = {{alias:@stdlib/ndarray/array}}( arr, opts );
|
|
99
|
-
> out = {{alias:@stdlib/ndarray/array}}( [ 0, 0, 0, 0, 0, 0 ], opts );
|
|
100
|
-
> {{alias}}.assign( arr, out, f );
|
|
101
|
-
> var v = out.get( 1, 1 )
|
|
102
|
-
5
|
|
103
|
-
|
|
104
|
-
See Also
|
|
105
|
-
--------
|
|
106
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,270 +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 array = require( '@stdlib/ndarray-array' );
|
|
20
|
-
import map = require( './index' );
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Callback function.
|
|
24
|
-
*
|
|
25
|
-
* @param v - argument
|
|
26
|
-
* @returns result
|
|
27
|
-
*/
|
|
28
|
-
function clbk( v: any ): any {
|
|
29
|
-
return v;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// TESTS //
|
|
34
|
-
|
|
35
|
-
// The function returns a collection when provided a collection...
|
|
36
|
-
{
|
|
37
|
-
const arr = [ 1, 2, 3, 4, 5, 6 ];
|
|
38
|
-
|
|
39
|
-
map( arr, clbk ); // $ExpectType Collection
|
|
40
|
-
map( arr, clbk, {} ); // $ExpectType Collection
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// The function returns an ndarray when provided an ndarray...
|
|
44
|
-
{
|
|
45
|
-
const arr = array( [ 1, 2, 3, 4, 5, 6 ] );
|
|
46
|
-
|
|
47
|
-
map( arr, clbk ); // $ExpectType ndarray
|
|
48
|
-
map( arr, clbk, {} ); // $ExpectType ndarray
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// The compiler throws an error if the function is provided a first argument other than a collection or ndarray...
|
|
52
|
-
{
|
|
53
|
-
map( 5, clbk ); // $ExpectError
|
|
54
|
-
map( true, clbk ); // $ExpectError
|
|
55
|
-
map( false, clbk ); // $ExpectError
|
|
56
|
-
map( null, clbk, {} ); // $ExpectError
|
|
57
|
-
map( {}, clbk ); // $ExpectError
|
|
58
|
-
|
|
59
|
-
map( 5, clbk, {} ); // $ExpectError
|
|
60
|
-
map( true, clbk, {} ); // $ExpectError
|
|
61
|
-
map( false, clbk, {} ); // $ExpectError
|
|
62
|
-
map( null, clbk, {} ); // $ExpectError
|
|
63
|
-
map( {}, clbk, {} ); // $ExpectError
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// The compiler throws an error if the function is provided a second argument other than a function with a supported signature...
|
|
67
|
-
{
|
|
68
|
-
const arr1 = [ 1, 2, 3, 4, 5, 6 ];
|
|
69
|
-
|
|
70
|
-
map( arr1, '5' ); // $ExpectError
|
|
71
|
-
map( arr1, true ); // $ExpectError
|
|
72
|
-
map( arr1, false ); // $ExpectError
|
|
73
|
-
map( arr1, 123 ); // $ExpectError
|
|
74
|
-
map( arr1, null ); // $ExpectError
|
|
75
|
-
map( arr1, {} ); // $ExpectError
|
|
76
|
-
map( arr1, [] ); // $ExpectError
|
|
77
|
-
|
|
78
|
-
map( arr1, '5', {} ); // $ExpectError
|
|
79
|
-
map( arr1, true, {} ); // $ExpectError
|
|
80
|
-
map( arr1, false, {} ); // $ExpectError
|
|
81
|
-
map( arr1, 123, {} ); // $ExpectError
|
|
82
|
-
map( arr1, null, {} ); // $ExpectError
|
|
83
|
-
map( arr1, {}, {} ); // $ExpectError
|
|
84
|
-
map( arr1, [], {} ); // $ExpectError
|
|
85
|
-
|
|
86
|
-
map( arr1, ( x: number, y: number, z: number ): number => x + y + z ); // $ExpectError
|
|
87
|
-
map( arr1, ( x: number, y: number, z: number ): number => x + y + z, {} ); // $ExpectError
|
|
88
|
-
|
|
89
|
-
const arr2 = array( [ 1, 2, 3, 4, 5, 6 ] );
|
|
90
|
-
|
|
91
|
-
map( arr2, '5' ); // $ExpectError
|
|
92
|
-
map( arr2, true ); // $ExpectError
|
|
93
|
-
map( arr2, false ); // $ExpectError
|
|
94
|
-
map( arr2, 123 ); // $ExpectError
|
|
95
|
-
map( arr2, null ); // $ExpectError
|
|
96
|
-
map( arr2, {} ); // $ExpectError
|
|
97
|
-
map( arr2, [] ); // $ExpectError
|
|
98
|
-
|
|
99
|
-
map( arr2, '5', {} ); // $ExpectError
|
|
100
|
-
map( arr2, true, {} ); // $ExpectError
|
|
101
|
-
map( arr2, false, {} ); // $ExpectError
|
|
102
|
-
map( arr2, 123, {} ); // $ExpectError
|
|
103
|
-
map( arr2, null, {} ); // $ExpectError
|
|
104
|
-
map( arr2, {}, {} ); // $ExpectError
|
|
105
|
-
map( arr2, [], {} ); // $ExpectError
|
|
106
|
-
|
|
107
|
-
map( arr2, ( x: number, y: number, z: number ): number => x + y + z ); // $ExpectError
|
|
108
|
-
map( arr2, ( x: number, y: number, z: number ): number => x + y + z, {} ); // $ExpectError
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
112
|
-
{
|
|
113
|
-
const arr1 = [ 1, 2, 3, 4, 5, 6 ];
|
|
114
|
-
|
|
115
|
-
map(); // $ExpectError
|
|
116
|
-
map( arr1 ); // $ExpectError
|
|
117
|
-
map( arr1, clbk, {}, 4 ); // $ExpectError
|
|
118
|
-
|
|
119
|
-
const arr2 = array( [ 1, 2, 3, 4, 5, 6 ] );
|
|
120
|
-
|
|
121
|
-
map(); // $ExpectError
|
|
122
|
-
map( arr2 ); // $ExpectError
|
|
123
|
-
map( arr2, clbk, {}, 4 ); // $ExpectError
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Attached to the main export is an `assign` method which returns a collection when provided a collection...
|
|
127
|
-
{
|
|
128
|
-
const arr = [ 1, 2, 3, 4, 5, 6 ];
|
|
129
|
-
const out = [ 0, 0, 0, 0, 0, 0 ];
|
|
130
|
-
|
|
131
|
-
map.assign( arr, out, clbk ); // $ExpectType Collection
|
|
132
|
-
map.assign( arr, out, clbk, {} ); // $ExpectType Collection
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// The `assign` method returns an ndarray when provided an ndarray...
|
|
136
|
-
{
|
|
137
|
-
const arr = array( [ 1, 2, 3, 4, 5, 6 ] );
|
|
138
|
-
const out = array( [ 0, 0, 0, 0, 0, 0 ] );
|
|
139
|
-
|
|
140
|
-
map.assign( arr, out, clbk ); // $ExpectType ndarray
|
|
141
|
-
map.assign( arr, out, clbk, {} ); // $ExpectType ndarray
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// The compiler throws an error if the `assign` method is provided a first argument other than a collection or ndarray...
|
|
145
|
-
{
|
|
146
|
-
const out1 = [ 0, 0, 0, 0, 0, 0 ];
|
|
147
|
-
|
|
148
|
-
map.assign( 5, out1, clbk ); // $ExpectError
|
|
149
|
-
map.assign( true, out1, clbk ); // $ExpectError
|
|
150
|
-
map.assign( false, out1, clbk ); // $ExpectError
|
|
151
|
-
map.assign( null, out1, clbk, {} ); // $ExpectError
|
|
152
|
-
map.assign( {}, out1, clbk ); // $ExpectError
|
|
153
|
-
|
|
154
|
-
map.assign( 5, out1, clbk, {} ); // $ExpectError
|
|
155
|
-
map.assign( true, out1, clbk, {} ); // $ExpectError
|
|
156
|
-
map.assign( false, out1, clbk, {} ); // $ExpectError
|
|
157
|
-
map.assign( null, out1, clbk, {} ); // $ExpectError
|
|
158
|
-
map.assign( {}, out1, clbk, {} ); // $ExpectError
|
|
159
|
-
|
|
160
|
-
const out2 = array( [ 0, 0, 0, 0, 0, 0 ] );
|
|
161
|
-
|
|
162
|
-
map.assign( 5, out2, clbk ); // $ExpectError
|
|
163
|
-
map.assign( true, out2, clbk ); // $ExpectError
|
|
164
|
-
map.assign( false, out2, clbk ); // $ExpectError
|
|
165
|
-
map.assign( null, out2, clbk, {} ); // $ExpectError
|
|
166
|
-
map.assign( {}, out2, clbk ); // $ExpectError
|
|
167
|
-
|
|
168
|
-
map.assign( 5, out2, clbk, {} ); // $ExpectError
|
|
169
|
-
map.assign( true, out2, clbk, {} ); // $ExpectError
|
|
170
|
-
map.assign( false, out2, clbk, {} ); // $ExpectError
|
|
171
|
-
map.assign( null, out2, clbk, {} ); // $ExpectError
|
|
172
|
-
map.assign( {}, out2, clbk, {} ); // $ExpectError
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// The compiler throws an error if the `assign` method is provided a second argument other than a collection or ndarray...
|
|
176
|
-
{
|
|
177
|
-
const arr1 = [ 0, 0, 0, 0, 0, 0 ];
|
|
178
|
-
|
|
179
|
-
map.assign( arr1, 5, clbk ); // $ExpectError
|
|
180
|
-
map.assign( arr1, true, clbk ); // $ExpectError
|
|
181
|
-
map.assign( arr1, false, clbk ); // $ExpectError
|
|
182
|
-
map.assign( arr1, null, clbk, {} ); // $ExpectError
|
|
183
|
-
map.assign( arr1, {}, clbk ); // $ExpectError
|
|
184
|
-
|
|
185
|
-
map.assign( arr1, 5, clbk, {} ); // $ExpectError
|
|
186
|
-
map.assign( arr1, true, clbk, {} ); // $ExpectError
|
|
187
|
-
map.assign( arr1, false, clbk, {} ); // $ExpectError
|
|
188
|
-
map.assign( arr1, null, clbk, {} ); // $ExpectError
|
|
189
|
-
map.assign( arr1, {}, clbk, {} ); // $ExpectError
|
|
190
|
-
|
|
191
|
-
const arr2 = array( [ 0, 0, 0, 0, 0, 0 ] );
|
|
192
|
-
|
|
193
|
-
map.assign( arr2, 5, clbk ); // $ExpectError
|
|
194
|
-
map.assign( arr2, true, clbk ); // $ExpectError
|
|
195
|
-
map.assign( arr2, false, clbk ); // $ExpectError
|
|
196
|
-
map.assign( arr2, null, clbk, {} ); // $ExpectError
|
|
197
|
-
map.assign( arr2, {}, clbk ); // $ExpectError
|
|
198
|
-
|
|
199
|
-
map.assign( arr2, 5, clbk, {} ); // $ExpectError
|
|
200
|
-
map.assign( arr2, true, clbk, {} ); // $ExpectError
|
|
201
|
-
map.assign( arr2, false, clbk, {} ); // $ExpectError
|
|
202
|
-
map.assign( arr2, null, clbk, {} ); // $ExpectError
|
|
203
|
-
map.assign( arr2, {}, clbk, {} ); // $ExpectError
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// The compiler throws an error if the `assign` method is provided a third argument other than a function with a supported signature...
|
|
207
|
-
{
|
|
208
|
-
const arr1 = [ 1, 2, 3, 4, 5, 6 ];
|
|
209
|
-
const out1 = [ 0, 0, 0, 0, 0, 0 ];
|
|
210
|
-
|
|
211
|
-
map.assign( arr1, out1, '5' ); // $ExpectError
|
|
212
|
-
map.assign( arr1, out1, true ); // $ExpectError
|
|
213
|
-
map.assign( arr1, out1, false ); // $ExpectError
|
|
214
|
-
map.assign( arr1, out1, 123 ); // $ExpectError
|
|
215
|
-
map.assign( arr1, out1, null ); // $ExpectError
|
|
216
|
-
map.assign( arr1, out1, {} ); // $ExpectError
|
|
217
|
-
map.assign( arr1, out1, [] ); // $ExpectError
|
|
218
|
-
|
|
219
|
-
map.assign( arr1, out1, '5', {} ); // $ExpectError
|
|
220
|
-
map.assign( arr1, out1, true, {} ); // $ExpectError
|
|
221
|
-
map.assign( arr1, out1, false, {} ); // $ExpectError
|
|
222
|
-
map.assign( arr1, out1, 123, {} ); // $ExpectError
|
|
223
|
-
map.assign( arr1, out1, null, {} ); // $ExpectError
|
|
224
|
-
map.assign( arr1, out1, {}, {} ); // $ExpectError
|
|
225
|
-
map.assign( arr1, out1, [], {} ); // $ExpectError
|
|
226
|
-
|
|
227
|
-
map.assign( arr1, out1, ( x: number, y: number, z: number ): number => x + y + z ); // $ExpectError
|
|
228
|
-
map.assign( arr1, out1, ( x: number, y: number, z: number ): number => x + y + z, {} ); // $ExpectError
|
|
229
|
-
|
|
230
|
-
const arr2 = array( [ 1, 2, 3, 4, 5, 6 ] );
|
|
231
|
-
const out2 = array( [ 0, 0, 0, 0, 0, 0 ] );
|
|
232
|
-
|
|
233
|
-
map.assign( arr2, out2, '5' ); // $ExpectError
|
|
234
|
-
map.assign( arr2, out2, true ); // $ExpectError
|
|
235
|
-
map.assign( arr2, out2, false ); // $ExpectError
|
|
236
|
-
map.assign( arr2, out2, 123 ); // $ExpectError
|
|
237
|
-
map.assign( arr2, out2, null ); // $ExpectError
|
|
238
|
-
map.assign( arr2, out2, {} ); // $ExpectError
|
|
239
|
-
map.assign( arr2, out2, [] ); // $ExpectError
|
|
240
|
-
|
|
241
|
-
map.assign( arr2, out2, '5', {} ); // $ExpectError
|
|
242
|
-
map.assign( arr2, out2, true, {} ); // $ExpectError
|
|
243
|
-
map.assign( arr2, out2, false, {} ); // $ExpectError
|
|
244
|
-
map.assign( arr2, out2, 123, {} ); // $ExpectError
|
|
245
|
-
map.assign( arr2, out2, null, {} ); // $ExpectError
|
|
246
|
-
map.assign( arr2, out2, {}, {} ); // $ExpectError
|
|
247
|
-
map.assign( arr2, out2, [], {} ); // $ExpectError
|
|
248
|
-
|
|
249
|
-
map.assign( arr2, out2, ( x: number, y: number, z: number ): number => x + y + z ); // $ExpectError
|
|
250
|
-
map.assign( arr2, out2, ( x: number, y: number, z: number ): number => x + y + z, {} ); // $ExpectError
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// The compiler throws an error if the `assign` method is provided an unsupported number of arguments...
|
|
254
|
-
{
|
|
255
|
-
const arr1 = [ 1, 2, 3, 4, 5, 6 ];
|
|
256
|
-
const out1 = [ 0, 0, 0, 0, 0, 0 ];
|
|
257
|
-
|
|
258
|
-
map.assign(); // $ExpectError
|
|
259
|
-
map.assign( arr1 ); // $ExpectError
|
|
260
|
-
map.assign( arr1, out1 ); // $ExpectError
|
|
261
|
-
map.assign( arr1, out1, clbk, {}, 4 ); // $ExpectError
|
|
262
|
-
|
|
263
|
-
const arr2 = array( [ 1, 2, 3, 4, 5, 6 ] );
|
|
264
|
-
const out2 = array( [ 0, 0, 0, 0, 0, 0 ] );
|
|
265
|
-
|
|
266
|
-
map.assign(); // $ExpectError
|
|
267
|
-
map.assign( arr2 ); // $ExpectError
|
|
268
|
-
map.assign( arr2, out2 ); // $ExpectError
|
|
269
|
-
map.assign( arr2, out2, clbk, {}, 4 ); // $ExpectError
|
|
270
|
-
}
|