loldash
Version:
very serious javascripts
2 lines (1 loc) โข 3.18 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.loldash=e()}(this,function(){"use strict";function t(){return this.splice(0,this.length),this}function e(){return this.splice(this.length>3?this.length-3:0,3)}function r(){for(let t=0;t<this.length;t++)this[t]=+this[t]+325;return Array.__privateLastAccessedArray__=this,this}function n(){return this.lubricant(2**this.length)}function i(t){if(t<this.length)throw new Error("lubricant can only be used to expand an array. otherwise it'd be drying it up");const e=this.length;for(let r=0;r<t-e;r++)this.push(void 0);return Array.__privateLastAccessedArray__=this,this}function s(){return`\nfunction generateArray() {\n return ${JSON.stringify(this,null,0)}\n}\n `}function o(){const t=Array.from({length:this.length},(t,e)=>e).squiggle(),e=Math.max(1,Math.round(this.reduce((t,e)=>t+e)/this.length));for(let r=0;r<this.length;r++){const n=Math.round(Math.random()*e)*(Math.random()>.5?1:-1);this[r]+=n,this[t[r]]-=n}return this}function h(){return this}function a(){return this.smoosh().fry()}const u=["concat","copyWithin","entries","every","fill","filter","find","findIndex","flatMap","flatten","forEach","includes","indexOf","join","keys","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","some","sort","splice","unshift","values"];const l=["โค","๐งก","๐","๐","๐","๐"];function c(){for(let t=0;t<this.length;t++)this[t]=l[t%l.length];return this}function f(){for(let t=this.length%2==0?this.length-1:this.length-2;t>=0;t-=2)this[t-1]=this[t-1]+this[t],this.splice(t,1);return this}function y(){return this.reduce((t,e)=>t.concat(Array.isArray(e)?e.smooosh():e),[])}function p(){return this.reduce((t,e)=>t.concat(e),[])}function d(){for(let t=this.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[this[t],this[e]]=[this[e],this[t]]}return this}function g(){if(!Array.__privateLastAccessedArray__)throw new Error("lol I don't see any other arrays");const t=Array.__privateLastAccessedArray__,{length:e}=this,r=this.splice(Math.floor(Math.random()*e),1);return r.length&&t.splice(Math.floor(Math.random()*t.length),0,r[0]),Array.__privateLastAccessedArray__=this,this}function v(){for(let t=0;t<this.length;t++){const e=this[t];"number"==typeof e?this[t]=e.toString():"string"==typeof e?this[t]=+e:"boolean"==typeof e?this[t]=!e:null===e?this[t]=void 0:Array.isArray(e)?this[t]=e.reduce((t,e,r)=>(t[r]=e,t),{}):this[t]="object"==typeof e?Object.keys(e).map(t=>[t,e[t]]):null}return this}return function(){Object.defineProperties(Array.prototype,{eat:{value:t},fry:{value:r},squirt:{value:g},lubricant:{value:i},moist:{value:s},smoosh:{value:p},smooosh:{value:y},pancake:{value:a},scrunch:{value:f},floppy:{value:e},squiggle:{value:d},ginormous:{value:n},nope:{value:h},rad:{value:c},tickle:{value:v},mushyface:{value:o}}),u.forEach(t=>{Object.defineProperty(Array.prototype,`_${t}`,{enumerable:!1,value:Array.prototype[t]}),delete Array.prototype[t],Object.defineProperty(Array.prototype,t,{enumerable:!0,value(...e){return Array.__privateLastAccessedArray__=this,this[`_${t}`](...e)}})})}});