@stdlib/utils-async-map-keys 0.0.8 → 0.2.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/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +27 -12
- package/SECURITY.md +5 -0
- 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 +9 -9
- package/lib/factory.js +4 -4
- package/lib/index.js +3 -3
- package/lib/limit.js +0 -1
- package/lib/{map_keys.js → main.js} +0 -1
- package/lib/validate.js +4 -3
- package/package.json +20 -17
- package/docs/repl.txt +0 -187
- package/docs/types/test.ts +0 -166
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-2024 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
|
# mapKeysAsync
|
|
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] -->
|
|
@@ -377,8 +388,8 @@ mapKeysAsync( files, read, done );
|
|
|
377
388
|
|
|
378
389
|
## See Also
|
|
379
390
|
|
|
380
|
-
- <span class="package-name">[`@stdlib/utils
|
|
381
|
-
- <span class="package-name">[`@stdlib/utils
|
|
391
|
+
- <span class="package-name">[`@stdlib/utils-map-keys`][@stdlib/utils/map-keys]</span><span class="delimiter">: </span><span class="description">map keys from one object to a new object having the same values.</span>
|
|
392
|
+
- <span class="package-name">[`@stdlib/utils-async/map-values`][@stdlib/utils/async/map-values]</span><span class="delimiter">: </span><span class="description">map values from one object to a new object having the same keys.</span>
|
|
382
393
|
|
|
383
394
|
</section>
|
|
384
395
|
|
|
@@ -410,7 +421,7 @@ See [LICENSE][stdlib-license].
|
|
|
410
421
|
|
|
411
422
|
## Copyright
|
|
412
423
|
|
|
413
|
-
Copyright © 2016-
|
|
424
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
414
425
|
|
|
415
426
|
</section>
|
|
416
427
|
|
|
@@ -423,8 +434,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
423
434
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/utils-async-map-keys.svg
|
|
424
435
|
[npm-url]: https://npmjs.org/package/@stdlib/utils-async-map-keys
|
|
425
436
|
|
|
426
|
-
[test-image]: https://github.com/stdlib-js/utils-async-map-keys/actions/workflows/test.yml/badge.svg
|
|
427
|
-
[test-url]: https://github.com/stdlib-js/utils-async-map-keys/actions/workflows/test.yml
|
|
437
|
+
[test-image]: https://github.com/stdlib-js/utils-async-map-keys/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
438
|
+
[test-url]: https://github.com/stdlib-js/utils-async-map-keys/actions/workflows/test.yml?query=branch:v0.2.0
|
|
428
439
|
|
|
429
440
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-async-map-keys/main.svg
|
|
430
441
|
[coverage-url]: https://codecov.io/github/stdlib-js/utils-async-map-keys?branch=main
|
|
@@ -436,19 +447,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
436
447
|
|
|
437
448
|
-->
|
|
438
449
|
|
|
450
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
451
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
452
|
+
|
|
453
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
454
|
+
|
|
455
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
456
|
+
|
|
439
457
|
[umd]: https://github.com/umdjs/umd
|
|
440
458
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
441
459
|
|
|
442
460
|
[deno-url]: https://github.com/stdlib-js/utils-async-map-keys/tree/deno
|
|
461
|
+
[deno-readme]: https://github.com/stdlib-js/utils-async-map-keys/blob/deno/README.md
|
|
443
462
|
[umd-url]: https://github.com/stdlib-js/utils-async-map-keys/tree/umd
|
|
463
|
+
[umd-readme]: https://github.com/stdlib-js/utils-async-map-keys/blob/umd/README.md
|
|
444
464
|
[esm-url]: https://github.com/stdlib-js/utils-async-map-keys/tree/esm
|
|
445
|
-
|
|
446
|
-
[
|
|
447
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
448
|
-
|
|
449
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
450
|
-
|
|
451
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
465
|
+
[esm-readme]: https://github.com/stdlib-js/utils-async-map-keys/blob/esm/README.md
|
|
466
|
+
[branches-url]: https://github.com/stdlib-js/utils-async-map-keys/blob/main/branches.md
|
|
452
467
|
|
|
453
468
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/utils-async-map-keys/main/LICENSE
|
|
454
469
|
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var y=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var P=y(function(Z,T){
|
|
2
|
+
var S=require('@stdlib/assert-is-plain-object/dist'),q=require('@stdlib/assert-has-own-property/dist'),j=require('@stdlib/assert-is-boolean/dist').isPrimitive,B=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,b=require('@stdlib/error-tools-fmtprodmsg/dist');function C(e,r){return S(r)?(q(r,"thisArg")&&(e.thisArg=r.thisArg),q(r,"series")&&(e.series=r.series,!j(e.series))?new TypeError(b('1RP2o',"series",e.series)):q(r,"limit")&&(e.limit=r.limit,!B(e.limit))?new TypeError(b('1RP3P',"limit",e.limit)):null):new TypeError(b('1RP2V',r));}T.exports=C
|
|
3
|
+
});var N=y(function(_,F){
|
|
4
|
+
var R=require("debug"),z=require('@stdlib/utils-keys/dist'),s=R("map-values-async:limit");function D(e,r,i,n){var u,v,l,f,c,t,m,o,h;if(l=z(e),t=l.length,s("Number of keys: %d",t),o={},t===0)return s("Finished processing an object."),n(null,o);for(t<r.limit?c=t:c=r.limit,s("Concurrency limit: %d",c),s("Number of arguments: %d",i.length),u=t-1,v=0,m=-1,h=0;h<c;h++)m<u&&x();function x(){var a,g;m+=1,g=l[m],a=e[g],s("%s: %s",g,JSON.stringify(a)),i.length===2?i.call(r.thisArg,g,d):i.length===3?i.call(r.thisArg,g,a,d):i.call(r.thisArg,g,a,e,d);function d(O,E){if(!f){if(O)return f=!0,A(O);s("Transform result => %s: %s",E,JSON.stringify(a)),o[E]=a,A()}}}function A(a){if(a)return s("Encountered an error: %s",a.message),n(a);if(v+=1,s("Processed %d of %d properties.",v,t),m<u)return x();if(v===t)return s("Finished processing an object."),n(null,o)}}F.exports=D
|
|
5
|
+
});var p=y(function($,V){
|
|
6
|
+
var k=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),G=require('@stdlib/constants-float64-pinf/dist'),H=P(),M=N();function Q(e,r){var i,n,u;if(i={},arguments.length>1){if(n=H(i,e),n)throw n;u=r}else u=e;if(!k(u))throw new TypeError(w('1RP3q',u));return i.series?i.limit=1:i.limit||(i.limit=G),v;function v(l,f){if(typeof l!="object"||l===null)throw new TypeError(w('1RP3L',l));if(!k(f))throw new TypeError(w('1RP3q',f));return M(l,i,u,c);function c(t,m){if(t)return f(t);f(null,m)}}}V.exports=Q
|
|
7
|
+
});var J=y(function(rr,K){
|
|
8
|
+
var I=p();function U(e,r,i,n){if(arguments.length<4)return I(r)(e,i);I(r,i)(e,n)}K.exports=U
|
|
9
|
+
});var W=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),L=J(),X=p();W(L,"factory",X);module.exports=L;
|
|
10
|
+
/** @license Apache-2.0 */
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/validate.js", "../lib/limit.js", "../lib/factory.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next own property\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'thisArg': {},\n* 'series': false,\n* 'limit': 10\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'thisArg' ) ) {\n\t\topts.thisArg = options.thisArg;\n\t}\n\tif ( hasOwnProp( options, 'series' ) ) {\n\t\topts.series = options.series;\n\t\tif ( !isBoolean( opts.series ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'limit' ) ) {\n\t\topts.limit = options.limit;\n\t\tif ( !isPositiveInteger( opts.limit ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 logger = require( 'debug' );\nvar objectKeys = require( '@stdlib/utils-keys' );\n\n\n// VARIABLES //\n\nvar debug = logger( 'map-values-async:limit' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each own property in a source object, limiting the number of concurrently pending functions.\n*\n* ## Notes\n*\n* - Iteration order is **not** guaranteed.\n* - We need to cache an object value to prevent the edge case where, during the invocation of the transform function, the value corresponding to a particular key is swapped for some other value. For some, that might be a feature; here, we take the stance that one should be less clever.\n*\n* @private\n* @param {Object} obj - source object\n* @param {Options} opts - function options\n* @param {*} [opts.thisArg] - execution context\n* @param {PositiveInteger} [opts.limit] - maximum number of pending function invocations\n* @param {Function} fcn - function to invoke\n* @param {Callback} done - function to invoke upon completion or upon encountering an error\n* @returns {void}\n*/\nfunction limit( obj, opts, fcn, done ) {\n\tvar maxIndex;\n\tvar count;\n\tvar keys;\n\tvar flg;\n\tvar lim;\n\tvar len;\n\tvar idx;\n\tvar out;\n\tvar i;\n\n\tkeys = objectKeys( obj );\n\tlen = keys.length;\n\tdebug( 'Number of keys: %d', len );\n\n\tout = {};\n\tif ( len === 0 ) {\n\t\tdebug( 'Finished processing an object.' );\n\t\treturn done( null, out );\n\t}\n\tif ( len < opts.limit ) {\n\t\tlim = len;\n\t} else {\n\t\tlim = opts.limit;\n\t}\n\tdebug( 'Concurrency limit: %d', lim );\n\tdebug( 'Number of arguments: %d', fcn.length );\n\n\tmaxIndex = len - 1;\n\tcount = 0;\n\tidx = -1;\n\tfor ( i = 0; i < lim; i++ ) {\n\t\t// This guard is necessary to protect against synchronous functions which exhaust all properties...\n\t\tif ( idx < maxIndex ) {\n\t\t\tnext(); // eslint-disable-line node/callback-return\n\t\t}\n\t}\n\t/**\n\t* Callback to invoke a provided function for the next property.\n\t*\n\t* @private\n\t*/\n\tfunction next() {\n\t\tvar value;\n\t\tvar key;\n\n\t\tidx += 1;\n\t\tkey = keys[ idx ];\n\n\t\tvalue = obj[ key ];\n\t\tdebug( '%s: %s', key, JSON.stringify( value ) );\n\n\t\tif ( fcn.length === 2 ) {\n\t\t\tfcn.call( opts.thisArg, key, cb );\n\t\t} else if ( fcn.length === 3 ) {\n\t\t\tfcn.call( opts.thisArg, key, value, cb );\n\t\t} else {\n\t\t\tfcn.call( opts.thisArg, key, value, obj, cb );\n\t\t}\n\t\t/**\n\t\t* Callback invoked once a provided function finishes transforming a property.\n\t\t*\n\t\t* @private\n\t\t* @param {*} [error] - error\n\t\t* @param {*} [key] - transformed key\n\t\t* @returns {void}\n\t\t*/\n\t\tfunction cb( error, key ) {\n\t\t\tif ( flg ) {\n\t\t\t\t// Prevent further processing of properties:\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( error ) {\n\t\t\t\tflg = true;\n\t\t\t\treturn clbk( error );\n\t\t\t}\n\t\t\tdebug( 'Transform result => %s: %s', key, JSON.stringify( value ) );\n\t\t\tout[ key ] = value;\n\t\t\tclbk();\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked once ready to process the next property.\n\t*\n\t* @private\n\t* @param {*} [error] - error\n\t* @returns {void}\n\t*/\n\tfunction clbk( error ) {\n\t\tif ( error ) {\n\t\t\tdebug( 'Encountered an error: %s', error.message );\n\t\t\treturn done( error );\n\t\t}\n\t\tcount += 1;\n\t\tdebug( 'Processed %d of %d properties.', count, len );\n\t\tif ( idx < maxIndex ) {\n\t\t\treturn next();\n\t\t}\n\t\tif ( count === len ) {\n\t\t\tdebug( 'Finished processing an object.' );\n\t\t\treturn done( null, out );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = limit;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 format = require( '@stdlib/string-format' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar validate = require( './validate.js' );\nvar limit = require( './limit.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function to map keys from one object to a new object having the same values.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n* - Iteration and insertion order are **not** guaranteed.\n* - The function only operates on own properties, not inherited properties.\n*\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next own property\n* @param {Function} transform - transform function\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} last argument must be a function\n* @returns {Function} function which maps keys from one object to a new object having the same values\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function read( key, value, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( value, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( null, key+':unreadable' );\n* }\n* next( null, key+':readable' );\n* }\n* }\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Create a reusable function:\n* var mapKeysAsync = factory( opts, read );\n*\n* // Create a dictionary of file names:\n* var files = {\n* 'file1': './beep.js',\n* 'file2': './boop.js'\n* };\n*\n* // Define a callback which handles errors:\n* function done( error, out ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( out );\n* }\n*\n* // Process each file in `files`:\n* mapKeysAsync( files, done );\n*/\nfunction factory( options, transform ) {\n\tvar opts;\n\tvar err;\n\tvar f;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tf = transform;\n\t} else {\n\t\tf = options;\n\t}\n\tif ( !isFunction( f ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );\n\t}\n\tif ( opts.series ) {\n\t\topts.limit = 1;\n\t} else if ( !opts.limit ) {\n\t\topts.limit = PINF;\n\t}\n\treturn mapKeysAsync;\n\n\t/**\n\t* Maps keys from one object to a new object having the same values.\n\t*\n\t* @private\n\t* @param {Object} obj - source object\n\t* @param {Callback} done - function to invoke upon completion\n\t* @throws {TypeError} first argument must be an object\n\t* @throws {TypeError} last argument must be a function\n\t* @returns {void}\n\t*/\n\tfunction mapKeysAsync( obj, done ) {\n\t\tif ( typeof obj !== 'object' || obj === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );\n\t\t}\n\t\tif ( !isFunction( done ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );\n\t\t}\n\t\treturn limit( obj, opts, f, clbk );\n\n\t\t/**\n\t\t* Callback invoked upon completion.\n\t\t*\n\t\t* @private\n\t\t* @param {*} [error] - error\n\t\t* @param {Object} [out] - output object\n\t\t* @returns {void}\n\t\t*/\n\t\tfunction clbk( error, out ) {\n\t\t\tif ( error ) {\n\t\t\t\treturn done( error );\n\t\t\t}\n\t\t\tdone( null, out );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 factory = require( './factory.js' );\n\n\n// MAIN //\n\n/**\n* Maps keys from one object to a new object having the same values.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n* - Iteration and insertion order are **not** guaranteed.\n* - The function only operates on own properties, not inherited properties.\n*\n* @param {Object} obj - source object\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next own property\n* @param {Function} transform - transform function\n* @param {Callback} done - function to invoke upon completion\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} second-to-last argument must be a function\n* @throws {TypeError} last argument must be a function\n* @returns {void}\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function read( key, value, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( value, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( null, key+':unreadable' );\n* }\n* next( null, key+':readable' );\n* }\n* }\n*\n* // Define a callback which handles errors:\n* function done( error, out ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( out );\n* }\n*\n* // Create a dictionary of file names:\n* var files = {\n* 'file1': './beep.js',\n* 'file2': './boop.js'\n* };\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Process each file in `files`:\n* mapKeysAsync( files, opts, read, done );\n*/\nfunction mapKeysAsync( obj, options, transform, done ) {\n\tif ( arguments.length < 4 ) {\n\t\treturn factory( options )( obj, transform );\n\t}\n\tfactory( options, transform )( obj, done );\n}\n\n\n// EXPORTS //\n\nmodule.exports = mapKeysAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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* Map keys from one object to a new object having the same values.\n*\n* @module @stdlib/utils-async-map-keys\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n* var mapKeysAsync = require( '@stdlib/utils-async-map-keys' );\n*\n* function read( key, value, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( value, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( null, key+':unreadable' );\n* }\n* next( null, key+':readable' );\n* }\n* }\n*\n* // Define a callback which handles errors:\n* function done( error, out ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( out );\n* }\n*\n* // Create a dictionary of file names:\n* var files = {\n* 'file1': './beep.js',\n* 'file2': './boop.js'\n* };\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Process each file in `files`:\n* mapKeysAsync( files, opts, read, done );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isPositiveInteger", "format", "validate", "opts", "options", "require_limit", "__commonJSMin", "exports", "module", "logger", "objectKeys", "debug", "limit", "obj", "opts", "fcn", "done", "maxIndex", "count", "keys", "flg", "lim", "len", "idx", "out", "i", "next", "value", "key", "cb", "error", "clbk", "require_factory", "__commonJSMin", "exports", "module", "isFunction", "format", "PINF", "validate", "limit", "factory", "options", "transform", "opts", "err", "f", "mapKeysAsync", "obj", "done", "clbk", "error", "out", "require_main", "__commonJSMin", "exports", "module", "factory", "mapKeysAsync", "obj", "options", "transform", "done", "setReadOnly", "main", "factory"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Interface defining function options.
|
|
@@ -119,7 +119,7 @@ type TernaryTransform = ( value: any, index: number, next: Callback ) => void;
|
|
|
119
119
|
* @param obj - the input object
|
|
120
120
|
* @param next - a callback to be invoked after processing an object `value`
|
|
121
121
|
*/
|
|
122
|
-
type QuaternaryTransform = ( value: any, index: number, obj: any, next: Callback ) => void;
|
|
122
|
+
type QuaternaryTransform = ( value: any, index: number, obj: any, next: Callback ) => void;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Transform function.
|
|
@@ -129,7 +129,7 @@ type QuaternaryTransform = ( value: any, index: number, obj: any, next: Callback
|
|
|
129
129
|
* @param obj - the input object
|
|
130
130
|
* @param next - a callback to be invoked after processing an object `value`
|
|
131
131
|
*/
|
|
132
|
-
type Transform = Unary | BinaryTransform | TernaryTransform | QuaternaryTransform;
|
|
132
|
+
type Transform = Unary | BinaryTransform | TernaryTransform | QuaternaryTransform;
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Maps keys from one object to a new object having the same values.
|
|
@@ -164,7 +164,7 @@ interface MapKeysAsync {
|
|
|
164
164
|
* @throws must provide valid options
|
|
165
165
|
*
|
|
166
166
|
* @example
|
|
167
|
-
* var readFile = require(
|
|
167
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
168
168
|
*
|
|
169
169
|
* function read( key, value, next ) {
|
|
170
170
|
* var opts = {
|
|
@@ -201,7 +201,7 @@ interface MapKeysAsync {
|
|
|
201
201
|
* // Process each file in `files`:
|
|
202
202
|
* mapKeysAsync( files, opts, read, done );
|
|
203
203
|
*/
|
|
204
|
-
( obj: any, options: Options, transform: Transform, done: DoneCallback ): void;
|
|
204
|
+
( obj: any, options: Options, transform: Transform, done: DoneCallback ): void;
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
207
|
* Maps keys from one object to a new object having the same values.
|
|
@@ -219,7 +219,7 @@ interface MapKeysAsync {
|
|
|
219
219
|
* @param done - function to invoke upon completion
|
|
220
220
|
*
|
|
221
221
|
* @example
|
|
222
|
-
* var readFile = require(
|
|
222
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
223
223
|
*
|
|
224
224
|
* function read( key, value, next ) {
|
|
225
225
|
* var opts = {
|
|
@@ -274,7 +274,7 @@ interface MapKeysAsync {
|
|
|
274
274
|
* @returns function which maps keys from one object to a new object having the same values
|
|
275
275
|
*
|
|
276
276
|
* @example
|
|
277
|
-
* var readFile = require(
|
|
277
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
278
278
|
*
|
|
279
279
|
* function read( key, value, next ) {
|
|
280
280
|
* var opts = {
|
|
@@ -331,7 +331,7 @@ interface MapKeysAsync {
|
|
|
331
331
|
* @returns function which maps keys from one object to a new object having the same values
|
|
332
332
|
*
|
|
333
333
|
* @example
|
|
334
|
-
* var readFile = require(
|
|
334
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
335
335
|
*
|
|
336
336
|
* function read( key, value, next ) {
|
|
337
337
|
* var opts = {
|
|
@@ -391,7 +391,7 @@ interface MapKeysAsync {
|
|
|
391
391
|
* @throws must provide valid options
|
|
392
392
|
*
|
|
393
393
|
* @example
|
|
394
|
-
* var readFile = require(
|
|
394
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
395
395
|
*
|
|
396
396
|
* function read( key, value, next ) {
|
|
397
397
|
* var opts = {
|
package/lib/factory.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
23
|
var isFunction = require( '@stdlib/assert-is-function' );
|
|
24
|
+
var format = require( '@stdlib/string-format' );
|
|
24
25
|
var PINF = require( '@stdlib/constants-float64-pinf' );
|
|
25
26
|
var validate = require( './validate.js' );
|
|
26
27
|
var limit = require( './limit.js' );
|
|
@@ -38,7 +39,6 @@ var limit = require( './limit.js' );
|
|
|
38
39
|
* - Iteration and insertion order are **not** guaranteed.
|
|
39
40
|
* - The function only operates on own properties, not inherited properties.
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
42
|
* @param {Options} [options] - function options
|
|
43
43
|
* @param {*} [options.thisArg] - execution context
|
|
44
44
|
* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time
|
|
@@ -106,7 +106,7 @@ function factory( options, transform ) {
|
|
|
106
106
|
f = options;
|
|
107
107
|
}
|
|
108
108
|
if ( !isFunction( f ) ) {
|
|
109
|
-
throw new TypeError( 'invalid argument. Last argument must be a function. Value:
|
|
109
|
+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
|
|
110
110
|
}
|
|
111
111
|
if ( opts.series ) {
|
|
112
112
|
opts.limit = 1;
|
|
@@ -127,10 +127,10 @@ function factory( options, transform ) {
|
|
|
127
127
|
*/
|
|
128
128
|
function mapKeysAsync( obj, done ) {
|
|
129
129
|
if ( typeof obj !== 'object' || obj === null ) {
|
|
130
|
-
throw new TypeError( 'invalid argument. First argument must be an object. Value:
|
|
130
|
+
throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );
|
|
131
131
|
}
|
|
132
132
|
if ( !isFunction( done ) ) {
|
|
133
|
-
throw new TypeError( 'invalid argument. Last argument must be a function. Value:
|
|
133
|
+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
|
|
134
134
|
}
|
|
135
135
|
return limit( obj, opts, f, clbk );
|
|
136
136
|
|
package/lib/index.js
CHANGED
|
@@ -66,15 +66,15 @@
|
|
|
66
66
|
// MODULES //
|
|
67
67
|
|
|
68
68
|
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
69
|
-
var
|
|
69
|
+
var main = require( './main.js' );
|
|
70
70
|
var factory = require( './factory.js' );
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
// MAIN //
|
|
74
74
|
|
|
75
|
-
setReadOnly(
|
|
75
|
+
setReadOnly( main, 'factory', factory );
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
// EXPORTS //
|
|
79
79
|
|
|
80
|
-
module.exports =
|
|
80
|
+
module.exports = main;
|
package/lib/limit.js
CHANGED
|
@@ -39,7 +39,6 @@ var debug = logger( 'map-values-async:limit' );
|
|
|
39
39
|
* - Iteration order is **not** guaranteed.
|
|
40
40
|
* - We need to cache an object value to prevent the edge case where, during the invocation of the transform function, the value corresponding to a particular key is swapped for some other value. For some, that might be a feature; here, we take the stance that one should be less clever.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
42
|
* @private
|
|
44
43
|
* @param {Object} obj - source object
|
|
45
44
|
* @param {Options} opts - function options
|
|
@@ -35,7 +35,6 @@ var factory = require( './factory.js' );
|
|
|
35
35
|
* - Iteration and insertion order are **not** guaranteed.
|
|
36
36
|
* - The function only operates on own properties, not inherited properties.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
38
|
* @param {Object} obj - source object
|
|
40
39
|
* @param {Options} [options] - function options
|
|
41
40
|
* @param {*} [options.thisArg] - execution context
|
package/lib/validate.js
CHANGED
|
@@ -24,6 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
|
|
|
24
24
|
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
|
|
25
25
|
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
|
|
26
26
|
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
|
|
27
|
+
var format = require( '@stdlib/string-format' );
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
// MAIN //
|
|
@@ -53,7 +54,7 @@ var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimit
|
|
|
53
54
|
*/
|
|
54
55
|
function validate( opts, options ) {
|
|
55
56
|
if ( !isObject( options ) ) {
|
|
56
|
-
return new TypeError( 'invalid argument. Options must be an object. Value:
|
|
57
|
+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
|
|
57
58
|
}
|
|
58
59
|
if ( hasOwnProp( options, 'thisArg' ) ) {
|
|
59
60
|
opts.thisArg = options.thisArg;
|
|
@@ -61,13 +62,13 @@ function validate( opts, options ) {
|
|
|
61
62
|
if ( hasOwnProp( options, 'series' ) ) {
|
|
62
63
|
opts.series = options.series;
|
|
63
64
|
if ( !isBoolean( opts.series ) ) {
|
|
64
|
-
return new TypeError( 'invalid option. `
|
|
65
|
+
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
if ( hasOwnProp( options, 'limit' ) ) {
|
|
68
69
|
opts.limit = options.limit;
|
|
69
70
|
if ( !isPositiveInteger( opts.limit ) ) {
|
|
70
|
-
return new TypeError( 'invalid option. `
|
|
71
|
+
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/utils-async-map-keys",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Map keys from one object to a new object having the same values.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,24 +37,27 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-has-own-property": "^0.
|
|
41
|
-
"@stdlib/assert-is-boolean": "^0.0
|
|
42
|
-
"@stdlib/assert-is-function": "^0.0
|
|
43
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
44
|
-
"@stdlib/assert-is-positive-integer": "^0.0
|
|
45
|
-
"@stdlib/constants-float64-pinf": "^0.0
|
|
46
|
-
"@stdlib/
|
|
47
|
-
"@stdlib/utils-
|
|
48
|
-
"
|
|
40
|
+
"@stdlib/assert-has-own-property": "^0.1.1",
|
|
41
|
+
"@stdlib/assert-is-boolean": "^0.2.0",
|
|
42
|
+
"@stdlib/assert-is-function": "^0.2.0",
|
|
43
|
+
"@stdlib/assert-is-plain-object": "^0.2.0",
|
|
44
|
+
"@stdlib/assert-is-positive-integer": "^0.2.0",
|
|
45
|
+
"@stdlib/constants-float64-pinf": "^0.2.0",
|
|
46
|
+
"@stdlib/string-format": "^0.2.0",
|
|
47
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0",
|
|
48
|
+
"@stdlib/utils-keys": "^0.2.0",
|
|
49
|
+
"debug": "^2.6.9",
|
|
50
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.1"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@stdlib/
|
|
52
|
-
"@stdlib/
|
|
53
|
-
"@stdlib/
|
|
54
|
-
"@stdlib/utils-noop": "^0.0.x",
|
|
53
|
+
"@stdlib/fs-read-file": "^0.1.1",
|
|
54
|
+
"@stdlib/random-base-randu": "^0.1.0",
|
|
55
|
+
"@stdlib/utils-noop": "^0.2.0",
|
|
55
56
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
56
57
|
"istanbul": "^0.4.1",
|
|
57
|
-
"tap-
|
|
58
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
59
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
60
|
+
"@stdlib/bench": "^0.3.1"
|
|
58
61
|
},
|
|
59
62
|
"engines": {
|
|
60
63
|
"node": ">=0.10.0",
|
|
@@ -96,7 +99,7 @@
|
|
|
96
99
|
"obj"
|
|
97
100
|
],
|
|
98
101
|
"funding": {
|
|
99
|
-
"type": "
|
|
100
|
-
"url": "https://
|
|
102
|
+
"type": "opencollective",
|
|
103
|
+
"url": "https://opencollective.com/stdlib"
|
|
101
104
|
}
|
|
102
105
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( obj, [options,] transform, done )
|
|
3
|
-
Maps keys from one object to a new object having the same values.
|
|
4
|
-
|
|
5
|
-
When invoked, `transform` is provided a maximum of four arguments:
|
|
6
|
-
|
|
7
|
-
- `key`: object key
|
|
8
|
-
- `value`: object value corresponding to `key`
|
|
9
|
-
- `obj`: the input object
|
|
10
|
-
- `next`: a callback to be invoked after processing an object `key`
|
|
11
|
-
|
|
12
|
-
The actual number of provided arguments depends on function length. If
|
|
13
|
-
`transform` accepts two arguments, `transform` is provided:
|
|
14
|
-
|
|
15
|
-
- `key`
|
|
16
|
-
- `next`
|
|
17
|
-
|
|
18
|
-
If `transform` accepts three arguments, `transform` is provided:
|
|
19
|
-
|
|
20
|
-
- `key`
|
|
21
|
-
- `value`
|
|
22
|
-
- `next`
|
|
23
|
-
|
|
24
|
-
For every other `transform` signature, `transform` is provided all four
|
|
25
|
-
arguments.
|
|
26
|
-
|
|
27
|
-
The `next` callback accepts two arguments:
|
|
28
|
-
|
|
29
|
-
- `error`: error argument
|
|
30
|
-
- `key`: transformed key
|
|
31
|
-
|
|
32
|
-
If a `transform` function calls the `next` callback with a truthy `error`
|
|
33
|
-
argument, the function suspends execution and immediately calls the `done`
|
|
34
|
-
callback for subsequent `error` handling.
|
|
35
|
-
|
|
36
|
-
The key returned by a transform function should be a value which can be
|
|
37
|
-
serialized as an object key.
|
|
38
|
-
|
|
39
|
-
Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony,
|
|
40
|
-
wrap the `done` callback in a function which either executes at the end of
|
|
41
|
-
the current stack (e.g., `nextTick`) or during a subsequent turn of the
|
|
42
|
-
event loop (e.g., `setImmediate`, `setTimeout`).
|
|
43
|
-
|
|
44
|
-
The function only maps own properties. Hence, the function does not map
|
|
45
|
-
inherited properties.
|
|
46
|
-
|
|
47
|
-
The function shallow copies key values.
|
|
48
|
-
|
|
49
|
-
Key iteration and insertion order are *not* guaranteed.
|
|
50
|
-
|
|
51
|
-
Parameters
|
|
52
|
-
----------
|
|
53
|
-
obj: Object
|
|
54
|
-
Source object.
|
|
55
|
-
|
|
56
|
-
options: Object (optional)
|
|
57
|
-
Function options.
|
|
58
|
-
|
|
59
|
-
options.limit: integer (optional)
|
|
60
|
-
Maximum number of pending invocations. Default: Infinity.
|
|
61
|
-
|
|
62
|
-
options.series: boolean (optional)
|
|
63
|
-
Boolean indicating whether to process each property sequentially.
|
|
64
|
-
Default: false.
|
|
65
|
-
|
|
66
|
-
options.thisArg: any (optional)
|
|
67
|
-
Execution context.
|
|
68
|
-
|
|
69
|
-
transform: Function
|
|
70
|
-
Transform function. Returned values specify the keys of the output
|
|
71
|
-
object.
|
|
72
|
-
|
|
73
|
-
done: Function
|
|
74
|
-
A callback invoked either upon processing all own properties or upon
|
|
75
|
-
encountering an error.
|
|
76
|
-
|
|
77
|
-
Examples
|
|
78
|
-
--------
|
|
79
|
-
// Basic usage:
|
|
80
|
-
> function transform( key, value, next ) {
|
|
81
|
-
... setTimeout( onTimeout, value );
|
|
82
|
-
... function onTimeout() {
|
|
83
|
-
... next( null, key+':'+value );
|
|
84
|
-
... }
|
|
85
|
-
... };
|
|
86
|
-
> function done( error, out ) {
|
|
87
|
-
... if ( error ) {
|
|
88
|
-
... throw error;
|
|
89
|
-
... }
|
|
90
|
-
... console.log( out );
|
|
91
|
-
... };
|
|
92
|
-
> var obj = { 'a': 1, 'b': 2 };
|
|
93
|
-
> {{alias}}( obj, transform, done )
|
|
94
|
-
{ 'a:1': 1, 'b:2': 2 }
|
|
95
|
-
|
|
96
|
-
// Limit number of concurrent invocations:
|
|
97
|
-
> function transform( key, value, next ) {
|
|
98
|
-
... setTimeout( onTimeout, value );
|
|
99
|
-
... function onTimeout() {
|
|
100
|
-
... next( null, key+':'+value );
|
|
101
|
-
... }
|
|
102
|
-
... };
|
|
103
|
-
> function done( error, out ) {
|
|
104
|
-
... if ( error ) {
|
|
105
|
-
... throw error;
|
|
106
|
-
... }
|
|
107
|
-
... console.log( out );
|
|
108
|
-
... };
|
|
109
|
-
> var opts = { 'limit': 2 };
|
|
110
|
-
> var obj = { 'a': 1, 'b': 2, 'c': 3 };
|
|
111
|
-
> {{alias}}( obj, opts, transform, done )
|
|
112
|
-
{ 'a:1': 1, 'b:2': 2, 'c:3': 3 }
|
|
113
|
-
|
|
114
|
-
// Process sequentially:
|
|
115
|
-
> function transform( key, value, next ) {
|
|
116
|
-
... setTimeout( onTimeout, value );
|
|
117
|
-
... function onTimeout() {
|
|
118
|
-
... next( null, key+':'+value );
|
|
119
|
-
... }
|
|
120
|
-
... };
|
|
121
|
-
> function done( error, out ) {
|
|
122
|
-
... if ( error ) {
|
|
123
|
-
... throw error;
|
|
124
|
-
... }
|
|
125
|
-
... console.log( out );
|
|
126
|
-
... };
|
|
127
|
-
> var opts = { 'series': true };
|
|
128
|
-
> var obj = { 'a': 1, 'b': 2, 'c': 3 };
|
|
129
|
-
> {{alias}}( obj, opts, transform, done )
|
|
130
|
-
{ 'a:1': 1, 'b:2': 2, 'c:3': 3 }
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
{{alias}}.factory( [options,] transform )
|
|
134
|
-
Returns a function which maps keys from one object to a new object having
|
|
135
|
-
the same values.
|
|
136
|
-
|
|
137
|
-
Parameters
|
|
138
|
-
----------
|
|
139
|
-
options: Object (optional)
|
|
140
|
-
Function options.
|
|
141
|
-
|
|
142
|
-
options.limit: integer (optional)
|
|
143
|
-
Maximum number of pending invocations. Default: Infinity.
|
|
144
|
-
|
|
145
|
-
options.series: boolean (optional)
|
|
146
|
-
Boolean indicating whether to process each property sequentially.
|
|
147
|
-
Default: false.
|
|
148
|
-
|
|
149
|
-
options.thisArg: any (optional)
|
|
150
|
-
Execution context.
|
|
151
|
-
|
|
152
|
-
transform: Function
|
|
153
|
-
Transform function. Returned values specify the keys of the output
|
|
154
|
-
object.
|
|
155
|
-
|
|
156
|
-
Returns
|
|
157
|
-
-------
|
|
158
|
-
out: Function
|
|
159
|
-
A function which maps keys from one object to a new object having the
|
|
160
|
-
same values.
|
|
161
|
-
|
|
162
|
-
Examples
|
|
163
|
-
--------
|
|
164
|
-
> function transform( key, value, next ) {
|
|
165
|
-
... setTimeout( onTimeout, value );
|
|
166
|
-
... function onTimeout() {
|
|
167
|
-
... next( null, key+':'+value );
|
|
168
|
-
... }
|
|
169
|
-
... };
|
|
170
|
-
> var opts = { 'series': true };
|
|
171
|
-
> var f = {{alias}}.factory( opts, transform );
|
|
172
|
-
> function done( error, out ) {
|
|
173
|
-
... if ( error ) {
|
|
174
|
-
... throw error;
|
|
175
|
-
... }
|
|
176
|
-
... console.log( out );
|
|
177
|
-
... };
|
|
178
|
-
> var obj = { 'a': 1, 'b': 2, 'c': 3 };
|
|
179
|
-
> f( obj, done )
|
|
180
|
-
{ 'a:1': 1, 'b:2': 2, 'c:3': 3 }
|
|
181
|
-
> obj = { 'beep': 'boop' };
|
|
182
|
-
> f( obj, done )
|
|
183
|
-
{ 'beep:boop': 'beep' }
|
|
184
|
-
|
|
185
|
-
See Also
|
|
186
|
-
--------
|
|
187
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,166 +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 mapKeysAsync = require( './index' );
|
|
20
|
-
|
|
21
|
-
const transform = ( key: string, next: Function ) => {
|
|
22
|
-
next( null, key + ':beep' );
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const done = ( error: Error | null, out: any ) => {
|
|
26
|
-
if ( error ) {
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
if ( out === void 0 ) {
|
|
30
|
-
throw new Error( '`out` is missing.' );
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// TESTS //
|
|
36
|
-
|
|
37
|
-
// The function returns void...
|
|
38
|
-
{
|
|
39
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, done ); // $ExpectType void
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// The compiler throws an error if the function is provided a second argument which is not a transform function...
|
|
43
|
-
{
|
|
44
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, 2, done ); // $ExpectError
|
|
45
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, false, done ); // $ExpectError
|
|
46
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, true, done ); // $ExpectError
|
|
47
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, 'abc', done ); // $ExpectError
|
|
48
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, {}, done ); // $ExpectError
|
|
49
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, [], done ); // $ExpectError
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature...
|
|
53
|
-
{
|
|
54
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, 2 ); // $ExpectError
|
|
55
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, false ); // $ExpectError
|
|
56
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, true ); // $ExpectError
|
|
57
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, 'abc' ); // $ExpectError
|
|
58
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, {} ); // $ExpectError
|
|
59
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, [] ); // $ExpectError
|
|
60
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform, ( x: number ): number => x ); // $ExpectError
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// The compiler throws an error if the function is provided an options argument which is not an object...
|
|
64
|
-
{
|
|
65
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, [], transform, done ); // $ExpectError
|
|
66
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, 123, transform, done ); // $ExpectError
|
|
67
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, 'abc', transform, done ); // $ExpectError
|
|
68
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, false, transform, done ); // $ExpectError
|
|
69
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, true, transform, done ); // $ExpectError
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// The compiler throws an error if the function is provided a `limit` option which is not a number...
|
|
73
|
-
{
|
|
74
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'limit': '12' }, transform, done ); // $ExpectError
|
|
75
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'limit': true }, transform, done ); // $ExpectError
|
|
76
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'limit': false }, transform, done ); // $ExpectError
|
|
77
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'limit': {} }, transform, done ); // $ExpectError
|
|
78
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'limit': [] }, transform, done ); // $ExpectError
|
|
79
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'limit': ( x: number ): number => x }, transform, done ); // $ExpectError
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// The compiler throws an error if the function is provided a `series` option which is not a boolean...
|
|
83
|
-
{
|
|
84
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'series': '12' }, transform, done ); // $ExpectError
|
|
85
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'series': 12 }, transform, done ); // $ExpectError
|
|
86
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'series': {} }, transform, done ); // $ExpectError
|
|
87
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'series': [] }, transform, done ); // $ExpectError
|
|
88
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, { 'series': ( x: number ): number => x }, transform, done ); // $ExpectError
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// The compiler throws an error if the function is provided an invalid number of arguments...
|
|
92
|
-
{
|
|
93
|
-
mapKeysAsync(); // $ExpectError
|
|
94
|
-
mapKeysAsync( { 'a': 1, 'b': 2 } ); // $ExpectError
|
|
95
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, transform ); // $ExpectError
|
|
96
|
-
mapKeysAsync( { 'a': 1, 'b': 2 }, {}, transform, done, {} ); // $ExpectError
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Attached to main export is a `factory` method which returns a function...
|
|
100
|
-
{
|
|
101
|
-
mapKeysAsync.factory( transform ); // $ExpectType FactoryFunction
|
|
102
|
-
mapKeysAsync.factory( { 'series': true }, transform ); // $ExpectType FactoryFunction
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// The compiler throws an error if the `factory` method is provided an options argument which is not an object...
|
|
106
|
-
{
|
|
107
|
-
mapKeysAsync.factory( [], transform ); // $ExpectError
|
|
108
|
-
mapKeysAsync.factory( 123, transform ); // $ExpectError
|
|
109
|
-
mapKeysAsync.factory( 'abc', transform ); // $ExpectError
|
|
110
|
-
mapKeysAsync.factory( false, transform ); // $ExpectError
|
|
111
|
-
mapKeysAsync.factory( true, transform ); // $ExpectError
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// The compiler throws an error if the `factory` method is provided a last argument which is not an transform function...
|
|
115
|
-
{
|
|
116
|
-
mapKeysAsync.factory( {} ); // $ExpectError
|
|
117
|
-
mapKeysAsync.factory( true ); // $ExpectError
|
|
118
|
-
mapKeysAsync.factory( false ); // $ExpectError
|
|
119
|
-
mapKeysAsync.factory( {}, 123 ); // $ExpectError
|
|
120
|
-
mapKeysAsync.factory( {}, 'abc' ); // $ExpectError
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// The compiler throws an error if the function returned by the `factory` method is provided invalid arguments...
|
|
124
|
-
{
|
|
125
|
-
const fcn1 = mapKeysAsync.factory( transform );
|
|
126
|
-
fcn1( { 'a': 1, 'b': 2 }, 12 ); // $ExpectError
|
|
127
|
-
fcn1( { 'a': 1, 'b': 2 }, true ); // $ExpectError
|
|
128
|
-
fcn1( { 'a': 1, 'b': 2 }, false ); // $ExpectError
|
|
129
|
-
fcn1( { 'a': 1, 'b': 2 }, '5' ); // $ExpectError
|
|
130
|
-
fcn1( { 'a': 1, 'b': 2 }, {} ); // $ExpectError
|
|
131
|
-
fcn1( { 'a': 1, 'b': 2 }, [] ); // $ExpectError
|
|
132
|
-
fcn1( { 'a': 1, 'b': 2 }, ( x: number ): number => x ); // $ExpectError
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments...
|
|
136
|
-
{
|
|
137
|
-
const fcn1 = mapKeysAsync.factory( transform );
|
|
138
|
-
fcn1(); // $ExpectError
|
|
139
|
-
fcn1( { 'a': 1, 'b': 2 } ); // $ExpectError
|
|
140
|
-
fcn1( { 'a': 1, 'b': 2 }, done, {} ); // $ExpectError
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// The compiler throws an error if the `factory` method is provided a `limit` option which is not a number...
|
|
144
|
-
{
|
|
145
|
-
mapKeysAsync.factory( { 'limit': '12' }, transform ); // $ExpectError
|
|
146
|
-
mapKeysAsync.factory( { 'limit': true }, transform ); // $ExpectError
|
|
147
|
-
mapKeysAsync.factory( { 'limit': false }, transform ); // $ExpectError
|
|
148
|
-
mapKeysAsync.factory( { 'limit': {} }, transform ); // $ExpectError
|
|
149
|
-
mapKeysAsync.factory( { 'limit': [] }, transform ); // $ExpectError
|
|
150
|
-
mapKeysAsync.factory( { 'limit': ( x: number ): number => x }, transform ); // $ExpectError
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// The compiler throws an error if the `factory` method is provided a `series` option which is not a boolean...
|
|
154
|
-
{
|
|
155
|
-
mapKeysAsync.factory( { 'series': '12' }, transform ); // $ExpectError
|
|
156
|
-
mapKeysAsync.factory( { 'series': 12 }, transform ); // $ExpectError
|
|
157
|
-
mapKeysAsync.factory( { 'series': {} }, transform ); // $ExpectError
|
|
158
|
-
mapKeysAsync.factory( { 'series': [] }, transform ); // $ExpectError
|
|
159
|
-
mapKeysAsync.factory( { 'series': ( x: number ): number => x }, transform ); // $ExpectError
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// The compiler throws an error if the `factory` method is provided an invalid number of arguments...
|
|
163
|
-
{
|
|
164
|
-
mapKeysAsync.factory(); // $ExpectError
|
|
165
|
-
mapKeysAsync.factory( {}, transform, {} ); // $ExpectError
|
|
166
|
-
}
|