@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 1.42 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./../utils/define-nonenumerable-read-only-property.js";import e from"./../assert/is-string.js";import i from"./../assert/is-plain-object.js";import t from"./../assert/is-function.js";import n from"./read-file.js";import o from"./../string/remove-utf8-bom.js";import s from"./../utils/parse-json.js";import a from"./../assert/instance-of.js";var m=e.isPrimitive,f=i,u=t,l=n,v=o,g=s,p=a;function c(r,e,i){var t,n;if(arguments.length<3)t={},n=e;else{if(m(e))t={encoding:e};else{if(!f(e))throw new TypeError("invalid argument. Options argument must be either a string or an object. Value: `"+e+"`.");t=e}n=i}if(!u(n))throw new TypeError("invalid argument. Callback argument must be a function. Value: `"+n+"`.");function o(r,e){return r?n(r):(e=e.toString(),"utf8"===t.encoding&&(e=v(e)),e=t.reviver?g(e,t.reviver):g(e),p(e,Error)?n(e):void n(null,e))}l(r,t,o)}var d=e.isPrimitive,j=i,b=n.sync,h=o,y=s,w=a;function E(r,e){var i,t;if(arguments.length>1)if(d(e))i={encoding:e};else{if(!j(e))throw new TypeError("invalid argument. Options argument must be either a string or an object. Value: `"+e+"`.");i=e}else i={};return t=b(r,i),w(t,Error)?t:(t=t.toString(),"utf8"===i.encoding&&(t=h(t)),i.reviver?y(t,i.reviver):y(t))}var T=r,V=c,O=E;T(V,"sync",O);export default V;
//# sourceMappingURL=read-json.js.map