@stdlib/fs-read-json 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +23 -11
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1 -1
- package/lib/async.js +3 -2
- package/lib/sync.js +2 -1
- package/package.json +17 -15
- package/docs/repl.txt +0 -72
- package/docs/types/test.ts +0 -169
package/CITATION.cff
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: stdlib
|
|
3
|
+
message: >-
|
|
4
|
+
If you use this software, please cite it using the
|
|
5
|
+
metadata from this file.
|
|
6
|
+
|
|
7
|
+
type: software
|
|
8
|
+
|
|
9
|
+
authors:
|
|
10
|
+
- name: The Stdlib Authors
|
|
11
|
+
url: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
12
|
+
|
|
13
|
+
repository-code: https://github.com/stdlib-js/stdlib
|
|
14
|
+
url: https://stdlib.io
|
|
15
|
+
|
|
16
|
+
abstract: |
|
|
17
|
+
Standard library for JavaScript and Node.js.
|
|
18
|
+
|
|
19
|
+
keywords:
|
|
20
|
+
- JavaScript
|
|
21
|
+
- Node.js
|
|
22
|
+
- TypeScript
|
|
23
|
+
- standard library
|
|
24
|
+
- scientific computing
|
|
25
|
+
- numerical computing
|
|
26
|
+
- statistical computing
|
|
27
|
+
|
|
28
|
+
license: Apache-2.0 AND BSL-1.0
|
|
29
|
+
|
|
30
|
+
date-released: 2016
|
package/LICENSE
CHANGED
|
@@ -175,307 +175,3 @@
|
|
|
175
175
|
of your accepting any such warranty or additional liability.
|
|
176
176
|
|
|
177
177
|
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
182
|
-
|
|
183
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
184
|
-
obtaining a copy of the software and accompanying documentation covered by this
|
|
185
|
-
license (the "Software") to use, reproduce, display, distribute, execute, and
|
|
186
|
-
transmit the Software, and to prepare derivative works of the Software, and to
|
|
187
|
-
permit third-parties to whom the Software is furnished to do so, all subject to
|
|
188
|
-
the following:
|
|
189
|
-
|
|
190
|
-
The copyright notices in the Software and this entire statement, including the
|
|
191
|
-
above license grant, this restriction and the following disclaimer, must be
|
|
192
|
-
included in all copies of the Software, in whole or in part, and all derivative
|
|
193
|
-
works of the Software, unless such copies or derivative works are solely in the
|
|
194
|
-
form of machine-executable object code generated by a source language processor.
|
|
195
|
-
|
|
196
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
197
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
198
|
-
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
199
|
-
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
|
|
200
|
-
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
201
|
-
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
DEPENDENCIES
|
|
207
|
-
|
|
208
|
-
The library links against the following external libraries, which have their own
|
|
209
|
-
licenses:
|
|
210
|
-
|
|
211
|
-
* OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
|
|
212
|
-
def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
|
|
213
|
-
|
|
214
|
-
Copyright (c) 2011-2014, The OpenBLAS Project
|
|
215
|
-
All rights reserved.
|
|
216
|
-
|
|
217
|
-
Redistribution and use in source and binary forms, with or without
|
|
218
|
-
modification, are permitted provided that the following conditions are
|
|
219
|
-
met:
|
|
220
|
-
|
|
221
|
-
1. Redistributions of source code must retain the above copyright
|
|
222
|
-
notice, this list of conditions and the following disclaimer.
|
|
223
|
-
|
|
224
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
225
|
-
notice, this list of conditions and the following disclaimer in
|
|
226
|
-
the documentation and/or other materials provided with the
|
|
227
|
-
distribution.
|
|
228
|
-
|
|
229
|
-
3. Neither the name of the OpenBLAS project nor the names of
|
|
230
|
-
its contributors may be used to endorse or promote products
|
|
231
|
-
derived from this software without specific prior written
|
|
232
|
-
permission.
|
|
233
|
-
|
|
234
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
235
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
236
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
237
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
238
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
239
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
240
|
-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
241
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
242
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
243
|
-
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* Electron <https://raw.githubusercontent.com/electron/electron/
|
|
247
|
-
c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
|
|
248
|
-
|
|
249
|
-
Copyright (c) 2013-2017 GitHub Inc.
|
|
250
|
-
|
|
251
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
252
|
-
a copy of this software and associated documentation files (the
|
|
253
|
-
"Software"), to deal in the Software without restriction, including
|
|
254
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
255
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
256
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
257
|
-
the following conditions:
|
|
258
|
-
|
|
259
|
-
The above copyright notice and this permission notice shall be
|
|
260
|
-
included in all copies or substantial portions of the Software.
|
|
261
|
-
|
|
262
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
263
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
264
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
265
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
266
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
267
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
268
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* Boost <http://www.boost.org/LICENSE_1_0.txt>
|
|
272
|
-
|
|
273
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
274
|
-
|
|
275
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
276
|
-
obtaining a copy of the software and accompanying documentation covered by
|
|
277
|
-
this license (the "Software") to use, reproduce, display, distribute,
|
|
278
|
-
execute, and transmit the Software, and to prepare derivative works of the
|
|
279
|
-
Software, and to permit third-parties to whom the Software is furnished to
|
|
280
|
-
do so, all subject to the following:
|
|
281
|
-
|
|
282
|
-
The copyright notices in the Software and this entire statement, including
|
|
283
|
-
the above license grant, this restriction and the following disclaimer,
|
|
284
|
-
must be included in all copies of the Software, in whole or in part, and
|
|
285
|
-
all derivative works of the Software, unless such copies or derivative
|
|
286
|
-
works are solely in the form of machine-executable object code generated by
|
|
287
|
-
a source language processor.
|
|
288
|
-
|
|
289
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
290
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
291
|
-
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
292
|
-
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
293
|
-
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
294
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
295
|
-
DEALINGS IN THE SOFTWARE.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* Cephes <http://www.netlib.org/cephes/readme>
|
|
299
|
-
|
|
300
|
-
Copyright (c) 1984-2000 Stephen L. Moshier
|
|
301
|
-
|
|
302
|
-
Some software in this archive may be from the book _Methods and Programs for
|
|
303
|
-
Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
|
|
304
|
-
or from the Cephes Mathematical Library, a commercial product. In either event,
|
|
305
|
-
it is copyrighted by the author. What you see here may be used freely but it
|
|
306
|
-
comes with no support or guarantee.
|
|
307
|
-
|
|
308
|
-
Stephen L. Moshier
|
|
309
|
-
moshier@na-net.ornl.gov
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ATTRIBUTION
|
|
314
|
-
|
|
315
|
-
The library contains implementations from the following external libraries,
|
|
316
|
-
which have their own licenses:
|
|
317
|
-
|
|
318
|
-
* FreeBSD <https://svnweb.freebsd.org/>
|
|
319
|
-
|
|
320
|
-
Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
|
321
|
-
|
|
322
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
323
|
-
Permission to use, copy, modify, and distribute this
|
|
324
|
-
software is freely granted, provided that this notice
|
|
325
|
-
is preserved.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
* FDLIBM <http://www.netlib.org/fdlibm/>
|
|
329
|
-
|
|
330
|
-
Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
|
331
|
-
|
|
332
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
333
|
-
Permission to use, copy, modify, and distribute this
|
|
334
|
-
software is freely granted, provided that this notice
|
|
335
|
-
is preserved.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
|
|
339
|
-
|
|
340
|
-
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
341
|
-
|
|
342
|
-
Redistribution and use in source and binary forms, with or without
|
|
343
|
-
modification, are permitted provided that the following conditions are
|
|
344
|
-
met:
|
|
345
|
-
|
|
346
|
-
* Redistributions of source code must retain the above copyright
|
|
347
|
-
notice, this list of conditions and the following disclaimer.
|
|
348
|
-
* Redistributions in binary form must reproduce the above
|
|
349
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
350
|
-
in the documentation and/or other materials provided with the
|
|
351
|
-
distribution.
|
|
352
|
-
* Neither the name of Google Inc. nor the names of its
|
|
353
|
-
contributors may be used to endorse or promote products derived from
|
|
354
|
-
this software without specific prior written permission.
|
|
355
|
-
|
|
356
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
357
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
358
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
359
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
360
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
361
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
362
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
363
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
364
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
365
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
366
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
|
|
370
|
-
|
|
371
|
-
Public domain.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
* ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
|
|
375
|
-
|
|
376
|
-
Copyright JS Foundation and other contributors, https://js.foundation
|
|
377
|
-
|
|
378
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
379
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
380
|
-
in the Software without restriction, including without limitation the rights
|
|
381
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
382
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
383
|
-
furnished to do so, subject to the following conditions:
|
|
384
|
-
|
|
385
|
-
The above copyright notice and this permission notice shall be included in
|
|
386
|
-
all copies or substantial portions of the Software.
|
|
387
|
-
|
|
388
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
389
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
390
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
391
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
392
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
393
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
394
|
-
THE SOFTWARE.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
|
|
398
|
-
e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
|
|
399
|
-
|
|
400
|
-
Copyright (c) 2015: Dahua Lin.
|
|
401
|
-
|
|
402
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
403
|
-
a copy of this software and associated documentation files (the
|
|
404
|
-
"Software"), to deal in the Software without restriction, including
|
|
405
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
406
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
407
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
408
|
-
the following conditions:
|
|
409
|
-
|
|
410
|
-
The above copyright notice and this permission notice shall be
|
|
411
|
-
included in all copies or substantial portions of the Software.
|
|
412
|
-
|
|
413
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
414
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
415
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
416
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
417
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
418
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
419
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
|
|
423
|
-
SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
|
|
424
|
-
|
|
425
|
-
The MIT License (MIT)
|
|
426
|
-
|
|
427
|
-
Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
|
|
428
|
-
|
|
429
|
-
https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
|
|
430
|
-
|
|
431
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
432
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
433
|
-
in the Software without restriction, including without limitation the rights
|
|
434
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
435
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
436
|
-
furnished to do so, subject to the following conditions:
|
|
437
|
-
|
|
438
|
-
The above copyright notice and this permission notice shall be included in all
|
|
439
|
-
copies or substantial portions of the Software.
|
|
440
|
-
|
|
441
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
442
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
443
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
444
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
445
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
446
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
447
|
-
SOFTWARE.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
|
|
451
|
-
mt19937ar.c>
|
|
452
|
-
|
|
453
|
-
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
|
454
|
-
All rights reserved.
|
|
455
|
-
|
|
456
|
-
Redistribution and use in source and binary forms, with or without
|
|
457
|
-
modification, are permitted provided that the following conditions
|
|
458
|
-
are met:
|
|
459
|
-
|
|
460
|
-
1. Redistributions of source code must retain the above copyright
|
|
461
|
-
notice, this list of conditions and the following disclaimer.
|
|
462
|
-
|
|
463
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
464
|
-
notice, this list of conditions and the following disclaimer in the
|
|
465
|
-
documentation and/or other materials provided with the distribution.
|
|
466
|
-
|
|
467
|
-
3. The names of its contributors may not be used to endorse or promote
|
|
468
|
-
products derived from this software without specific prior written
|
|
469
|
-
permission.
|
|
470
|
-
|
|
471
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
472
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
473
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
474
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
475
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
476
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
477
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
478
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
479
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
480
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
481
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2023 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# Read JSON
|
|
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] -->
|
|
@@ -163,7 +174,7 @@ function onJSON( error, data ) {
|
|
|
163
174
|
|
|
164
175
|
## See Also
|
|
165
176
|
|
|
166
|
-
- <span class="package-name">[`@stdlib/fs
|
|
177
|
+
- <span class="package-name">[`@stdlib/fs-read-file`][@stdlib/fs/read-file]</span><span class="delimiter">: </span><span class="description">read the entire contents of a file.</span>
|
|
167
178
|
|
|
168
179
|
</section>
|
|
169
180
|
|
|
@@ -195,7 +206,7 @@ See [LICENSE][stdlib-license].
|
|
|
195
206
|
|
|
196
207
|
## Copyright
|
|
197
208
|
|
|
198
|
-
Copyright © 2016-
|
|
209
|
+
Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
199
210
|
|
|
200
211
|
</section>
|
|
201
212
|
|
|
@@ -208,8 +219,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
208
219
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/fs-read-json.svg
|
|
209
220
|
[npm-url]: https://npmjs.org/package/@stdlib/fs-read-json
|
|
210
221
|
|
|
211
|
-
[test-image]: https://github.com/stdlib-js/fs-read-json/actions/workflows/test.yml/badge.svg
|
|
212
|
-
[test-url]: https://github.com/stdlib-js/fs-read-json/actions/workflows/test.yml
|
|
222
|
+
[test-image]: https://github.com/stdlib-js/fs-read-json/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
223
|
+
[test-url]: https://github.com/stdlib-js/fs-read-json/actions/workflows/test.yml?query=branch:v0.1.0
|
|
213
224
|
|
|
214
225
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/fs-read-json/main.svg
|
|
215
226
|
[coverage-url]: https://codecov.io/github/stdlib-js/fs-read-json?branch=main
|
|
@@ -221,19 +232,20 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
221
232
|
|
|
222
233
|
-->
|
|
223
234
|
|
|
235
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
236
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
237
|
+
|
|
238
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
239
|
+
|
|
240
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
241
|
+
|
|
224
242
|
[umd]: https://github.com/umdjs/umd
|
|
225
243
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
226
244
|
|
|
227
245
|
[deno-url]: https://github.com/stdlib-js/fs-read-json/tree/deno
|
|
228
246
|
[umd-url]: https://github.com/stdlib-js/fs-read-json/tree/umd
|
|
229
247
|
[esm-url]: https://github.com/stdlib-js/fs-read-json/tree/esm
|
|
230
|
-
|
|
231
|
-
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
232
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
233
|
-
|
|
234
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
235
|
-
|
|
236
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
248
|
+
[branches-url]: https://github.com/stdlib-js/fs-read-json/blob/main/branches.md
|
|
237
249
|
|
|
238
250
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/fs-read-json/main/LICENSE
|
|
239
251
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";var v=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var q=v(function(P,g){
|
|
2
|
+
var l=require('@stdlib/assert-is-string/dist').isPrimitive,S=require('@stdlib/assert-is-plain-object/dist'),b=require('@stdlib/assert-is-function/dist'),y=require('@stdlib/fs-read-file/dist'),h=require('@stdlib/string-remove-utf8-bom/dist'),s=require('@stdlib/utils-parse-json/dist'),w=require('@stdlib/assert-instance-of/dist'),c=require('@stdlib/error-tools-fmtprodmsg/dist');function E(n,r,a){var e,t;if(arguments.length<3)e={},t=r;else{if(l(r))e={encoding:r};else{if(!S(r))throw new TypeError(c('0OH3t',r));e=r}t=a}if(!b(t))throw new TypeError(c('0OH2b',t));y(n,e,O);function O(u,i){if(u)return t(u);if(i=i.toString(),e.encoding==="utf8"&&(i=h(i)),e.reviver?i=s(i,e.reviver):i=s(i),w(i,Error))return t(i);t(null,i)}}g.exports=E
|
|
3
|
+
});var d=v(function(R,o){
|
|
4
|
+
var J=require('@stdlib/assert-is-string/dist').isPrimitive,N=require('@stdlib/assert-is-plain-object/dist'),j=require('@stdlib/fs-read-file/dist').sync,p=require('@stdlib/string-remove-utf8-bom/dist'),m=require('@stdlib/utils-parse-json/dist'),x=require('@stdlib/assert-instance-of/dist'),F=require('@stdlib/error-tools-fmtprodmsg/dist');function T(n,r){var a,e;if(arguments.length>1)if(J(r))a={encoding:r};else{if(!N(r))throw new TypeError(F('0OH3t',r));a=r}else a={};return e=j(n,a),x(e,Error)?e:(e=e.toString(),a.encoding==="utf8"&&(e=p(e)),a.reviver?m(e,a.reviver):m(e))}o.exports=T
|
|
5
|
+
});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=q(),B=d();V(f,"sync",B);module.exports=f;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/async.js", "../lib/sync.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 isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar readFile = require( '@stdlib/fs-read-file' );\nvar removeBOM = require( '@stdlib/string-remove-utf8-bom' );\nvar parseJSON = require( '@stdlib/utils-parse-json' );\nvar instanceOf = require( '@stdlib/assert-instance-of' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Asynchronously reads a file as JSON.\n*\n* @param {(string|Buffer|integer)} file - file path or file descriptor\n* @param {(Options|string)} [options] - options\n* @param {(string|null)} [options.encoding] - file encoding\n* @param {string} [options.flag] - file status flag\n* @param {Function} [options.reviver] - JSON reviver\n* @param {Callback} clbk - callback\n* @throws {TypeError} options argument must be either a string or an object\n* @throws {TypeError} callback argument must be a function\n*\n* @example\n* var resolve = require( 'path' ).resolve;\n*\n* readJSON( resolve( __dirname, '..', 'package.json' ), onJSON );\n*\n* function onJSON( error, data ) {\n* if ( error ) {\n* throw error;\n* }\n* console.dir( data );\n* }\n*/\nfunction readJSON( file, options, clbk ) {\n\tvar opts;\n\tvar done;\n\tif ( arguments.length < 3 ) {\n\t\topts = {};\n\t\tdone = options;\n\t} else {\n\t\tif ( isString( options ) ) {\n\t\t\topts = {\n\t\t\t\t'encoding': options\n\t\t\t};\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be either a string or an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = options;\n\t\t}\n\t\tdone = clbk;\n\t}\n\tif ( !isFunction( done ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', done ) );\n\t}\n\treadFile( file, opts, onRead );\n\n\t/**\n\t* Callback invoked upon reading a file.\n\t*\n\t* @private\n\t* @param {(Error|null)} error - error object\n\t* @param {(Buffer|string)} file - file contents\n\t* @returns {void}\n\t*/\n\tfunction onRead( error, file ) {\n\t\tif ( error ) {\n\t\t\treturn done( error );\n\t\t}\n\t\tfile = file.toString();\n\t\tif ( opts.encoding === 'utf8' ) {\n\t\t\tfile = removeBOM( file );\n\t\t}\n\t\tif ( opts.reviver ) {\n\t\t\tfile = parseJSON( file, opts.reviver );\n\t\t} else {\n\t\t\tfile = parseJSON( file );\n\t\t}\n\t\tif ( instanceOf( file, Error ) ) {\n\t\t\treturn done( file );\n\t\t}\n\t\tdone( null, file );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = readJSON;\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 isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar readFile = require( '@stdlib/fs-read-file' ).sync;\nvar removeBOM = require( '@stdlib/string-remove-utf8-bom' );\nvar parseJSON = require( '@stdlib/utils-parse-json' );\nvar instanceOf = require( '@stdlib/assert-instance-of' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Synchronously reads a file as JSON.\n*\n* @param {(string|Buffer|integer)} file - file path or file descriptor\n* @param {(Options|string)} [options] - options\n* @param {(string|null)} [options.encoding] - file encoding\n* @param {string} [options.flag] - file status flag\n* @param {Function} [options.reviver] - JSON reviver\n* @throws {TypeError} options argument must be either a string or an object\n* @returns {(JSON|Error)} JSON or an error\n*\n* @example\n* var resolve = require( 'path' ).resolve;\n* var instanceOf = require( '@stdlib/assert-instance-of' );\n*\n* var out = readJSONSync( resolve( __dirname, '..', 'package.json' ) );\n* if ( instanceOf( out, Error ) ) {\n* throw out;\n* }\n* console.dir( out );\n*/\nfunction readJSONSync( file, options ) {\n\tvar opts;\n\tvar f;\n\tif ( arguments.length > 1 ) {\n\t\tif ( isString( options ) ) {\n\t\t\topts = {\n\t\t\t\t'encoding': options\n\t\t\t};\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be either a string or an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = options;\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\tf = readFile( file, opts );\n\tif ( instanceOf( f, Error ) ) {\n\t\treturn f;\n\t}\n\tf = f.toString();\n\tif ( opts.encoding === 'utf8' ) {\n\t\tf = removeBOM( f );\n\t}\n\tif ( opts.reviver ) {\n\t\treturn parseJSON( f, opts.reviver );\n\t}\n\treturn parseJSON( f );\n}\n\n\n// EXPORTS //\n\nmodule.exports = readJSONSync;\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* Read a file as JSON.\n*\n* @module @stdlib/fs-read-json\n*\n* @example\n* var resolve = require( 'path' ).resolve;\n* var readJSON = require( '@stdlib/fs-read-json' );\n*\n* function onJSON( error, data ) {\n* if ( error ) {\n* throw error;\n* }\n* console.dir( data );\n* }\n*\n* readJSON( resolve( __dirname, '..', 'package.json' ), onJSON );\n*\n* @example\n* var resolve = require( 'path' ).resolve;\n* var instanceOf = require( '@stdlib/assert-instance-of' );\n* var readJSON = require( '@stdlib/fs-read-json' );\n*\n* var out = readJSON.sync( resolve( __dirname, '..', 'package.json' ) );\n* if ( instanceOf( out, Error ) ) {\n* throw out;\n* }\n* console.dir( out );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar readJSON = require( './async.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( readJSON, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = readJSON;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,sBAAuB,EAC3CC,EAAY,QAAS,gCAAiC,EACtDC,EAAY,QAAS,0BAA2B,EAChDC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EA6B9C,SAASC,EAAUC,EAAMC,EAASC,EAAO,CACxC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EACvBD,EAAO,CAAC,EACRC,EAAOH,MACD,CACN,GAAKV,EAAUU,CAAQ,EACtBE,EAAO,CACN,SAAYF,CACb,MACM,CACN,GAAK,CAACT,EAAUS,CAAQ,EACvB,MAAM,IAAI,UAAWH,EAAQ,wFAAyFG,CAAQ,CAAE,EAEjIE,EAAOF,CACR,CACAG,EAAOF,CACR,CACA,GAAK,CAACT,EAAYW,CAAK,EACtB,MAAM,IAAI,UAAWN,EAAQ,uEAAwEM,CAAK,CAAE,EAE7GV,EAAUM,EAAMG,EAAME,CAAO,EAU7B,SAASA,EAAQC,EAAON,EAAO,CAC9B,GAAKM,EACJ,OAAOF,EAAME,CAAM,EAWpB,GATAN,EAAOA,EAAK,SAAS,EAChBG,EAAK,WAAa,SACtBH,EAAOL,EAAWK,CAAK,GAEnBG,EAAK,QACTH,EAAOJ,EAAWI,EAAMG,EAAK,OAAQ,EAErCH,EAAOJ,EAAWI,CAAK,EAEnBH,EAAYG,EAAM,KAAM,EAC5B,OAAOI,EAAMJ,CAAK,EAEnBI,EAAM,KAAMJ,CAAK,CAClB,CACD,CAKAV,EAAO,QAAUS,ICjHjB,IAAAQ,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,gCAAiC,EACrDC,EAAW,QAAS,sBAAuB,EAAE,KAC7CC,EAAY,QAAS,gCAAiC,EACtDC,EAAY,QAAS,0BAA2B,EAChDC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAcC,EAAMC,EAAU,CACtC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EACvB,GAAKX,EAAUS,CAAQ,EACtBC,EAAO,CACN,SAAYD,CACb,MACM,CACN,GAAK,CAACR,EAAUQ,CAAQ,EACvB,MAAM,IAAI,UAAWH,EAAQ,wFAAyFG,CAAQ,CAAE,EAEjIC,EAAOD,CACR,MAEAC,EAAO,CAAC,EAGT,OADAC,EAAIT,EAAUM,EAAME,CAAK,EACpBL,EAAYM,EAAG,KAAM,EAClBA,GAERA,EAAIA,EAAE,SAAS,EACVD,EAAK,WAAa,SACtBC,EAAIR,EAAWQ,CAAE,GAEbD,EAAK,QACFN,EAAWO,EAAGD,EAAK,OAAQ,EAE5BN,EAAWO,CAAE,EACrB,CAKAZ,EAAO,QAAUQ,ICpCjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,IACXC,EAAO,IAKXF,EAAaC,EAAU,OAAQC,CAAK,EAKpC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_async", "__commonJSMin", "exports", "module", "isString", "isObject", "isFunction", "readFile", "removeBOM", "parseJSON", "instanceOf", "format", "readJSON", "file", "options", "clbk", "opts", "done", "onRead", "error", "require_sync", "__commonJSMin", "exports", "module", "isString", "isObject", "readFile", "removeBOM", "parseJSON", "instanceOf", "format", "readJSONSync", "file", "options", "opts", "f", "setReadOnly", "readJSON", "sync"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
package/lib/async.js
CHANGED
|
@@ -27,6 +27,7 @@ var readFile = require( '@stdlib/fs-read-file' );
|
|
|
27
27
|
var removeBOM = require( '@stdlib/string-remove-utf8-bom' );
|
|
28
28
|
var parseJSON = require( '@stdlib/utils-parse-json' );
|
|
29
29
|
var instanceOf = require( '@stdlib/assert-instance-of' );
|
|
30
|
+
var format = require( '@stdlib/string-format' );
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
// MAIN //
|
|
@@ -68,14 +69,14 @@ function readJSON( file, options, clbk ) {
|
|
|
68
69
|
};
|
|
69
70
|
} else {
|
|
70
71
|
if ( !isObject( options ) ) {
|
|
71
|
-
throw new TypeError( 'invalid argument. Options argument must be either a string or an object. Value:
|
|
72
|
+
throw new TypeError( format( 'invalid argument. Options argument must be either a string or an object. Value: `%s`.', options ) );
|
|
72
73
|
}
|
|
73
74
|
opts = options;
|
|
74
75
|
}
|
|
75
76
|
done = clbk;
|
|
76
77
|
}
|
|
77
78
|
if ( !isFunction( done ) ) {
|
|
78
|
-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value:
|
|
79
|
+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', done ) );
|
|
79
80
|
}
|
|
80
81
|
readFile( file, opts, onRead );
|
|
81
82
|
|
package/lib/sync.js
CHANGED
|
@@ -26,6 +26,7 @@ var readFile = require( '@stdlib/fs-read-file' ).sync;
|
|
|
26
26
|
var removeBOM = require( '@stdlib/string-remove-utf8-bom' );
|
|
27
27
|
var parseJSON = require( '@stdlib/utils-parse-json' );
|
|
28
28
|
var instanceOf = require( '@stdlib/assert-instance-of' );
|
|
29
|
+
var format = require( '@stdlib/string-format' );
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
// MAIN //
|
|
@@ -61,7 +62,7 @@ function readJSONSync( file, options ) {
|
|
|
61
62
|
};
|
|
62
63
|
} else {
|
|
63
64
|
if ( !isObject( options ) ) {
|
|
64
|
-
throw new TypeError( 'invalid argument. Options argument must be either a string or an object. Value:
|
|
65
|
+
throw new TypeError( format( 'invalid argument. Options argument must be either a string or an object. Value: `%s`.', options ) );
|
|
65
66
|
}
|
|
66
67
|
opts = options;
|
|
67
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/fs-read-json",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Read a file as JSON.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,22 +37,24 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-instance-of": "^0.0
|
|
41
|
-
"@stdlib/assert-is-function": "^0.0
|
|
42
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
43
|
-
"@stdlib/assert-is-string": "^0.0
|
|
44
|
-
"@stdlib/fs-read-file": "^0.0
|
|
45
|
-
"@stdlib/string-
|
|
46
|
-
"@stdlib/
|
|
47
|
-
"@stdlib/utils-
|
|
40
|
+
"@stdlib/assert-instance-of": "^0.1.0",
|
|
41
|
+
"@stdlib/assert-is-function": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-plain-object": "^0.1.0",
|
|
43
|
+
"@stdlib/assert-is-string": "^0.1.0",
|
|
44
|
+
"@stdlib/fs-read-file": "^0.1.0",
|
|
45
|
+
"@stdlib/string-format": "^0.1.0",
|
|
46
|
+
"@stdlib/string-remove-utf8-bom": "^0.1.0",
|
|
47
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
|
|
48
|
+
"@stdlib/utils-parse-json": "^0.1.0",
|
|
49
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@stdlib/assert-is-browser": "^0.0
|
|
51
|
-
"@stdlib/bench": "^0.0
|
|
52
|
-
"@stdlib/utils-noop": "^0.0
|
|
52
|
+
"@stdlib/assert-is-browser": "^0.1.0",
|
|
53
|
+
"@stdlib/bench": "^0.1.0",
|
|
54
|
+
"@stdlib/utils-noop": "^0.1.0",
|
|
53
55
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
54
56
|
"istanbul": "^0.4.1",
|
|
55
|
-
"tap-
|
|
57
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
56
58
|
},
|
|
57
59
|
"engines": {
|
|
58
60
|
"node": ">=0.10.0",
|
|
@@ -85,7 +87,7 @@
|
|
|
85
87
|
"json"
|
|
86
88
|
],
|
|
87
89
|
"funding": {
|
|
88
|
-
"type": "
|
|
89
|
-
"url": "https://
|
|
90
|
+
"type": "opencollective",
|
|
91
|
+
"url": "https://opencollective.com/stdlib"
|
|
90
92
|
}
|
|
91
93
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( file[, options], clbk )
|
|
3
|
-
Asynchronously reads a file as JSON.
|
|
4
|
-
|
|
5
|
-
Parameters
|
|
6
|
-
----------
|
|
7
|
-
file: string|Buffer|integer
|
|
8
|
-
Filename or file descriptor.
|
|
9
|
-
|
|
10
|
-
options: Object|string (optional)
|
|
11
|
-
Options. If a string, the value is the encoding.
|
|
12
|
-
|
|
13
|
-
options.encoding: string|null (optional)
|
|
14
|
-
Encoding. If the encoding option is set to `utf8` and the file has a
|
|
15
|
-
UTF-8 byte order mark (BOM), the byte order mark is *removed* before
|
|
16
|
-
attempting to parse as JSON. Default: null.
|
|
17
|
-
|
|
18
|
-
options.flag: string (optional)
|
|
19
|
-
Flag. Default: 'r'.
|
|
20
|
-
|
|
21
|
-
options.reviver: Function (optional)
|
|
22
|
-
JSON transformation function.
|
|
23
|
-
|
|
24
|
-
clbk: Function
|
|
25
|
-
Callback to invoke upon reading file contents.
|
|
26
|
-
|
|
27
|
-
Examples
|
|
28
|
-
--------
|
|
29
|
-
> function onRead( error, data ) {
|
|
30
|
-
... if ( error ) {
|
|
31
|
-
... console.error( error.message );
|
|
32
|
-
... } else {
|
|
33
|
-
... console.log( data );
|
|
34
|
-
... }
|
|
35
|
-
... };
|
|
36
|
-
> {{alias}}( './beep/boop.json', onRead );
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{{alias}}.sync( file[, options] )
|
|
40
|
-
Synchronously reads a file as JSON.
|
|
41
|
-
|
|
42
|
-
Parameters
|
|
43
|
-
----------
|
|
44
|
-
file: string|Buffer|integer
|
|
45
|
-
Filename or file descriptor.
|
|
46
|
-
|
|
47
|
-
options: Object|string (optional)
|
|
48
|
-
Options. If a string, the value is the encoding.
|
|
49
|
-
|
|
50
|
-
options.encoding: string|null (optional)
|
|
51
|
-
Encoding. If the encoding option is set to `utf8` and the file has a
|
|
52
|
-
UTF-8 byte order mark (BOM), the byte order mark is *removed* before
|
|
53
|
-
attempting to parse as JSON. Default: null.
|
|
54
|
-
|
|
55
|
-
options.flag: string (optional)
|
|
56
|
-
Flag. Default: 'r'.
|
|
57
|
-
|
|
58
|
-
options.reviver: Function (optional)
|
|
59
|
-
JSON transformation function.
|
|
60
|
-
|
|
61
|
-
Returns
|
|
62
|
-
-------
|
|
63
|
-
out: Error|JSON
|
|
64
|
-
File contents.
|
|
65
|
-
|
|
66
|
-
Examples
|
|
67
|
-
--------
|
|
68
|
-
> var out = {{alias}}.sync( './beep/boop.json' );
|
|
69
|
-
|
|
70
|
-
See Also
|
|
71
|
-
--------
|
|
72
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020 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 readJSON = require( './index' );
|
|
20
|
-
|
|
21
|
-
const onLoad = ( error: Error | null, file: string | Buffer ) => {
|
|
22
|
-
if ( error || !file ) {
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// TESTS //
|
|
29
|
-
|
|
30
|
-
// The function does not have a return value...
|
|
31
|
-
{
|
|
32
|
-
readJSON( 'package.json', onLoad ); // $ExpectType void
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// The compiler throws an error if the function is provided a first argument which is not a string, buffer, or file descriptor...
|
|
36
|
-
{
|
|
37
|
-
readJSON( false, onLoad ); // $ExpectError
|
|
38
|
-
readJSON( true, onLoad ); // $ExpectError
|
|
39
|
-
readJSON( null, onLoad ); // $ExpectError
|
|
40
|
-
readJSON( undefined, onLoad ); // $ExpectError
|
|
41
|
-
readJSON( [], onLoad ); // $ExpectError
|
|
42
|
-
readJSON( {}, onLoad ); // $ExpectError
|
|
43
|
-
readJSON( ( x: number ): number => x, onLoad ); // $ExpectError
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// The compiler throws an error if the function is provided a callback argument which is not a function with the expected signature...
|
|
47
|
-
{
|
|
48
|
-
readJSON( '/path/to/package.json', 'abc' ); // $ExpectError
|
|
49
|
-
readJSON( '/path/to/package.json', 1 ); // $ExpectError
|
|
50
|
-
readJSON( '/path/to/package.json', false ); // $ExpectError
|
|
51
|
-
readJSON( '/path/to/package.json', true ); // $ExpectError
|
|
52
|
-
readJSON( '/path/to/package.json', null ); // $ExpectError
|
|
53
|
-
readJSON( '/path/to/package.json', undefined ); // $ExpectError
|
|
54
|
-
readJSON( '/path/to/package.json', [] ); // $ExpectError
|
|
55
|
-
readJSON( '/path/to/package.json', {} ); // $ExpectError
|
|
56
|
-
readJSON( '/path/to/package.json', ( x: number ): number => x ); // $ExpectError
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// The compiler throws an error if the function is provided an options argument which is not an object or string...
|
|
60
|
-
{
|
|
61
|
-
readJSON( 'package.json', false, onLoad ); // $ExpectError
|
|
62
|
-
readJSON( 'package.json', true, onLoad ); // $ExpectError
|
|
63
|
-
readJSON( 'package.json', null, onLoad ); // $ExpectError
|
|
64
|
-
readJSON( 'package.json', undefined, onLoad ); // $ExpectError
|
|
65
|
-
readJSON( 'package.json', 123, onLoad ); // $ExpectError
|
|
66
|
-
readJSON( 'package.json', [], onLoad ); // $ExpectError
|
|
67
|
-
readJSON( 'package.json', ( x: number ): number => x, onLoad ); // $ExpectError
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// The compiler throws an error if the function is provided an `encoding` option which is not a string or null...
|
|
71
|
-
{
|
|
72
|
-
readJSON( 'package.json', { 'encoding': 123 }, onLoad ); // $ExpectError
|
|
73
|
-
readJSON( 'package.json', { 'encoding': true }, onLoad ); // $ExpectError
|
|
74
|
-
readJSON( 'package.json', { 'encoding': false }, onLoad ); // $ExpectError
|
|
75
|
-
readJSON( 'package.json', { 'encoding': [] }, onLoad ); // $ExpectError
|
|
76
|
-
readJSON( 'package.json', { 'encoding': {} }, onLoad ); // $ExpectError
|
|
77
|
-
readJSON( 'package.json', { 'encoding': ( x: number ): number => x }, onLoad ); // $ExpectError
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// The compiler throws an error if the function is provided a `flag` option which is not a string...
|
|
81
|
-
{
|
|
82
|
-
readJSON( 'package.json', { 'flag': 123 }, onLoad ); // $ExpectError
|
|
83
|
-
readJSON( 'package.json', { 'flag': true }, onLoad ); // $ExpectError
|
|
84
|
-
readJSON( 'package.json', { 'flag': false }, onLoad ); // $ExpectError
|
|
85
|
-
readJSON( 'package.json', { 'flag': null }, onLoad ); // $ExpectError
|
|
86
|
-
readJSON( 'package.json', { 'flag': [] }, onLoad ); // $ExpectError
|
|
87
|
-
readJSON( 'package.json', { 'flag': {} }, onLoad ); // $ExpectError
|
|
88
|
-
readJSON( 'package.json', { 'flag': ( x: number ): number => x }, onLoad ); // $ExpectError
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// The compiler throws an error if the function is provided a `reviver` option which is not a function...
|
|
92
|
-
{
|
|
93
|
-
readJSON( 'package.json', { 'reviver': 123 }, onLoad ); // $ExpectError
|
|
94
|
-
readJSON( 'package.json', { 'reviver': 'abc' }, onLoad ); // $ExpectError
|
|
95
|
-
readJSON( 'package.json', { 'reviver': true }, onLoad ); // $ExpectError
|
|
96
|
-
readJSON( 'package.json', { 'reviver': false }, onLoad ); // $ExpectError
|
|
97
|
-
readJSON( 'package.json', { 'reviver': null }, onLoad ); // $ExpectError
|
|
98
|
-
readJSON( 'package.json', { 'reviver': [] }, onLoad ); // $ExpectError
|
|
99
|
-
readJSON( 'package.json', { 'reviver': {} }, onLoad ); // $ExpectError
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
103
|
-
{
|
|
104
|
-
readJSON(); // $ExpectError
|
|
105
|
-
readJSON( 'C:\\foo\\bar\\baz\\package.json' ); // $ExpectError
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Attached to main export is a `sync` method which returns a string or an error...
|
|
109
|
-
{
|
|
110
|
-
readJSON.sync( 'package.json' ); // $ExpectType string | Error
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// The compiler throws an error if the `sync` method is provided a first argument which is not a string, buffer, or file descriptor...
|
|
114
|
-
{
|
|
115
|
-
readJSON.sync( false ); // $ExpectError
|
|
116
|
-
readJSON.sync( true ); // $ExpectError
|
|
117
|
-
readJSON.sync( null ); // $ExpectError
|
|
118
|
-
readJSON.sync( undefined ); // $ExpectError
|
|
119
|
-
readJSON.sync( [] ); // $ExpectError
|
|
120
|
-
readJSON.sync( {} ); // $ExpectError
|
|
121
|
-
readJSON.sync( ( x: number ): number => x ); // $ExpectError
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// The compiler throws an error if the `sync` method is provided an options argument which is not an object or string...
|
|
125
|
-
{
|
|
126
|
-
readJSON.sync( 'package.json', null ); // $ExpectError
|
|
127
|
-
readJSON.sync( 'package.json', true ); // $ExpectError
|
|
128
|
-
readJSON.sync( 'package.json', false ); // $ExpectError
|
|
129
|
-
readJSON.sync( 'package.json', 123 ); // $ExpectError
|
|
130
|
-
readJSON.sync( 'package.json', [] ); // $ExpectError
|
|
131
|
-
readJSON.sync( 'package.json', ( x: number ): number => x ); // $ExpectError
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// The compiler throws an error if the `sync` method is provided an `encoding` option which is not a string or null...
|
|
135
|
-
{
|
|
136
|
-
readJSON.sync( 'package.json', { 'encoding': 123 } ); // $ExpectError
|
|
137
|
-
readJSON.sync( 'package.json', { 'encoding': true } ); // $ExpectError
|
|
138
|
-
readJSON.sync( 'package.json', { 'encoding': false } ); // $ExpectError
|
|
139
|
-
readJSON.sync( 'package.json', { 'encoding': [] } ); // $ExpectError
|
|
140
|
-
readJSON.sync( 'package.json', { 'encoding': {} } ); // $ExpectError
|
|
141
|
-
readJSON.sync( 'package.json', { 'encoding': ( x: number ): number => x } ); // $ExpectError
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// The compiler throws an error if the `sync` method is provided a `flag` option which is not a string...
|
|
145
|
-
{
|
|
146
|
-
readJSON.sync( 'package.json', { 'flag': 123 } ); // $ExpectError
|
|
147
|
-
readJSON.sync( 'package.json', { 'flag': true } ); // $ExpectError
|
|
148
|
-
readJSON.sync( 'package.json', { 'flag': false } ); // $ExpectError
|
|
149
|
-
readJSON.sync( 'package.json', { 'flag': null } ); // $ExpectError
|
|
150
|
-
readJSON.sync( 'package.json', { 'flag': [] } ); // $ExpectError
|
|
151
|
-
readJSON.sync( 'package.json', { 'flag': {} } ); // $ExpectError
|
|
152
|
-
readJSON.sync( 'package.json', { 'flag': ( x: number ): number => x } ); // $ExpectError
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// The compiler throws an error if the `sync` method is provided a `reviver` option which is not a function...
|
|
156
|
-
{
|
|
157
|
-
readJSON.sync( 'package.json', { 'reviver': 'abc' } ); // $ExpectError
|
|
158
|
-
readJSON.sync( 'package.json', { 'reviver': 123 } ); // $ExpectError
|
|
159
|
-
readJSON.sync( 'package.json', { 'reviver': true } ); // $ExpectError
|
|
160
|
-
readJSON.sync( 'package.json', { 'reviver': false } ); // $ExpectError
|
|
161
|
-
readJSON.sync( 'package.json', { 'reviver': null } ); // $ExpectError
|
|
162
|
-
readJSON.sync( 'package.json', { 'reviver': [] } ); // $ExpectError
|
|
163
|
-
readJSON.sync( 'package.json', { 'reviver': {} } ); // $ExpectError
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// The compiler throws an error if the `sync` method is provided an unsupported number of arguments...
|
|
167
|
-
{
|
|
168
|
-
readJSON.sync(); // $ExpectError
|
|
169
|
-
}
|