From 7a5d36da24e2c102b6871352ec384f29a5c8118c Mon Sep 17 00:00:00 2001 From: Mat Taylor Date: Fri, 14 Oct 2022 17:59:29 -0700 Subject: [PATCH] mini --- objix.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objix.min.js b/objix.min.js index a739c25..3abc1cb 100644 --- a/objix.min.js +++ b/objix.min.js @@ -1 +1 @@ -const P=Object.prototype,F=Object.fromEntries,K=Object.keys,A=Object.assign;for(let t of["keys","values","entries","create","assign"])P[t]=function(...n){return Object[t](this,...n)};P.every=function(t){for(let n of K(this))if(!t(this[n],n))return!1;return!0},P.some=function(t){for(let n of K(this))if(t(this[n],n))return!0;return!1},P.map=function(t){let n={};for(let i of K(this))n[i]=t(this[i],i);return n},P.has=function(t){return this.find((n=>n.equals(t)))},P.filter=function(t){return F(K(this).flatMap((n=>t(this[n],n)?[[n,this[n]]]:[])))},P.flatMap=function(t){return F(K(this).flatMap((n=>t(n,this[n]))))},P.clean=function(){return F(K(this).flatMap((t=>this[t]?[[t,this[t]]]:[])))},P.type=function(){return this.constructor.name},P.is=function(t,n){return t==Object?![String,Boolean,Number,Function].includes(this.constructor):this.constructor==t||!n&&this.is(Object)&&this instanceof t},P.find=P.find=function(t){for(let n of K(this))if(t(this[n],n))return n},P.extend=function(...t){return A({},...t,this)},P.delete=function(...t){for(let n of t)delete this[n];return this},P.json=function(){return JSON.stringify(this)},P.clone=function(t,n=this.constructor){return this.is(Object)?this.is(Array,1)?this.map((n=>t&&n?n.clone(t-1):n)):new n(this.valueOf().is(Object)?this.map((n=>t&&n?n.clone(t-1):n)):this):this.valueOf()},P[Symbol.iterator]=function(){return this.entries()[Symbol.iterator]()},P.join=function(...t){let n=A({},this);for(let i of t)K(i).map((t=>n[t]&&=[].concat(n[t],i[t])));return n},P.split=function(){let t=[];for(let n of K(this))this[n].map(((i,e)=>t[e]?t[e][n]=i:t[e]={[n]:i}));return t},P.common=function(t){return F(K(this).flatMap((n=>t[n]==this[n]?[[n,this[n]]]:[])))},P.contains=function(t,n){for(let i of K(t))if(!(this[i]==t[i]||n&&this.some((i=>i.contains(t,n-1)))))return!1;return!0},P.equals=function(t,n){return this==t||this.type()==t.type()&&this.size()==t.size()&&!(this-t)&&this.every(((i,e)=>i==t[e]||n&&i?.equals(t[e],n-1)))},P.size=function(){return K(this).length},P.keyBy=function(t,n){return t.map((t=>this[t[n]]=this[t[n]]?[t].concat(this[t[n]]):t)),this},P.bind=function(t,n){return this[t]=function(...t){return n(this,...t)},this},P.log=function(t="",n="log"){return console[n]((new Date).toISOString().slice(0,-8),t,this.clone(-1)),this},P.new=function(t){return this._t?new Proxy(this._t.new(t),this._h):A(this.create(),t)},P.trap=function(t,n,...i){return new Proxy(this,{set(e,r,s){if((!i[0]||i.has(r))&&!t(s,r,e)&&n)throw[n,r,s]+"";return e[r]=s},get(t,n){return{_t:t,_h:this}[n]||t[n]}})};for(let t of K(P))if("_"!=t[0]){P["_"+t]=P[t];try{module.exports[t]=(n,...i)=>n["_"+t](...i)}catch{}} \ No newline at end of file +const P=Object.prototype,F=Object.fromEntries,K=Object.keys,A=Object.assign;for(let t of["keys","values","entries","create","assign"])P[t]=function(...n){return Object[t](this,...n)};P.every=function(t){for(let n in this)if(!t(this[n],n))return!1;return!0},P.some=function(t){for(let n in this)if(t(this[n],n))return!0;return!1},P.map=function(t){let n={};for(let i in this)n[i]=t(this[i],i);return n},P.has=function(t){return this.find((n=>n.equals(t)))},P.filter=function(t){return F(K(this).flatMap((n=>t(this[n],n)?[[n,this[n]]]:[])))},P.flatMap=function(t){return F(K(this).flatMap((n=>t(n,this[n]))))},P.clean=function(){return F(K(this).flatMap((t=>this[t]?[[t,this[t]]]:[])))},P.type=function(){return this.constructor.name},P.is=function(t,n){return t==Object?![String,Boolean,Number,Function].includes(this.constructor):this.constructor==t||!n&&this.is(Object)&&this instanceof t},P.find=P.find=function(t){for(let n in this)if(t(this[n],n))return n},P.extend=function(...t){return A({},...t,this)},P.delete=function(...t){for(let n of t)delete this[n];return this},P.json=function(){return JSON.stringify(this)},P.clone=function(t,n=this.constructor){return this.is(Object)?this.is(Array,1)?this.map((n=>t&&n?n.clone(t-1):n)):new n(this.valueOf().is(Object)?this.map((n=>t&&n?n.clone(t-1):n)):this):this.valueOf()},P[Symbol.iterator]=function(){return this.values()[Symbol.iterator]()},P.join=function(...t){let n=A({},this);for(let i of t)K(i).map((t=>n[t]&&=[].concat(n[t],i[t])));return n},P.split=function(){let t=[];for(let n in this)this[n].map(((i,e)=>t[e]?t[e][n]=i:t[e]={[n]:i}));return t},P.common=function(t){return F(K(this).flatMap((n=>t[n]==this[n]?[[n,this[n]]]:[])))},P.contains=function(t,n){for(let i in t)if(!(this[i]==t[i]||n&&this.some((i=>i.contains(t,n-1)))))return!1;return!0},P.equals=function(t,n){return this==t||this.type()==t.type()&&this.size()==t.size()&&!(this-t)&&this.every(((i,e)=>i==t[e]||n&&i?.equals(t[e],n-1)))},P.size=function(){return K(this).length},P.keyBy=function(t,n){return t.map((t=>this[t[n]]=this[t[n]]?[t].concat(this[t[n]]):t)),this},P.bind=function(t,n){return this[t]=function(...t){return n(this,...t)},this},P.log=function(t="",n="log"){return console[n]((new Date).toISOString().slice(0,-8),t,this.clone(-1)),this},P.new=function(t){return this._t?new Proxy(this._t.new(t),this._h):A(this.create(),t)},P.trap=function(t,n,...i){return new Proxy(this,{set(e,r,s){if((!i[0]||i.has(r))&&!t(s,r,e)&&n)throw[n,r,s]+"";return e[r]=s},get(t,n){return{_t:t,_h:this}[n]||t[n]}})};for(let t of K(P))if("_"!=t[0]){[t,"__"+t].map((n=>Object.defineProperty(P,n,{enumerable:!1,value:P[t]})));try{module.exports[t]=(n,...i)=>n["__"+t](...i)}catch{}} \ No newline at end of file