@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.23 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"./define-nonenumerable-read-only-property.js";import t from"./../assert/is-object-like.js";import e from"./copy.js";import i from"./../constants/math/float64-max.js";import o from"./../assert/is-plain-object.js";import n from"./../assert/has-own-property.js";import a from"./../assert/is-string.js";import p from"./../assert/is-boolean.js";import s from"./../assert/is-nonnegative-integer.js";import m from"./keys.js";import l from"./../assert/is-array.js";var f=i,u={delimiter:".",depth:f,copy:!1},y=o,d=n,v=a.isPrimitive,c=p.isPrimitive,h=s.isPrimitive;function j(r,t){return y(t)?d(t,"depth")&&(r.depth=t.depth,!h(r.depth))?new TypeError("invalid option. `depth` option must be a nonnegative integer. Option: `"+r.depth+"`."):d(t,"copy")&&(r.copy=t.copy,!c(r.copy))?new TypeError("invalid option. `copy` option must be a boolean primitive. Option: `"+r.copy+"`."):d(t,"flattenArrays")&&(r.flattenArrays=t.flattenArrays,!c(r.flattenArrays))?new TypeError("invalid option. `flattenArrays` option must be a boolean primitive. Option: `"+r.flattenArrays+"`."):d(t,"delimiter")&&(r.delimiter=t.delimiter,!v(r.delimiter))?new TypeError("invalid option. `delimiter` option must be a string primitive. Option: `"+r.delimiter+"`."):null:new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.")}var b=m,g=o,w=l;function A(r,t,e,i,o){var n,a,p,s;for(e&&(e+=o.delimiter),n=b(t),s=0;s<n.length;s++)a=t[n[s]],p=e+n[s],i&&(g(a)&&b(a).length||o.flattenArrays&&w(a))?A(r,a,p,i-1,o):r[p]=a;return r}var E=e,T=A;function O(r,t){var e;return e=0===t.depth?r:T({},r,"",t.depth,t),t.copy?E(e):e}var k=t,P=e,V=u,x=j,F=O;function M(r,t){var e,i;if(!k(r))throw new TypeError("invalid argument. First argument must be object-like. Value: `"+r+"`.");if(e=P(V),arguments.length>1&&(i=x(e,t)))throw i;return F(r,e)}var q=t,z=e,B=u,C=j,D=O;function G(r){var t,e;if(t=z(B),e=C(t,r))throw e;return function(r){if(!q(r))throw new TypeError("invalid argument. Must provide an object-like value. Value: `"+r+"`.");return D(r,t)}}var H=r,I=M,J=G;H(I,"factory",J);export default I;
//# sourceMappingURL=flatten-object.js.map