@stdlib/simulate-iter-awln 0.0.5 → 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 +51 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1 -1
- package/lib/defaults.js +38 -0
- package/lib/index.js +2 -2
- package/lib/main.js +19 -20
- package/package.json +31 -30
- package/docs/repl.txt +0 -85
- package/docs/types/test.ts +0 -150
- package/lib/defaults.json +0 -3
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,9 +18,20 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# iterawln
|
|
22
33
|
|
|
23
|
-
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
|
|
34
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
24
35
|
|
|
25
36
|
> Create an [iterator][mdn-iterator-protocol] which introduces additive white Laplacian noise (AWLN).
|
|
26
37
|
|
|
@@ -212,6 +223,21 @@ while ( true ) {
|
|
|
212
223
|
|
|
213
224
|
<!-- /.references -->
|
|
214
225
|
|
|
226
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
227
|
+
|
|
228
|
+
<section class="related">
|
|
229
|
+
|
|
230
|
+
* * *
|
|
231
|
+
|
|
232
|
+
## See Also
|
|
233
|
+
|
|
234
|
+
- <span class="package-name">[`@stdlib/simulate-iter/awgn`][@stdlib/simulate/iter/awgn]</span><span class="delimiter">: </span><span class="description">create an iterator which introduces additive white Gaussian noise.</span>
|
|
235
|
+
- <span class="package-name">[`@stdlib/simulate-iter/awun`][@stdlib/simulate/iter/awun]</span><span class="delimiter">: </span><span class="description">create an iterator which introduces additive white uniform noise.</span>
|
|
236
|
+
|
|
237
|
+
</section>
|
|
238
|
+
|
|
239
|
+
<!-- /.related -->
|
|
240
|
+
|
|
215
241
|
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
216
242
|
|
|
217
243
|
|
|
@@ -238,7 +264,7 @@ See [LICENSE][stdlib-license].
|
|
|
238
264
|
|
|
239
265
|
## Copyright
|
|
240
266
|
|
|
241
|
-
Copyright © 2016-
|
|
267
|
+
Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
242
268
|
|
|
243
269
|
</section>
|
|
244
270
|
|
|
@@ -251,22 +277,34 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
251
277
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/simulate-iter-awln.svg
|
|
252
278
|
[npm-url]: https://npmjs.org/package/@stdlib/simulate-iter-awln
|
|
253
279
|
|
|
254
|
-
[test-image]: https://github.com/stdlib-js/simulate-iter-awln/actions/workflows/test.yml/badge.svg
|
|
255
|
-
[test-url]: https://github.com/stdlib-js/simulate-iter-awln/actions/workflows/test.yml
|
|
280
|
+
[test-image]: https://github.com/stdlib-js/simulate-iter-awln/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
281
|
+
[test-url]: https://github.com/stdlib-js/simulate-iter-awln/actions/workflows/test.yml?query=branch:v0.1.0
|
|
256
282
|
|
|
257
283
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/simulate-iter-awln/main.svg
|
|
258
284
|
[coverage-url]: https://codecov.io/github/stdlib-js/simulate-iter-awln?branch=main
|
|
259
285
|
|
|
286
|
+
<!--
|
|
287
|
+
|
|
260
288
|
[dependencies-image]: https://img.shields.io/david/stdlib-js/simulate-iter-awln.svg
|
|
261
289
|
[dependencies-url]: https://david-dm.org/stdlib-js/simulate-iter-awln/main
|
|
262
290
|
|
|
291
|
+
-->
|
|
292
|
+
|
|
263
293
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
264
|
-
[chat-url]: https://gitter.im
|
|
294
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
265
295
|
|
|
266
296
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
267
297
|
|
|
268
298
|
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
269
299
|
|
|
300
|
+
[umd]: https://github.com/umdjs/umd
|
|
301
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
302
|
+
|
|
303
|
+
[deno-url]: https://github.com/stdlib-js/simulate-iter-awln/tree/deno
|
|
304
|
+
[umd-url]: https://github.com/stdlib-js/simulate-iter-awln/tree/umd
|
|
305
|
+
[esm-url]: https://github.com/stdlib-js/simulate-iter-awln/tree/esm
|
|
306
|
+
[branches-url]: https://github.com/stdlib-js/simulate-iter-awln/blob/main/branches.md
|
|
307
|
+
|
|
270
308
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/simulate-iter-awln/main/LICENSE
|
|
271
309
|
|
|
272
310
|
[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
|
|
@@ -275,6 +313,14 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
275
313
|
|
|
276
314
|
[@stdlib/random/base/mt19937]: https://www.npmjs.com/package/@stdlib/random-base-mt19937
|
|
277
315
|
|
|
316
|
+
<!-- <related-links> -->
|
|
317
|
+
|
|
318
|
+
[@stdlib/simulate/iter/awgn]: https://www.npmjs.com/package/@stdlib/simulate-iter-awgn
|
|
319
|
+
|
|
320
|
+
[@stdlib/simulate/iter/awun]: https://www.npmjs.com/package/@stdlib/simulate-iter-awun
|
|
321
|
+
|
|
322
|
+
<!-- </related-links> -->
|
|
323
|
+
|
|
278
324
|
</section>
|
|
279
325
|
|
|
280
326
|
<!-- /.links -->
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";var c=function(u,n){return function(){return n||u((n={exports:{}}).exports,n),n.exports}};var m=c(function(_,f){
|
|
2
|
+
function N(){return{copy:!0}}f.exports=N
|
|
3
|
+
});var q=c(function(C,b){
|
|
4
|
+
var i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),l=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),h=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),A=require('@stdlib/assert-is-iterator-like/dist'),F=require('@stdlib/assert-is-positive-number/dist').isPrimitive,G=require('@stdlib/assert-is-plain-object/dist'),p=require('@stdlib/assert-is-function/dist'),j=require('@stdlib/assert-is-boolean/dist').isPrimitive,V=require('@stdlib/assert-is-uint32array/dist'),v=require('@stdlib/assert-has-own-property/dist'),k=require('@stdlib/utils-noop/dist'),U=require('@stdlib/utils-constant-function/dist'),d=require('@stdlib/symbol-iterator/dist'),W=require('@stdlib/random-base-laplace/dist').factory,o=require('@stdlib/error-tools-fmtprodmsg/dist'),z=require('@stdlib/constants-float64-sqrt-two/dist'),B=m();function y(u,n,e){var a,s,r,g;if(!A(u))throw new TypeError(o('0t73v',u));if(!F(n))throw new TypeError(o('0t772',n));if(s=B(),arguments.length>2){if(!G(e))throw new TypeError(o('0t78J',e));if(v(e,"copy")&&(s.copy=e.copy,!j(e.copy)))throw new TypeError(o('0t72o',"copy",e.copy));if(v(e,"prng")){if(!p(e.prng))throw new TypeError(o('0t76u',"prng",e.prng));s.prng=e.prng}else if(v(e,"state")){if(s.state=e.state,!V(e.state))throw new TypeError(o('0t76z',"state",e.state))}else if(v(e,"seed")&&(s.seed=e.seed,e.seed===void 0))throw new TypeError(o('0t774',"seed",e.seed))}return a=W(0,n/z,s),r={},i(r,"next",P),i(r,"return",E),d&&p(u[d])&&i(r,d,R),e&&e.prng?(i(r,"seed",null),i(r,"seedLength",null),h(r,"state",U(null),k),i(r,"stateLength",null),i(r,"byteLength",null),i(r,"PRNG",e.prng)):(l(r,"seed",w),l(r,"seedLength",L),h(r,"state",O,x),l(r,"stateLength",S),l(r,"byteLength",T),i(r,"PRNG",a.PRNG)),r;function w(){return a.seed}function L(){return a.seedLength}function S(){return a.stateLength}function T(){return a.byteLength}function O(){return a.state}function x(t){a.state=t}function P(){var t;return g?{done:!0}:(t=u.next(),t.done?(g=!0,t):(typeof t.value=="number"?t=t.value+a():t=NaN,{value:t,done:!1}))}function E(t){return g=!0,arguments.length?{value:t,done:!0}:{done:!0}}function R(){return y(u[d](),n,s)}}b.exports=y
|
|
5
|
+
});var I=q();module.exports=I;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
7
|
+
/** @license Apache-2.0 */
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/defaults.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*/\nfunction defaults() {\n\treturn {\n\t\t'copy': true\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar isIteratorLike = require( '@stdlib/assert-is-iterator-like' );\nvar isPositiveNumber = require( '@stdlib/assert-is-positive-number' ).isPrimitive;\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isUint32Array = require( '@stdlib/assert-is-uint32array' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar noop = require( '@stdlib/utils-noop' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar iteratorSymbol = require( '@stdlib/symbol-iterator' );\nvar laplace = require( '@stdlib/random-base-laplace' ).factory;\nvar format = require( '@stdlib/string-format' );\nvar SQRT_TWO = require( '@stdlib/constants-float64-sqrt-two' );\nvar defaults = require( './defaults.js' );\n\n\n// MAIN //\n\n/**\n* Returns an iterator which introduces additive white Laplacian noise with standard deviation `sigma`.\n*\n* ## Method\n*\n* - The variance of a Laplace (biexponential or double-exponential) distribution is given by\n*\n* ```tex\n* \\operatorname{Var} = 2b^2\n* ```\n*\n* where \\\\( b \\\\) is the distribution scale parameter.\n*\n* - Accordingly, the standard deviation is then\n*\n* ```tex\n* \\sigma = b\\sqrt{2}\n* ```\n*\n* - Solving for \\\\( b \\\\), we derive the parameter transform necessary for generating a Laplacian random variable with standard deviation \\\\( \\sigma \\\\)\n*\n* ```tex\n* b = \\frac{\\sigma}{\\sqrt{2}}\n* ```\n*\n* @param {Iterator} iterator - input iterator\n* @param {PositiveNumber} sigma - standard deviation of the noise\n* @param {Options} [options] - function options\n* @param {PRNG} [options.prng] - pseudorandom number generator which generates uniformly distributed pseudorandom numbers on the interval `[0,1)`\n* @param {PRNGSeedMT19937} [options.seed] - pseudorandom number generator seed\n* @param {PRNGStateMT19937} [options.state] - pseudorandom number generator state\n* @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state\n* @throws {TypeError} first argument must be an iterator\n* @throws {TypeError} second argument must be a positive number\n* @throws {TypeError} third argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {Error} must provide a valid state\n* @returns {Iterator} iterator\n*\n* @example\n* var iterSineWave = require( '@stdlib/simulate-iter-sine-wave' );\n*\n* var sine = iterSineWave({\n* 'iter': 100\n* });\n*\n* var it = iterawln( sine, 0.5 );\n*\n* var v = it.next().value;\n* // returns <number>\n*\n* v = it.next().value;\n* // returns <number>\n*\n* v = it.next().value;\n* // returns <number>\n*\n* // ...\n*/\nfunction iterawln( iterator, sigma, options ) {\n\tvar rlaplace;\n\tvar opts;\n\tvar iter;\n\tvar FLG;\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator. Value: `%s`.', iterator ) );\n\t}\n\tif ( !isPositiveNumber( sigma ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a positive number. Value: `%s`.', sigma ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'copy' ) ) {\n\t\t\topts.copy = options.copy;\n\t\t\tif ( !isBoolean( options.copy ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'copy', options.copy ) );\n\t\t\t}\n\t\t}\n\t\tif ( hasOwnProp( options, 'prng' ) ) {\n\t\t\tif ( !isFunction( options.prng ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a pseudorandom number generator function. Option: `%s`.', 'prng', options.prng ) );\n\t\t\t}\n\t\t\topts.prng = options.prng;\n\t\t}\n\t\t// If provided a PRNG, ignore the `state` option, as we don't support getting or setting PRNG state.\n\t\telse if ( hasOwnProp( options, 'state' ) ) {\n\t\t\topts.state = options.state;\n\t\t\tif ( !isUint32Array( options.state ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a Uint32Array. Option: `%s`.', 'state', options.state ) );\n\t\t\t}\n\t\t}\n\t\t// If provided a PRNG, ignore the `seed` option, as a `seed`, by itself, is insufficient to guarantee reproducibility. If provided a state, ignore the `seed` option, as a PRNG state should contain seed information.\n\t\telse if ( hasOwnProp( options, 'seed' ) ) {\n\t\t\topts.seed = options.seed;\n\t\t\tif ( options.seed === void 0 ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: `%s`.', 'seed', options.seed ) );\n\t\t\t}\n\t\t}\n\t}\n\trlaplace = laplace( 0.0, sigma/SQRT_TWO, opts );\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator` and the provided iterator is iterable, make the iterator iterable:\n\tif ( iteratorSymbol && isFunction( iterator[ iteratorSymbol ] ) ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// If we are provided an \"external\" PRNG, we don't support getting or setting PRNG state, as we'd need to check for compatible state value types, etc, entailing considerable complexity.\n\tif ( options && options.prng ) {\n\t\tsetReadOnly( iter, 'seed', null );\n\t\tsetReadOnly( iter, 'seedLength', null );\n\t\tsetReadWriteAccessor( iter, 'state', constantFunction( null ), noop );\n\t\tsetReadOnly( iter, 'stateLength', null );\n\t\tsetReadOnly( iter, 'byteLength', null );\n\t\tsetReadOnly( iter, 'PRNG', options.prng );\n\t} else {\n\t\tsetReadOnlyAccessor( iter, 'seed', getSeed );\n\t\tsetReadOnlyAccessor( iter, 'seedLength', getSeedLength );\n\t\tsetReadWriteAccessor( iter, 'state', getState, setState );\n\t\tsetReadOnlyAccessor( iter, 'stateLength', getStateLength );\n\t\tsetReadOnlyAccessor( iter, 'byteLength', getStateSize );\n\t\tsetReadOnly( iter, 'PRNG', rlaplace.PRNG );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns the PRNG seed.\n\t*\n\t* @private\n\t* @returns {PRNGSeedMT19937} seed\n\t*/\n\tfunction getSeed() {\n\t\treturn rlaplace.seed;\n\t}\n\n\t/**\n\t* Returns the PRNG seed length.\n\t*\n\t* @private\n\t* @returns {PositiveInteger} seed length\n\t*/\n\tfunction getSeedLength() {\n\t\treturn rlaplace.seedLength;\n\t}\n\n\t/**\n\t* Returns the PRNG state length.\n\t*\n\t* @private\n\t* @returns {PositiveInteger} state length\n\t*/\n\tfunction getStateLength() {\n\t\treturn rlaplace.stateLength;\n\t}\n\n\t/**\n\t* Returns the PRNG state size (in bytes).\n\t*\n\t* @private\n\t* @returns {PositiveInteger} state size (in bytes)\n\t*/\n\tfunction getStateSize() {\n\t\treturn rlaplace.byteLength;\n\t}\n\n\t/**\n\t* Returns the current PRNG state.\n\t*\n\t* @private\n\t* @returns {PRNGStateMT19937} current state\n\t*/\n\tfunction getState() {\n\t\treturn rlaplace.state;\n\t}\n\n\t/**\n\t* Sets the PRNG state.\n\t*\n\t* @private\n\t* @param {PRNGStateMT19937} s - generator state\n\t* @throws {Error} must provide a valid state\n\t*/\n\tfunction setState( s ) {\n\t\trlaplace.state = s;\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar v;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tFLG = true;\n\t\t\treturn v;\n\t\t}\n\t\tif ( typeof v.value === 'number' ) {\n\t\t\tv = v.value + rlaplace();\n\t\t} else {\n\t\t\tv = NaN;\n\t\t}\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn iterawln( iterator[ iteratorSymbol ](), sigma, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterawln;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an iterator which introduces additive white Laplacian noise (AWLN).\n*\n* @module @stdlib/simulate-iter-awln\n*\n* @example\n* var iterSineWave = require( '@stdlib/simulate-iter-sine-wave' );\n* var iterawln = require( '@stdlib/simulate-iter-awln' );\n*\n* var sine = iterSineWave({\n* 'iter': 100\n* });\n*\n* var it = iterawln( sine, 0.5 );\n*\n* var v = it.next().value;\n* // returns <number>\n*\n* v = it.next().value;\n* // returns <number>\n*\n* v = it.next().value;\n* // returns <number>\n*\n* // ...\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require_defaults", "__commonJSMin", "exports", "module", "defaults", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setReadOnlyAccessor", "setReadWriteAccessor", "isIteratorLike", "isPositiveNumber", "isPlainObject", "isFunction", "isBoolean", "isUint32Array", "hasOwnProp", "noop", "constantFunction", "iteratorSymbol", "laplace", "format", "SQRT_TWO", "defaults", "iterawln", "iterator", "sigma", "options", "rlaplace", "opts", "iter", "FLG", "next", "end", "factory", "getSeed", "getSeedLength", "getState", "setState", "getStateLength", "getStateSize", "s", "v", "value", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
package/lib/defaults.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MAIN //
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns default options.
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
* @returns {Object} default options
|
|
28
|
+
*/
|
|
29
|
+
function defaults() {
|
|
30
|
+
return {
|
|
31
|
+
'copy': true
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// EXPORTS //
|
|
37
|
+
|
|
38
|
+
module.exports = defaults;
|
package/lib/index.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -30,13 +30,13 @@ var isFunction = require( '@stdlib/assert-is-function' );
|
|
|
30
30
|
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
|
|
31
31
|
var isUint32Array = require( '@stdlib/assert-is-uint32array' );
|
|
32
32
|
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
|
|
33
|
-
var copy = require( '@stdlib/utils-copy' );
|
|
34
33
|
var noop = require( '@stdlib/utils-noop' );
|
|
35
34
|
var constantFunction = require( '@stdlib/utils-constant-function' );
|
|
36
35
|
var iteratorSymbol = require( '@stdlib/symbol-iterator' );
|
|
37
36
|
var laplace = require( '@stdlib/random-base-laplace' ).factory;
|
|
37
|
+
var format = require( '@stdlib/string-format' );
|
|
38
38
|
var SQRT_TWO = require( '@stdlib/constants-float64-sqrt-two' );
|
|
39
|
-
var
|
|
39
|
+
var defaults = require( './defaults.js' );
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
// MAIN //
|
|
@@ -106,25 +106,25 @@ function iterawln( iterator, sigma, options ) {
|
|
|
106
106
|
var iter;
|
|
107
107
|
var FLG;
|
|
108
108
|
if ( !isIteratorLike( iterator ) ) {
|
|
109
|
-
throw new TypeError( 'invalid argument. First argument must be an iterator. Value:
|
|
109
|
+
throw new TypeError( format( 'invalid argument. First argument must be an iterator. Value: `%s`.', iterator ) );
|
|
110
110
|
}
|
|
111
111
|
if ( !isPositiveNumber( sigma ) ) {
|
|
112
|
-
throw new TypeError( 'invalid argument. Second argument must be a positive number. Value:
|
|
112
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a positive number. Value: `%s`.', sigma ) );
|
|
113
113
|
}
|
|
114
|
-
opts =
|
|
114
|
+
opts = defaults();
|
|
115
115
|
if ( arguments.length > 2 ) {
|
|
116
116
|
if ( !isPlainObject( options ) ) {
|
|
117
|
-
throw new TypeError( 'invalid argument. Third argument must be an object. Value:
|
|
117
|
+
throw new TypeError( format( 'invalid argument. Third argument must be an object. Value: `%s`.', options ) );
|
|
118
118
|
}
|
|
119
119
|
if ( hasOwnProp( options, 'copy' ) ) {
|
|
120
120
|
opts.copy = options.copy;
|
|
121
121
|
if ( !isBoolean( options.copy ) ) {
|
|
122
|
-
throw new TypeError( 'invalid option. `
|
|
122
|
+
throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'copy', options.copy ) );
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
if ( hasOwnProp( options, 'prng' ) ) {
|
|
126
126
|
if ( !isFunction( options.prng ) ) {
|
|
127
|
-
throw new TypeError( 'invalid option. `
|
|
127
|
+
throw new TypeError( format( 'invalid option. `%s` option must be a pseudorandom number generator function. Option: `%s`.', 'prng', options.prng ) );
|
|
128
128
|
}
|
|
129
129
|
opts.prng = options.prng;
|
|
130
130
|
}
|
|
@@ -132,14 +132,14 @@ function iterawln( iterator, sigma, options ) {
|
|
|
132
132
|
else if ( hasOwnProp( options, 'state' ) ) {
|
|
133
133
|
opts.state = options.state;
|
|
134
134
|
if ( !isUint32Array( options.state ) ) {
|
|
135
|
-
throw new TypeError( 'invalid option. `
|
|
135
|
+
throw new TypeError( format( 'invalid option. `%s` option must be a Uint32Array. Option: `%s`.', 'state', options.state ) );
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
// If provided a PRNG, ignore the `seed` option, as a `seed`, by itself, is insufficient to guarantee reproducibility. If provided a state, ignore the `seed` option, as a PRNG state should contain seed information.
|
|
139
139
|
else if ( hasOwnProp( options, 'seed' ) ) {
|
|
140
140
|
opts.seed = options.seed;
|
|
141
141
|
if ( options.seed === void 0 ) {
|
|
142
|
-
throw new TypeError( 'invalid option. `
|
|
142
|
+
throw new TypeError( format( 'invalid option. `%s` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: `%s`.', 'seed', options.seed ) );
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -240,27 +240,26 @@ function iterawln( iterator, sigma, options ) {
|
|
|
240
240
|
* @returns {Object} iterator protocol-compliant object
|
|
241
241
|
*/
|
|
242
242
|
function next() {
|
|
243
|
-
var out;
|
|
244
243
|
var v;
|
|
245
244
|
if ( FLG ) {
|
|
246
245
|
return {
|
|
247
246
|
'done': true
|
|
248
247
|
};
|
|
249
248
|
}
|
|
250
|
-
out = {};
|
|
251
249
|
v = iterator.next();
|
|
252
|
-
if ( typeof v.value === 'number' ) {
|
|
253
|
-
out.value = v.value + rlaplace();
|
|
254
|
-
} else if ( hasOwnProp( v, 'value' ) ) {
|
|
255
|
-
out.value = NaN;
|
|
256
|
-
}
|
|
257
250
|
if ( v.done ) {
|
|
258
251
|
FLG = true;
|
|
259
|
-
|
|
252
|
+
return v;
|
|
253
|
+
}
|
|
254
|
+
if ( typeof v.value === 'number' ) {
|
|
255
|
+
v = v.value + rlaplace();
|
|
260
256
|
} else {
|
|
261
|
-
|
|
257
|
+
v = NaN;
|
|
262
258
|
}
|
|
263
|
-
return
|
|
259
|
+
return {
|
|
260
|
+
'value': v,
|
|
261
|
+
'done': false
|
|
262
|
+
};
|
|
264
263
|
}
|
|
265
264
|
|
|
266
265
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/simulate-iter-awln",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Create an iterator which introduces additive white Laplacian noise.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,38 +37,39 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-has-own-property": "^0.0
|
|
41
|
-
"@stdlib/assert-is-boolean": "^0.0
|
|
42
|
-
"@stdlib/assert-is-function": "^0.0
|
|
43
|
-
"@stdlib/assert-is-iterator-like": "^0.0
|
|
44
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
45
|
-
"@stdlib/assert-is-positive-number": "^0.0
|
|
46
|
-
"@stdlib/assert-is-uint32array": "^0.0
|
|
47
|
-
"@stdlib/constants-float64-sqrt-two": "^0.0
|
|
48
|
-
"@stdlib/random-base-laplace": "^0.0
|
|
49
|
-
"@stdlib/
|
|
50
|
-
"@stdlib/
|
|
51
|
-
"@stdlib/
|
|
52
|
-
"@stdlib/utils-
|
|
53
|
-
"@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0
|
|
54
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0
|
|
55
|
-
"@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0
|
|
56
|
-
"@stdlib/utils-noop": "^0.0
|
|
40
|
+
"@stdlib/assert-has-own-property": "^0.1.0",
|
|
41
|
+
"@stdlib/assert-is-boolean": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-function": "^0.1.0",
|
|
43
|
+
"@stdlib/assert-is-iterator-like": "^0.1.0",
|
|
44
|
+
"@stdlib/assert-is-plain-object": "^0.1.0",
|
|
45
|
+
"@stdlib/assert-is-positive-number": "^0.1.0",
|
|
46
|
+
"@stdlib/assert-is-uint32array": "^0.1.0",
|
|
47
|
+
"@stdlib/constants-float64-sqrt-two": "^0.1.0",
|
|
48
|
+
"@stdlib/random-base-laplace": "^0.1.0",
|
|
49
|
+
"@stdlib/string-format": "^0.1.0",
|
|
50
|
+
"@stdlib/symbol-iterator": "^0.1.0",
|
|
51
|
+
"@stdlib/types": "^0.1.0",
|
|
52
|
+
"@stdlib/utils-constant-function": "^0.1.0",
|
|
53
|
+
"@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.0",
|
|
54
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
|
|
55
|
+
"@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.0",
|
|
56
|
+
"@stdlib/utils-noop": "^0.1.0",
|
|
57
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@stdlib/array-float64": "^0.0
|
|
60
|
-
"@stdlib/array-to-iterator": "^0.0
|
|
61
|
-
"@stdlib/array-uint32": "^0.0
|
|
62
|
-
"@stdlib/bench": "^0.0
|
|
63
|
-
"@stdlib/constants-uint32-max": "^0.0
|
|
64
|
-
"@stdlib/math-base-assert-is-nan": "^0.0
|
|
65
|
-
"@stdlib/random-base-minstd-shuffle": "^0.0.
|
|
66
|
-
"@stdlib/random-iter-randu": "^0.0.
|
|
67
|
-
"@stdlib/simulate-iter-sine-wave": "^0.0
|
|
60
|
+
"@stdlib/array-float64": "^0.1.0",
|
|
61
|
+
"@stdlib/array-to-iterator": "^0.1.0",
|
|
62
|
+
"@stdlib/array-uint32": "^0.1.0",
|
|
63
|
+
"@stdlib/bench": "^0.1.0",
|
|
64
|
+
"@stdlib/constants-uint32-max": "^0.1.0",
|
|
65
|
+
"@stdlib/math-base-assert-is-nan": "^0.1.0",
|
|
66
|
+
"@stdlib/random-base-minstd-shuffle": "^0.0.6",
|
|
67
|
+
"@stdlib/random-iter-randu": "^0.0.6",
|
|
68
|
+
"@stdlib/simulate-iter-sine-wave": "^0.1.0",
|
|
68
69
|
"proxyquire": "^2.0.0",
|
|
69
70
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
70
71
|
"istanbul": "^0.4.1",
|
|
71
|
-
"tap-
|
|
72
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
72
73
|
},
|
|
73
74
|
"engines": {
|
|
74
75
|
"node": ">=0.10.0",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"iter"
|
|
108
109
|
],
|
|
109
110
|
"funding": {
|
|
110
|
-
"type": "
|
|
111
|
-
"url": "https://
|
|
111
|
+
"type": "opencollective",
|
|
112
|
+
"url": "https://opencollective.com/stdlib"
|
|
112
113
|
}
|
|
113
114
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( iterator, sigma[, options] )
|
|
3
|
-
Returns an iterator which introduces additive white Laplacian noise (AWLN)
|
|
4
|
-
with standard deviation `sigma`.
|
|
5
|
-
|
|
6
|
-
If an environment supports Symbol.iterator and the provided iterator is
|
|
7
|
-
iterable, the returned iterator is iterable.
|
|
8
|
-
|
|
9
|
-
Parameters
|
|
10
|
-
----------
|
|
11
|
-
iterator: Object
|
|
12
|
-
Input iterator.
|
|
13
|
-
|
|
14
|
-
sigma: number
|
|
15
|
-
Standard deviation of the noise.
|
|
16
|
-
|
|
17
|
-
options: Object (optional)
|
|
18
|
-
Options.
|
|
19
|
-
|
|
20
|
-
options.prng: Function (optional)
|
|
21
|
-
Pseudorandom number generator (PRNG) for generating uniformly
|
|
22
|
-
distributed pseudorandom numbers on the interval [0,1). If provided, the
|
|
23
|
-
`state` and `seed` options are ignored. In order to seed the returned
|
|
24
|
-
iterator, one must seed the provided `prng` (assuming the provided
|
|
25
|
-
`prng` is seedable).
|
|
26
|
-
|
|
27
|
-
options.seed: integer|ArrayLikeObject<integer> (optional)
|
|
28
|
-
Pseudorandom number generator seed. The seed may be either a positive
|
|
29
|
-
unsigned 32-bit integer or, for arbitrary length seeds, an array-like
|
|
30
|
-
object containing unsigned 32-bit integers.
|
|
31
|
-
|
|
32
|
-
options.state: Uint32Array (optional)
|
|
33
|
-
Pseudorandom number generator state. If provided, the `seed` option is
|
|
34
|
-
ignored.
|
|
35
|
-
|
|
36
|
-
options.copy: boolean (optional)
|
|
37
|
-
Boolean indicating whether to copy a provided pseudorandom number
|
|
38
|
-
generator state. Setting this option to `false` allows sharing state
|
|
39
|
-
between two or more pseudorandom number generators. Setting this option
|
|
40
|
-
to `true` ensures that a returned iterator has exclusive control over
|
|
41
|
-
its internal state. Default: true.
|
|
42
|
-
|
|
43
|
-
Returns
|
|
44
|
-
-------
|
|
45
|
-
iterator: Object
|
|
46
|
-
Iterator.
|
|
47
|
-
|
|
48
|
-
iterator.next(): Function
|
|
49
|
-
Returns an iterator protocol-compliant object containing the next
|
|
50
|
-
iterated value (if one exists) and a boolean flag indicating whether the
|
|
51
|
-
iterator is finished.
|
|
52
|
-
|
|
53
|
-
iterator.return( [value] ): Function
|
|
54
|
-
Finishes an iterator and returns a provided value.
|
|
55
|
-
|
|
56
|
-
iterator.PRNG: Function
|
|
57
|
-
Underlying pseudorandom number generator.
|
|
58
|
-
|
|
59
|
-
iterator.seed: Uint32Array|null
|
|
60
|
-
Pseudorandom number generator seed.
|
|
61
|
-
|
|
62
|
-
iterator.seedLength: integer|null
|
|
63
|
-
Length of generator seed.
|
|
64
|
-
|
|
65
|
-
iterator.state: Uint32Array|null
|
|
66
|
-
Pseudorandom random number generator state.
|
|
67
|
-
|
|
68
|
-
iterator.stateLength: integer|null
|
|
69
|
-
Length of generator state.
|
|
70
|
-
|
|
71
|
-
iterator.byteLength: integer|null
|
|
72
|
-
Size (in bytes) of generator state.
|
|
73
|
-
|
|
74
|
-
Examples
|
|
75
|
-
--------
|
|
76
|
-
> var src = {{alias:@stdlib/simulate/iter/sine-wave}}();
|
|
77
|
-
> var it = {{alias}}( src, 0.5 );
|
|
78
|
-
> var v = it.next().value
|
|
79
|
-
<number>
|
|
80
|
-
> v = it.next().value
|
|
81
|
-
<number>
|
|
82
|
-
|
|
83
|
-
See Also
|
|
84
|
-
--------
|
|
85
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2019 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 iterawln = require( './index' );
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Returns an iterator protocol-compliant object.
|
|
23
|
-
*
|
|
24
|
-
* @returns iterator protocol-compliant object
|
|
25
|
-
*/
|
|
26
|
-
function iterator() {
|
|
27
|
-
return {
|
|
28
|
-
'next': next
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Implements the iterator protocol `next` method.
|
|
33
|
-
*
|
|
34
|
-
* @returns iterator protocol-compliant object
|
|
35
|
-
*/
|
|
36
|
-
function next() {
|
|
37
|
-
return {
|
|
38
|
-
'value': true,
|
|
39
|
-
'done': false
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// TESTS //
|
|
46
|
-
|
|
47
|
-
// The function returns an iterator...
|
|
48
|
-
{
|
|
49
|
-
iterawln( iterator(), 0.2 ); // $ExpectType ExtendedIterator
|
|
50
|
-
iterawln( iterator(), 0.2, {} ); // $ExpectType ExtendedIterator
|
|
51
|
-
iterawln( iterator(), 0.2, { 'seed': 12345 } ); // $ExpectType ExtendedIterator
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// The compiler throws an error if the function is provided a first argument which is not an iterator protocol-compliant object...
|
|
55
|
-
{
|
|
56
|
-
iterawln( '5', 1.0 ); // $ExpectError
|
|
57
|
-
iterawln( 5, 1.0 ); // $ExpectError
|
|
58
|
-
iterawln( true, 1.0 ); // $ExpectError
|
|
59
|
-
iterawln( false, 1.0 ); // $ExpectError
|
|
60
|
-
iterawln( null, 1.0 ); // $ExpectError
|
|
61
|
-
iterawln( undefined, 1.0 ); // $ExpectError
|
|
62
|
-
iterawln( [], 1.0 ); // $ExpectError
|
|
63
|
-
iterawln( {}, 1.0 ); // $ExpectError
|
|
64
|
-
iterawln( ( x: number ): number => x, 1.0 ); // $ExpectError
|
|
65
|
-
|
|
66
|
-
iterawln( '5', 1.0, {} ); // $ExpectError
|
|
67
|
-
iterawln( 5, 1.0, {} ); // $ExpectError
|
|
68
|
-
iterawln( true, 1.0, {} ); // $ExpectError
|
|
69
|
-
iterawln( false, 1.0, {} ); // $ExpectError
|
|
70
|
-
iterawln( null, 1.0, {} ); // $ExpectError
|
|
71
|
-
iterawln( undefined, 1.0, {} ); // $ExpectError
|
|
72
|
-
iterawln( [], 1.0, {} ); // $ExpectError
|
|
73
|
-
iterawln( {}, 1.0, {} ); // $ExpectError
|
|
74
|
-
iterawln( ( x: number ): number => x, 1.0, {} ); // $ExpectError
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// The compiler throws an error if the function is provided a second argument which is not a number...
|
|
78
|
-
{
|
|
79
|
-
iterawln( iterator(), '5' ); // $ExpectError
|
|
80
|
-
iterawln( iterator(), true ); // $ExpectError
|
|
81
|
-
iterawln( iterator(), false ); // $ExpectError
|
|
82
|
-
iterawln( iterator(), null ); // $ExpectError
|
|
83
|
-
iterawln( iterator(), undefined ); // $ExpectError
|
|
84
|
-
iterawln( iterator(), [] ); // $ExpectError
|
|
85
|
-
iterawln( iterator(), {} ); // $ExpectError
|
|
86
|
-
iterawln( iterator(), ( x: number ): number => x ); // $ExpectError
|
|
87
|
-
|
|
88
|
-
iterawln( iterator(), '5', {} ); // $ExpectError
|
|
89
|
-
iterawln( iterator(), true, {} ); // $ExpectError
|
|
90
|
-
iterawln( iterator(), false, {} ); // $ExpectError
|
|
91
|
-
iterawln( iterator(), null, {} ); // $ExpectError
|
|
92
|
-
iterawln( iterator(), undefined, {} ); // $ExpectError
|
|
93
|
-
iterawln( iterator(), [], {} ); // $ExpectError
|
|
94
|
-
iterawln( iterator(), {}, {} ); // $ExpectError
|
|
95
|
-
iterawln( iterator(), ( x: number ): number => x, {} ); // $ExpectError
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// The compiler throws an error if the function is provided a third argument which is not an object...
|
|
99
|
-
{
|
|
100
|
-
iterawln( iterator(), 1.0, null ); // $ExpectError
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// The compiler throws an error if the function is provided an invalid `seed` option...
|
|
104
|
-
{
|
|
105
|
-
iterawln( iterator(), 1.0, { 'seed': '5' } ); // $ExpectError
|
|
106
|
-
iterawln( iterator(), 1.0, { 'seed': true } ); // $ExpectError
|
|
107
|
-
iterawln( iterator(), 1.0, { 'seed': false } ); // $ExpectError
|
|
108
|
-
iterawln( iterator(), 1.0, { 'seed': null } ); // $ExpectError
|
|
109
|
-
iterawln( iterator(), 1.0, { 'seed': {} } ); // $ExpectError
|
|
110
|
-
iterawln( iterator(), 1.0, { 'seed': ( x: number ): number => x } ); // $ExpectError
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// The compiler throws an error if the function is provided an invalid `prng` option...
|
|
114
|
-
{
|
|
115
|
-
iterawln( iterator(), 1.0, { 'prng': '5' } ); // $ExpectError
|
|
116
|
-
iterawln( iterator(), 1.0, { 'prng': 5 } ); // $ExpectError
|
|
117
|
-
iterawln( iterator(), 1.0, { 'prng': true } ); // $ExpectError
|
|
118
|
-
iterawln( iterator(), 1.0, { 'prng': false } ); // $ExpectError
|
|
119
|
-
iterawln( iterator(), 1.0, { 'prng': null } ); // $ExpectError
|
|
120
|
-
iterawln( iterator(), 1.0, { 'prng': [] } ); // $ExpectError
|
|
121
|
-
iterawln( iterator(), 1.0, { 'prng': {} } ); // $ExpectError
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// The compiler throws an error if the function is provided an invalid `state` option...
|
|
125
|
-
{
|
|
126
|
-
iterawln( iterator(), 1.0, { 'state': '5' } ); // $ExpectError
|
|
127
|
-
iterawln( iterator(), 1.0, { 'state': 5 } ); // $ExpectError
|
|
128
|
-
iterawln( iterator(), 1.0, { 'state': true } ); // $ExpectError
|
|
129
|
-
iterawln( iterator(), 1.0, { 'state': false } ); // $ExpectError
|
|
130
|
-
iterawln( iterator(), 1.0, { 'state': null } ); // $ExpectError
|
|
131
|
-
iterawln( iterator(), 1.0, { 'state': [] } ); // $ExpectError
|
|
132
|
-
iterawln( iterator(), 1.0, { 'state': {} } ); // $ExpectError
|
|
133
|
-
iterawln( iterator(), 1.0, { 'state': ( x: number ): number => x } ); // $ExpectError
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// The compiler throws an error if the function is provided an invalid `copy` option...
|
|
137
|
-
{
|
|
138
|
-
iterawln( iterator(), 1.0, { 'copy': '5' } ); // $ExpectError
|
|
139
|
-
iterawln( iterator(), 1.0, { 'copy': 5 } ); // $ExpectError
|
|
140
|
-
iterawln( iterator(), 1.0, { 'copy': null } ); // $ExpectError
|
|
141
|
-
iterawln( iterator(), 1.0, { 'copy': [] } ); // $ExpectError
|
|
142
|
-
iterawln( iterator(), 1.0, { 'copy': {} } ); // $ExpectError
|
|
143
|
-
iterawln( iterator(), 1.0, { 'copy': ( x: number ): number => x } ); // $ExpectError
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// The compiler throws an error if the function is provided insufficient arguments...
|
|
147
|
-
{
|
|
148
|
-
iterawln(); // $ExpectError
|
|
149
|
-
iterawln( iterator() ); // $ExpectError
|
|
150
|
-
}
|
package/lib/defaults.json
DELETED