object-set-all-values-to 5.0.5 → 5.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +4 -5
- package/dist/object-set-all-values-to.esm.js +2 -36
- package/dist/object-set-all-values-to.umd.js +2 -2
- package/examples/_quickTake.js +1 -0
- package/package.json +24 -80
- package/types/index.d.ts +1 -1
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `4.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i object-set-all-values-to
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 4.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { setAllValuesTo } from "object-set-all-values-to";
|
|
42
41
|
|
|
43
42
|
assert.deepEqual(
|
|
@@ -77,7 +76,7 @@ assert.deepEqual(
|
|
|
77
76
|
|
|
78
77
|
## Documentation
|
|
79
78
|
|
|
80
|
-
Please [visit codsen.com](https://codsen.com/os/object-set-all-values-to/) for a full description of the API
|
|
79
|
+
Please [visit codsen.com](https://codsen.com/os/object-set-all-values-to/) for a full description of the API.
|
|
81
80
|
|
|
82
81
|
## Contributing
|
|
83
82
|
|
|
@@ -87,6 +86,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
87
86
|
|
|
88
87
|
MIT License
|
|
89
88
|
|
|
90
|
-
Copyright (c) 2010-
|
|
89
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
91
90
|
|
|
92
91
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
@@ -1,44 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-set-all-values-to
|
|
3
3
|
* @fileoverview Recursively walk the input and set all found values in plain objects to something
|
|
4
|
-
* @version 5.0.
|
|
4
|
+
* @version 5.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-set-all-values-to/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import isObj from 'lodash.isplainobject';
|
|
12
|
-
|
|
13
|
-
var version$1 = "5.0.5";
|
|
14
|
-
|
|
15
|
-
const version = version$1;
|
|
16
|
-
function setAllValuesTo(inputOriginal, valueOriginal) {
|
|
17
|
-
let value;
|
|
18
|
-
const input = clone(inputOriginal);
|
|
19
|
-
if (arguments.length < 2) {
|
|
20
|
-
value = false;
|
|
21
|
-
} else if (isObj(valueOriginal) || Array.isArray(valueOriginal)) {
|
|
22
|
-
value = clone(valueOriginal);
|
|
23
|
-
} else {
|
|
24
|
-
value = valueOriginal;
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(input)) {
|
|
27
|
-
input.forEach((_el, i) => {
|
|
28
|
-
if (isObj(input[i]) || Array.isArray(input[i])) {
|
|
29
|
-
input[i] = setAllValuesTo(input[i], value);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
} else if (isObj(input)) {
|
|
33
|
-
Object.keys(input).forEach(key => {
|
|
34
|
-
if (Array.isArray(input[key]) || isObj(input[key])) {
|
|
35
|
-
input[key] = setAllValuesTo(input[key], value);
|
|
36
|
-
} else {
|
|
37
|
-
input[key] = value;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return input;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { setAllValuesTo, version };
|
|
10
|
+
import i from"lodash.clonedeep";import n from"lodash.isplainobject";var l="5.0.11";var h=l;function a(c,r){let t,e=i(c);return arguments.length<2?t=!1:n(r)||Array.isArray(r)?t=i(r):t=r,Array.isArray(e)?e.forEach((s,o)=>{(n(e[o])||Array.isArray(e[o]))&&(e[o]=a(e[o],t))}):n(e)&&Object.keys(e).forEach(s=>{Array.isArray(e[s])||n(e[s])?e[s]=a(e[s],t):e[s]=t}),e}export{a as setAllValuesTo,h as version};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-set-all-values-to
|
|
3
3
|
* @fileoverview Recursively walk the input and set all found values in plain objects to something
|
|
4
|
-
* @version 5.0.
|
|
4
|
+
* @version 5.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-set-all-values-to/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).objectSetAllValuesTo={})}(this,(function(t){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e={exports:{}};!function(t,e){var n="__lodash_hash_undefined__",o=9007199254740991,c="[object Arguments]",u="[object Boolean]",a="[object Date]",i="[object Function]",f="[object GeneratorFunction]",s="[object Map]",l="[object Number]",p="[object Object]",y="[object Promise]",_="[object RegExp]",h="[object Set]",v="[object String]",b="[object Symbol]",d="[object WeakMap]",j="[object ArrayBuffer]",g="[object DataView]",w="[object Float32Array]",O="[object Float64Array]",A="[object Int8Array]",m="[object Int16Array]",x="[object Int32Array]",S="[object Uint8Array]",P="[object Uint8ClampedArray]",E="[object Uint16Array]",T="[object Uint32Array]",$=/\w*$/,F=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,k={};k[c]=k["[object Array]"]=k[j]=k[g]=k[u]=k[a]=k[w]=k[O]=k[A]=k[m]=k[x]=k[s]=k[l]=k[p]=k[_]=k[h]=k[v]=k[b]=k[S]=k[P]=k[E]=k[T]=!0,k["[object Error]"]=k[i]=k[d]=!1;var B="object"==typeof self&&self&&self.Object===Object&&self,M="object"==typeof r&&r&&r.Object===Object&&r||B||Function("return this")(),U=e&&!e.nodeType&&e,V=U&&t&&!t.nodeType&&t,D=V&&V.exports===U;function R(t,r){return t.set(r[0],r[1]),t}function z(t,r){return t.add(r),t}function C(t,r,e,n){var o=-1,c=t?t.length:0;for(n&&c&&(e=t[++o]);++o<c;)e=r(e,t[o],o,t);return e}function L(t){var r=!1;if(null!=t&&"function"!=typeof t.toString)try{r=!!(t+"")}catch(t){}return r}function W(t){var r=-1,e=Array(t.size);return t.forEach((function(t,n){e[++r]=[n,t]})),e}function G(t,r){return function(e){return t(r(e))}}function N(t){var r=-1,e=Array(t.size);return t.forEach((function(t){e[++r]=t})),e}var q,H=Array.prototype,J=Function.prototype,K=Object.prototype,Q=M["__core-js_shared__"],X=(q=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"",Y=J.toString,Z=K.hasOwnProperty,tt=K.toString,rt=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),et=D?M.Buffer:void 0,nt=M.Symbol,ot=M.Uint8Array,ct=G(Object.getPrototypeOf,Object),ut=Object.create,at=K.propertyIsEnumerable,it=H.splice,ft=Object.getOwnPropertySymbols,st=et?et.isBuffer:void 0,lt=G(Object.keys,Object),pt=Vt(M,"DataView"),yt=Vt(M,"Map"),_t=Vt(M,"Promise"),ht=Vt(M,"Set"),vt=Vt(M,"WeakMap"),bt=Vt(Object,"create"),dt=Lt(pt),jt=Lt(yt),gt=Lt(_t),wt=Lt(ht),Ot=Lt(vt),At=nt?nt.prototype:void 0,mt=At?At.valueOf:void 0;function xt(t){var r=-1,e=t?t.length:0;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function St(t){var r=-1,e=t?t.length:0;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function Pt(t){var r=-1,e=t?t.length:0;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function Et(t){this.__data__=new St(t)}function Tt(t,r){var e=Gt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Nt(t)}(t)&&Z.call(t,"callee")&&(!at.call(t,"callee")||tt.call(t)==c)}(t)?function(t,r){for(var e=-1,n=Array(t);++e<t;)n[e]=r(e);return n}(t.length,String):[],n=e.length,o=!!n;for(var u in t)!r&&!Z.call(t,u)||o&&("length"==u||zt(u,n))||e.push(u);return e}function $t(t,r,e){var n=t[r];Z.call(t,r)&&Wt(n,e)&&(void 0!==e||r in t)||(t[r]=e)}function Ft(t,r){for(var e=t.length;e--;)if(Wt(t[e][0],r))return e;return-1}function It(t,r,e,n,o,y,d){var F;if(n&&(F=y?n(t,o,y,d):n(t)),void 0!==F)return F;if(!Jt(t))return t;var I=Gt(t);if(I){if(F=function(t){var r=t.length,e=t.constructor(r);r&&"string"==typeof t[0]&&Z.call(t,"index")&&(e.index=t.index,e.input=t.input);return e}(t),!r)return function(t,r){var e=-1,n=t.length;r||(r=Array(n));for(;++e<n;)r[e]=t[e];return r}(t,F)}else{var B=Rt(t),M=B==i||B==f;if(qt(t))return function(t,r){if(r)return t.slice();var e=new t.constructor(t.length);return t.copy(e),e}(t,r);if(B==p||B==c||M&&!y){if(L(t))return y?t:{};if(F=function(t){return"function"!=typeof t.constructor||Ct(t)?{}:(r=ct(t),Jt(r)?ut(r):{});var r}(M?{}:t),!r)return function(t,r){return Mt(t,Dt(t),r)}(t,function(t,r){return t&&Mt(r,Kt(r),t)}(F,t))}else{if(!k[B])return y?t:{};F=function(t,r,e,n){var o=t.constructor;switch(r){case j:return Bt(t);case u:case a:return new o(+t);case g:return function(t,r){var e=r?Bt(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}(t,n);case w:case O:case A:case m:case x:case S:case P:case E:case T:return function(t,r){var e=r?Bt(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t,n);case s:return function(t,r,e){return C(r?e(W(t),!0):W(t),R,new t.constructor)}(t,n,e);case l:case v:return new o(t);case _:return function(t){var r=new t.constructor(t.source,$.exec(t));return r.lastIndex=t.lastIndex,r}(t);case h:return function(t,r,e){return C(r?e(N(t),!0):N(t),z,new t.constructor)}(t,n,e);case b:return c=t,mt?Object(mt.call(c)):{}}var c}(t,B,It,r)}}d||(d=new Et);var U=d.get(t);if(U)return U;if(d.set(t,F),!I)var V=e?function(t){return function(t,r,e){var n=r(t);return Gt(t)?n:function(t,r){for(var e=-1,n=r.length,o=t.length;++e<n;)t[o+e]=r[e];return t}(n,e(t))}(t,Kt,Dt)}(t):Kt(t);return function(t,r){for(var e=-1,n=t?t.length:0;++e<n&&!1!==r(t[e],e,t););}(V||t,(function(o,c){V&&(o=t[c=o]),$t(F,c,It(o,r,e,n,c,t,d))})),F}function kt(t){return!(!Jt(t)||(r=t,X&&X in r))&&(Ht(t)||L(t)?rt:F).test(Lt(t));var r}function Bt(t){var r=new t.constructor(t.byteLength);return new ot(r).set(new ot(t)),r}function Mt(t,r,e,n){e||(e={});for(var o=-1,c=r.length;++o<c;){var u=r[o],a=n?n(e[u],t[u],u,e,t):void 0;$t(e,u,void 0===a?t[u]:a)}return e}function Ut(t,r){var e,n,o=t.__data__;return("string"==(n=typeof(e=r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==e:null===e)?o["string"==typeof r?"string":"hash"]:o.map}function Vt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return kt(e)?e:void 0}xt.prototype.clear=function(){this.__data__=bt?bt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var r=this.__data__;if(bt){var e=r[t];return e===n?void 0:e}return Z.call(r,t)?r[t]:void 0},xt.prototype.has=function(t){var r=this.__data__;return bt?void 0!==r[t]:Z.call(r,t)},xt.prototype.set=function(t,r){return this.__data__[t]=bt&&void 0===r?n:r,this},St.prototype.clear=function(){this.__data__=[]},St.prototype.delete=function(t){var r=this.__data__,e=Ft(r,t);return!(e<0)&&(e==r.length-1?r.pop():it.call(r,e,1),!0)},St.prototype.get=function(t){var r=this.__data__,e=Ft(r,t);return e<0?void 0:r[e][1]},St.prototype.has=function(t){return Ft(this.__data__,t)>-1},St.prototype.set=function(t,r){var e=this.__data__,n=Ft(e,t);return n<0?e.push([t,r]):e[n][1]=r,this},Pt.prototype.clear=function(){this.__data__={hash:new xt,map:new(yt||St),string:new xt}},Pt.prototype.delete=function(t){return Ut(this,t).delete(t)},Pt.prototype.get=function(t){return Ut(this,t).get(t)},Pt.prototype.has=function(t){return Ut(this,t).has(t)},Pt.prototype.set=function(t,r){return Ut(this,t).set(t,r),this},Et.prototype.clear=function(){this.__data__=new St},Et.prototype.delete=function(t){return this.__data__.delete(t)},Et.prototype.get=function(t){return this.__data__.get(t)},Et.prototype.has=function(t){return this.__data__.has(t)},Et.prototype.set=function(t,r){var e=this.__data__;if(e instanceof St){var n=e.__data__;if(!yt||n.length<199)return n.push([t,r]),this;e=this.__data__=new Pt(n)}return e.set(t,r),this};var Dt=ft?G(ft,Object):function(){return[]},Rt=function(t){return tt.call(t)};function zt(t,r){return!!(r=null==r?o:r)&&("number"==typeof t||I.test(t))&&t>-1&&t%1==0&&t<r}function Ct(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||K)}function Lt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Wt(t,r){return t===r||t!=t&&r!=r}(pt&&Rt(new pt(new ArrayBuffer(1)))!=g||yt&&Rt(new yt)!=s||_t&&Rt(_t.resolve())!=y||ht&&Rt(new ht)!=h||vt&&Rt(new vt)!=d)&&(Rt=function(t){var r=tt.call(t),e=r==p?t.constructor:void 0,n=e?Lt(e):void 0;if(n)switch(n){case dt:return g;case jt:return s;case gt:return y;case wt:return h;case Ot:return d}return r});var Gt=Array.isArray;function Nt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Ht(t)}var qt=st||function(){return!1};function Ht(t){var r=Jt(t)?tt.call(t):"";return r==i||r==f}function Jt(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}function Kt(t){return Nt(t)?Tt(t):function(t){if(!Ct(t))return lt(t);var r=[];for(var e in Object(t))Z.call(t,e)&&"constructor"!=e&&r.push(e);return r}(t)}t.exports=function(t){return It(t,!0,!0)}}(e,e.exports);var n=e.exports;var o,c,u=Object.prototype,a=Function.prototype.toString,i=u.hasOwnProperty,f=a.call(Object),s=u.toString,l=(o=Object.getPrototypeOf,c=Object,function(t){return o(c(t))});var p=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=s.call(t)||function(t){var r=!1;if(null!=t&&"function"!=typeof t.toString)try{r=!!(t+"")}catch(t){}return r}(t))return!1;var r=l(t);if(null===r)return!0;var e=i.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&a.call(e)==f};t.setAllValuesTo=function t(r,e){let o;const c=n(r);return o=!(arguments.length<2)&&(p(e)||Array.isArray(e)?n(e):e),Array.isArray(c)?c.forEach(((r,e)=>{(p(c[e])||Array.isArray(c[e]))&&(c[e]=t(c[e],o))})):p(c)&&Object.keys(c).forEach((r=>{c[r]=Array.isArray(c[r])||p(c[r])?t(c[r],o):o})),c},t.version="5.0.5",Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
10
|
+
var objectSetAllValuesTo=(()=>{var zt=Object.create;var T=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var et=t=>T(t,"__esModule",{value:!0});var rt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ne=(t,e)=>{for(var r in e)T(t,r,{get:e[r],enumerable:!0})},nt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of te(e))!re.call(t,o)&&(r||o!=="default")&&T(t,o,{get:()=>e[o],enumerable:!(n=kt(e,o))||n.enumerable});return t},ot=(t,e)=>nt(et(T(t!=null?zt(ee(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),oe=(t=>(e,r)=>t&&t.get(e)||(r=nt(et({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var qt=rt((w,j)=>{var ae=200,at="__lodash_hash_undefined__",it=9007199254740991,B="[object Arguments]",ie="[object Array]",st="[object Boolean]",ct="[object Date]",se="[object Error]",H="[object Function]",ut="[object GeneratorFunction]",S="[object Map]",ft="[object Number]",L="[object Object]",lt="[object Promise]",pt="[object RegExp]",x="[object Set]",dt="[object String]",ht="[object Symbol]",D="[object WeakMap]",gt="[object ArrayBuffer]",C="[object DataView]",yt="[object Float32Array]",bt="[object Float64Array]",_t="[object Int8Array]",jt="[object Int16Array]",vt="[object Int32Array]",mt="[object Uint8Array]",wt="[object Uint8ClampedArray]",At="[object Uint16Array]",Ot="[object Uint32Array]",ce=/[\\^$.*+?()[\]{}|]/g,ue=/\w*$/,fe=/^\[object .+?Constructor\]$/,le=/^(?:0|[1-9]\d*)$/,a={};a[B]=a[ie]=a[gt]=a[C]=a[st]=a[ct]=a[yt]=a[bt]=a[_t]=a[jt]=a[vt]=a[S]=a[ft]=a[L]=a[pt]=a[x]=a[dt]=a[ht]=a[mt]=a[wt]=a[At]=a[Ot]=!0;a[se]=a[H]=a[D]=!1;var pe=typeof global=="object"&&global&&global.Object===Object&&global,de=typeof self=="object"&&self&&self.Object===Object&&self,u=pe||de||Function("return this")(),Tt=typeof w=="object"&&w&&!w.nodeType&&w,St=Tt&&typeof j=="object"&&j&&!j.nodeType&&j,he=St&&St.exports===Tt;function ge(t,e){return t.set(e[0],e[1]),t}function ye(t,e){return t.add(e),t}function be(t,e){for(var r=-1,n=t?t.length:0;++r<n&&e(t[r],r,t)!==!1;);return t}function _e(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function xt(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function je(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function ve(t,e){return t==null?void 0:t[e]}function Ct(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Et(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}function F(t,e){return function(r){return t(e(r))}}function Pt(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var me=Array.prototype,we=Function.prototype,E=Object.prototype,U=u["__core-js_shared__"],It=function(){var t=/[^.]+$/.exec(U&&U.keys&&U.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Mt=we.toString,l=E.hasOwnProperty,P=E.toString,Ae=RegExp("^"+Mt.call(l).replace(ce,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Rt=he?u.Buffer:void 0,Gt=u.Symbol,Bt=u.Uint8Array,Oe=F(Object.getPrototypeOf,Object),Te=Object.create,Se=E.propertyIsEnumerable,xe=me.splice,Ht=Object.getOwnPropertySymbols,Ce=Rt?Rt.isBuffer:void 0,Ee=F(Object.keys,Object),$=_(u,"DataView"),v=_(u,"Map"),K=_(u,"Promise"),N=_(u,"Set"),V=_(u,"WeakMap"),m=_(Object,"create"),Pe=h($),Ie=h(v),Me=h(K),Re=h(N),Ge=h(V),Lt=Gt?Gt.prototype:void 0,Dt=Lt?Lt.valueOf:void 0;function p(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Be(){this.__data__=m?m(null):{}}function He(t){return this.has(t)&&delete this.__data__[t]}function Le(t){var e=this.__data__;if(m){var r=e[t];return r===at?void 0:r}return l.call(e,t)?e[t]:void 0}function De(t){var e=this.__data__;return m?e[t]!==void 0:l.call(e,t)}function Fe(t,e){var r=this.__data__;return r[t]=m&&e===void 0?at:e,this}p.prototype.clear=Be;p.prototype.delete=He;p.prototype.get=Le;p.prototype.has=De;p.prototype.set=Fe;function f(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Ue(){this.__data__=[]}function $e(t){var e=this.__data__,r=I(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():xe.call(e,r,1),!0}function Ke(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]}function Ne(t){return I(this.__data__,t)>-1}function Ve(t,e){var r=this.__data__,n=I(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}f.prototype.clear=Ue;f.prototype.delete=$e;f.prototype.get=Ke;f.prototype.has=Ne;f.prototype.set=Ve;function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function We(){this.__data__={hash:new p,map:new(v||f),string:new p}}function qe(t){return M(this,t).delete(t)}function Je(t){return M(this,t).get(t)}function Xe(t){return M(this,t).has(t)}function Ye(t,e){return M(this,t).set(t,e),this}y.prototype.clear=We;y.prototype.delete=qe;y.prototype.get=Je;y.prototype.has=Xe;y.prototype.set=Ye;function b(t){this.__data__=new f(t)}function Ze(){this.__data__=new f}function Qe(t){return this.__data__.delete(t)}function ze(t){return this.__data__.get(t)}function ke(t){return this.__data__.has(t)}function tr(t,e){var r=this.__data__;if(r instanceof f){var n=r.__data__;if(!v||n.length<ae-1)return n.push([t,e]),this;r=this.__data__=new y(n)}return r.set(t,e),this}b.prototype.clear=Ze;b.prototype.delete=Qe;b.prototype.get=ze;b.prototype.has=ke;b.prototype.set=tr;function er(t,e){var r=J(t)||Tr(t)?je(t.length,String):[],n=r.length,o=!!n;for(var i in t)(e||l.call(t,i))&&!(o&&(i=="length"||mr(i,n)))&&r.push(i);return r}function Ft(t,e,r){var n=t[e];(!(l.call(t,e)&&Nt(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function I(t,e){for(var r=t.length;r--;)if(Nt(t[r][0],e))return r;return-1}function rr(t,e){return t&&Ut(e,X(e),t)}function W(t,e,r,n,o,i,c){var s;if(n&&(s=i?n(t,o,i,c):n(t)),s!==void 0)return s;if(!R(t))return t;var Q=J(t);if(Q){if(s=_r(t),!e)return gr(t,s)}else{var g=d(t),z=g==H||g==ut;if(xr(t))return cr(t,e);if(g==L||g==B||z&&!i){if(Ct(t))return i?t:{};if(s=jr(z?{}:t),!e)return yr(t,rr(s,t))}else{if(!a[g])return i?t:{};s=vr(t,g,W,e)}}c||(c=new b);var k=c.get(t);if(k)return k;if(c.set(t,s),!Q)var tt=r?br(t):X(t);return be(tt||t,function(G,O){tt&&(O=G,G=t[O]),Ft(s,O,W(G,e,r,n,O,t,c))}),s}function nr(t){return R(t)?Te(t):{}}function or(t,e,r){var n=e(t);return J(t)?n:_e(n,r(t))}function ar(t){return P.call(t)}function ir(t){if(!R(t)||Ar(t))return!1;var e=Wt(t)||Ct(t)?Ae:fe;return e.test(h(t))}function sr(t){if(!Kt(t))return Ee(t);var e=[];for(var r in Object(t))l.call(t,r)&&r!="constructor"&&e.push(r);return e}function cr(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}function q(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}function ur(t,e){var r=e?q(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function fr(t,e,r){var n=e?r(Et(t),!0):Et(t);return xt(n,ge,new t.constructor)}function lr(t){var e=new t.constructor(t.source,ue.exec(t));return e.lastIndex=t.lastIndex,e}function pr(t,e,r){var n=e?r(Pt(t),!0):Pt(t);return xt(n,ye,new t.constructor)}function dr(t){return Dt?Object(Dt.call(t)):{}}function hr(t,e){var r=e?q(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function gr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function Ut(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var c=e[o],s=n?n(r[c],t[c],c,r,t):void 0;Ft(r,c,s===void 0?t[c]:s)}return r}function yr(t,e){return Ut(t,$t(t),e)}function br(t){return or(t,X,$t)}function M(t,e){var r=t.__data__;return wr(e)?r[typeof e=="string"?"string":"hash"]:r.map}function _(t,e){var r=ve(t,e);return ir(r)?r:void 0}var $t=Ht?F(Ht,Object):Pr,d=ar;($&&d(new $(new ArrayBuffer(1)))!=C||v&&d(new v)!=S||K&&d(K.resolve())!=lt||N&&d(new N)!=x||V&&d(new V)!=D)&&(d=function(t){var e=P.call(t),r=e==L?t.constructor:void 0,n=r?h(r):void 0;if(n)switch(n){case Pe:return C;case Ie:return S;case Me:return lt;case Re:return x;case Ge:return D}return e});function _r(t){var e=t.length,r=t.constructor(e);return e&&typeof t[0]=="string"&&l.call(t,"index")&&(r.index=t.index,r.input=t.input),r}function jr(t){return typeof t.constructor=="function"&&!Kt(t)?nr(Oe(t)):{}}function vr(t,e,r,n){var o=t.constructor;switch(e){case gt:return q(t);case st:case ct:return new o(+t);case C:return ur(t,n);case yt:case bt:case _t:case jt:case vt:case mt:case wt:case At:case Ot:return hr(t,n);case S:return fr(t,n,r);case ft:case dt:return new o(t);case pt:return lr(t);case x:return pr(t,n,r);case ht:return dr(t)}}function mr(t,e){return e=e==null?it:e,!!e&&(typeof t=="number"||le.test(t))&&t>-1&&t%1==0&&t<e}function wr(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Ar(t){return!!It&&It in t}function Kt(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||E;return t===r}function h(t){if(t!=null){try{return Mt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function Or(t){return W(t,!0,!0)}function Nt(t,e){return t===e||t!==t&&e!==e}function Tr(t){return Sr(t)&&l.call(t,"callee")&&(!Se.call(t,"callee")||P.call(t)==B)}var J=Array.isArray;function Vt(t){return t!=null&&Cr(t.length)&&!Wt(t)}function Sr(t){return Er(t)&&Vt(t)}var xr=Ce||Ir;function Wt(t){var e=R(t)?P.call(t):"";return e==H||e==ut}function Cr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=it}function R(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Er(t){return!!t&&typeof t=="object"}function X(t){return Vt(t)?er(t):sr(t)}function Pr(){return[]}function Ir(){return!1}j.exports=Or});var Zt=rt((qr,Yt)=>{var Mr="[object Object]";function Rr(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Gr(t,e){return function(r){return t(e(r))}}var Br=Function.prototype,Jt=Object.prototype,Xt=Br.toString,Hr=Jt.hasOwnProperty,Lr=Xt.call(Object),Dr=Jt.toString,Fr=Gr(Object.getPrototypeOf,Object);function Ur(t){return!!t&&typeof t=="object"}function $r(t){if(!Ur(t)||Dr.call(t)!=Mr||Rr(t))return!1;var e=Fr(t);if(e===null)return!0;var r=Hr.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Xt.call(r)==Lr}Yt.exports=$r});var Vr={};ne(Vr,{setAllValuesTo:()=>Z,version:()=>Nr});var Y=ot(qt(),1),A=ot(Zt(),1);var Qt="5.0.11";var Nr=Qt;function Z(t,e){let r,n=(0,Y.default)(t);return arguments.length<2?r=!1:(0,A.default)(e)||Array.isArray(e)?r=(0,Y.default)(e):r=e,Array.isArray(n)?n.forEach((o,i)=>{((0,A.default)(n[i])||Array.isArray(n[i]))&&(n[i]=Z(n[i],r))}):(0,A.default)(n)&&Object.keys(n).forEach(o=>{Array.isArray(n[o])||(0,A.default)(n[o])?n[o]=Z(n[o],r):n[o]=r}),n}return oe(Vr);})();
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "object-set-all-values-to",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.11",
|
|
4
4
|
"description": "Recursively walk the input and set all found values in plain objects to something",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"all",
|
|
@@ -34,100 +34,44 @@
|
|
|
34
34
|
},
|
|
35
35
|
"types": "types/index.d.ts",
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"tap": "tap",
|
|
52
|
-
"pretest": "npm run build",
|
|
53
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
54
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
55
|
-
"tsc": "tsc",
|
|
56
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
37
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
38
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
39
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
40
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
41
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
42
|
+
"letspublish": "yarn publish || :",
|
|
43
|
+
"lint": "eslint . --fix",
|
|
44
|
+
"perf": "node perf/check.js",
|
|
45
|
+
"prepare": "echo 'ready'",
|
|
46
|
+
"prettier": "prettier",
|
|
47
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
48
|
+
"pretest": "yarn run lect && yarn run build",
|
|
49
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
50
|
+
"unit": "uvu test"
|
|
57
51
|
},
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"--no-warnings",
|
|
66
|
-
"--experimental-loader",
|
|
67
|
-
"@istanbuljs/esm-loader-hook"
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
54
|
+
},
|
|
55
|
+
"c8": {
|
|
56
|
+
"check-coverage": true,
|
|
57
|
+
"exclude": [
|
|
58
|
+
"**/test/**/*.*"
|
|
68
59
|
],
|
|
69
|
-
"
|
|
60
|
+
"lines": 100
|
|
70
61
|
},
|
|
71
62
|
"lect": {
|
|
72
63
|
"licence": {
|
|
73
64
|
"extras": [
|
|
74
65
|
""
|
|
75
66
|
]
|
|
76
|
-
},
|
|
77
|
-
"req": "{ setAllValuesTo }",
|
|
78
|
-
"various": {
|
|
79
|
-
"devDependencies": [
|
|
80
|
-
"@types/lodash.clonedeep",
|
|
81
|
-
"@types/lodash.isplainobject"
|
|
82
|
-
]
|
|
83
67
|
}
|
|
84
68
|
},
|
|
85
69
|
"dependencies": {
|
|
86
|
-
"@babel/runtime": "^7.16.0",
|
|
87
70
|
"lodash.clonedeep": "^4.5.0",
|
|
88
71
|
"lodash.isplainobject": "^4.0.6"
|
|
89
72
|
},
|
|
90
73
|
"devDependencies": {
|
|
91
|
-
"@babel/cli": "^7.16.0",
|
|
92
|
-
"@babel/core": "^7.16.0",
|
|
93
|
-
"@babel/node": "^7.16.0",
|
|
94
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
95
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
96
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
97
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
98
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
99
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
100
|
-
"@babel/preset-env": "^7.16.0",
|
|
101
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
102
|
-
"@babel/register": "^7.16.0",
|
|
103
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
104
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
105
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
106
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
107
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
108
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
109
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
110
74
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
111
|
-
"@types/lodash.isplainobject": "^4.0.6"
|
|
112
|
-
"@types/node": "^16.11.6",
|
|
113
|
-
"@types/tap": "^15.0.5",
|
|
114
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
115
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
116
|
-
"core-js": "^3.19.1",
|
|
117
|
-
"cross-env": "^7.0.3",
|
|
118
|
-
"eslint": "^8.2.0",
|
|
119
|
-
"lect": "^0.18.5",
|
|
120
|
-
"rollup": "^2.59.0",
|
|
121
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
122
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
123
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
124
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
125
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
126
|
-
"tap": "^15.0.10",
|
|
127
|
-
"tslib": "^2.3.1",
|
|
128
|
-
"typescript": "^4.4.4"
|
|
129
|
-
},
|
|
130
|
-
"engines": {
|
|
131
|
-
"node": ">=12"
|
|
75
|
+
"@types/lodash.isplainobject": "^4.0.6"
|
|
132
76
|
}
|
|
133
77
|
}
|
package/types/index.d.ts
CHANGED
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { setAllValuesTo } from \"object-set-all-values-to\";\n\nassert.deepEqual(\n setAllValuesTo({\n a: \"a\",\n b: \"b\",\n c: \"c\",\n d: \"d\",\n }),\n {\n a: false,\n b: false,\n c: false,\n d: false,\n }\n);\n\n// you can change the default \"false\" to something else:\nassert.deepEqual(\n setAllValuesTo(\n {\n a: \"a\",\n b: \"b\",\n c: \"c\",\n d: \"d\",\n },\n \"x\"\n ),\n {\n a: \"x\",\n b: \"x\",\n c: \"x\",\n d: \"x\",\n }\n);"}}
|