object-set-all-values-to 5.0.7 → 5.0.10
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/README.md +4 -1
- package/dist/object-set-all-values-to.esm.js +2 -40
- package/dist/object-set-all-values-to.umd.js +2 -2
- package/examples/_quickTake.js +1 -0
- package/package.json +22 -76
- package/types/index.d.ts +0 -0
- package/examples/api.json +0 -1
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 4.1.0
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
import { strict as assert } from "assert";
|
|
41
|
+
|
|
41
42
|
import { setAllValuesTo } from "object-set-all-values-to";
|
|
42
43
|
|
|
43
44
|
assert.deepEqual(
|
|
@@ -77,7 +78,7 @@ assert.deepEqual(
|
|
|
77
78
|
|
|
78
79
|
## Documentation
|
|
79
80
|
|
|
80
|
-
Please [visit codsen.com](https://codsen.com/os/object-set-all-values-to/) for a full description of the API
|
|
81
|
+
Please [visit codsen.com](https://codsen.com/os/object-set-all-values-to/) for a full description of the API.
|
|
81
82
|
|
|
82
83
|
## Contributing
|
|
83
84
|
|
|
@@ -89,4 +90,6 @@ MIT License
|
|
|
89
90
|
|
|
90
91
|
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
91
92
|
|
|
93
|
+
|
|
92
94
|
<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">
|
|
95
|
+
|
|
@@ -1,48 +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.10
|
|
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.7";
|
|
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
|
-
}
|
|
22
|
-
else if (isObj(valueOriginal) || Array.isArray(valueOriginal)) {
|
|
23
|
-
value = clone(valueOriginal);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
value = valueOriginal;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(input)) {
|
|
29
|
-
input.forEach((_el, i) => {
|
|
30
|
-
if (isObj(input[i]) || Array.isArray(input[i])) {
|
|
31
|
-
input[i] = setAllValuesTo(input[i], value);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else if (isObj(input)) {
|
|
36
|
-
Object.keys(input).forEach((key) => {
|
|
37
|
-
if (Array.isArray(input[key]) || isObj(input[key])) {
|
|
38
|
-
input[key] = setAllValuesTo(input[key], value);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
input[key] = value;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return input;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { setAllValuesTo, version };
|
|
10
|
+
import a from"lodash.clonedeep";import l from"lodash.isplainobject";var n="5.0.10";var h=n;function i(c,r){let s,e=a(c);return arguments.length<2?s=!1:l(r)||Array.isArray(r)?s=a(r):s=r,Array.isArray(e)?e.forEach((t,o)=>{(l(e[o])||Array.isArray(e[o]))&&(e[o]=i(e[o],s))}):l(e)&&Object.keys(e).forEach(t=>{Array.isArray(e[t])||l(e[t])?e[t]=i(e[t],s):e[t]=s}),e}export{i 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.10
|
|
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.7",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((A,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]",ht="[object String]",dt="[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]",At="[object Uint8ClampedArray]",wt="[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[ht]=a[dt]=a[mt]=a[At]=a[wt]=a[Ot]=!0;a[se]=a[H]=a[D]=!1;var pe=typeof global=="object"&&global&&global.Object===Object&&global,he=typeof self=="object"&&self&&self.Object===Object&&self,u=pe||he||Function("return this")(),Tt=typeof A=="object"&&A&&!A.nodeType&&A,St=Tt&&typeof j=="object"&&j&&!j.nodeType&&j,de=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,Ae=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=Ae.toString,l=E.hasOwnProperty,P=E.toString,we=RegExp("^"+Mt.call(l).replace(ce,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Rt=de?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=d($),Ie=d(v),Me=d(K),Re=d(N),Ge=d(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=h(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)||wr(t))return!1;var e=Wt(t)||Ct(t)?we:fe;return e.test(d(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 hr(t){return Dt?Object(Dt.call(t)):{}}function dr(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 Ar(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,h=ar;($&&h(new $(new ArrayBuffer(1)))!=C||v&&h(new v)!=S||K&&h(K.resolve())!=lt||N&&h(new N)!=x||V&&h(new V)!=D)&&(h=function(t){var e=P.call(t),r=e==L?t.constructor:void 0,n=r?d(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 At:case wt:case Ot:return dr(t,n);case S:return fr(t,n,r);case ft:case ht:return new o(t);case pt:return lr(t);case x:return pr(t,n,r);case dt:return hr(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 Ar(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function wr(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 d(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),w=ot(Zt(),1);var Qt="5.0.10";var Nr=Qt;function Z(t,e){let r,n=(0,Y.default)(t);return arguments.length<2?r=!1:(0,w.default)(e)||Array.isArray(e)?r=(0,Y.default)(e):r=e,Array.isArray(n)?n.forEach((o,i)=>{((0,w.default)(n[i])||Array.isArray(n[i]))&&(n[i]=Z(n[i],r))}):(0,w.default)(n)&&Object.keys(n).forEach(o=>{Array.isArray(n[o])||(0,w.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.10",
|
|
4
4
|
"description": "Recursively walk the input and set all found values in plain objects to something",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"all",
|
|
@@ -34,96 +34,42 @@
|
|
|
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
|
-
"republish": "npm publish || :",
|
|
50
|
-
"tap": "tap",
|
|
51
|
-
"pretest": "npm run build",
|
|
52
|
-
"test": "npm run test:ci && npm run perf",
|
|
53
|
-
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
54
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
55
|
-
"tsc": "tsc",
|
|
56
|
-
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
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",
|
|
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
|
+
"pretest": "yarn run lect && yarn run build",
|
|
47
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
48
|
+
"unit": "uvu test"
|
|
57
49
|
},
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
52
|
+
},
|
|
53
|
+
"c8": {
|
|
54
|
+
"check-coverage": true,
|
|
55
|
+
"exclude": [
|
|
56
|
+
"**/test/**/*.*"
|
|
64
57
|
],
|
|
65
|
-
"
|
|
58
|
+
"lines": 100
|
|
66
59
|
},
|
|
67
60
|
"lect": {
|
|
68
61
|
"licence": {
|
|
69
62
|
"extras": [
|
|
70
63
|
""
|
|
71
64
|
]
|
|
72
|
-
},
|
|
73
|
-
"req": "{ setAllValuesTo }",
|
|
74
|
-
"various": {
|
|
75
|
-
"devDependencies": [
|
|
76
|
-
"@types/lodash.clonedeep",
|
|
77
|
-
"@types/lodash.isplainobject"
|
|
78
|
-
]
|
|
79
65
|
}
|
|
80
66
|
},
|
|
81
67
|
"dependencies": {
|
|
82
|
-
"@babel/runtime": "^7.16.3",
|
|
83
68
|
"lodash.clonedeep": "^4.5.0",
|
|
84
69
|
"lodash.isplainobject": "^4.0.6"
|
|
85
70
|
},
|
|
86
71
|
"devDependencies": {
|
|
87
|
-
"@babel/cli": "^7.16.0",
|
|
88
|
-
"@babel/core": "^7.16.0",
|
|
89
|
-
"@babel/node": "^7.16.0",
|
|
90
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
91
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
92
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
93
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
94
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
95
|
-
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
96
|
-
"@babel/preset-env": "^7.16.4",
|
|
97
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
98
|
-
"@babel/register": "^7.16.0",
|
|
99
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
100
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
101
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
102
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
103
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
104
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
105
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
106
72
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
107
|
-
"@types/lodash.isplainobject": "^4.0.6"
|
|
108
|
-
"@types/node": "^16.11.10",
|
|
109
|
-
"@types/tap": "^15.0.5",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
111
|
-
"@typescript-eslint/parser": "^5.5.0",
|
|
112
|
-
"core-js": "^3.19.2",
|
|
113
|
-
"cross-env": "^7.0.3",
|
|
114
|
-
"eslint": "^8.3.0",
|
|
115
|
-
"lect": "^0.18.7",
|
|
116
|
-
"rollup": "^2.60.1",
|
|
117
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
118
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
119
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
120
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
121
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
122
|
-
"tap": "^15.1.5",
|
|
123
|
-
"tslib": "^2.3.1",
|
|
124
|
-
"typescript": "^4.5.2"
|
|
125
|
-
},
|
|
126
|
-
"engines": {
|
|
127
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
73
|
+
"@types/lodash.isplainobject": "^4.0.6"
|
|
128
74
|
}
|
|
129
75
|
}
|
package/types/index.d.ts
CHANGED
|
File without changes
|
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);"}}
|