├── .prettierrc ├── .gitignore ├── src ├── pancake.ts ├── eat.ts ├── ginormous.ts ├── nope.ts ├── smoosh.ts ├── floppy.ts ├── moist.ts ├── smooosh.ts ├── rad.ts ├── squiggle.ts ├── scrunch.ts ├── fry.ts ├── __tests__ │ ├── fry.test.ts │ ├── nope.ts │ ├── lubricant.test.ts │ ├── pancake.test.ts │ ├── smoosh.test.ts │ ├── moist.test.ts │ ├── smooosh.test.ts │ ├── eat.test.ts │ ├── rad.test.ts │ ├── ginormous.test.ts │ ├── squirt.test.ts │ ├── squiggle.test.ts │ ├── scrunch.test.ts │ ├── mushyface.test.ts │ ├── floppy.test.ts │ └── tickle.test.ts ├── lubricant.ts ├── mushyface.ts ├── squirt.ts ├── tickle.ts ├── proxyArray.ts └── index.ts ├── tslint.json ├── .editorconfig ├── LICENSE ├── rollup.config.js ├── tsconfig.json ├── README.md └── package.json /.prettierrc: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | .vscode/ 4 | coverage/ 5 | .rpt2_cache/ 6 | dist/ 7 | -------------------------------------------------------------------------------- /src/pancake.ts: -------------------------------------------------------------------------------- 1 | export default function pancake(this: any[]) { 2 | return this.smoosh().fry(); 3 | } 4 | -------------------------------------------------------------------------------- /src/eat.ts: -------------------------------------------------------------------------------- 1 | export default function eat(this: any[]) { 2 | this.splice(0, this.length); 3 | return this; 4 | } 5 | -------------------------------------------------------------------------------- /src/ginormous.ts: -------------------------------------------------------------------------------- 1 | export default function ginormous(this: any[]) { 2 | return this.lubricant(2 ** this.length); 3 | } 4 | -------------------------------------------------------------------------------- /src/nope.ts: -------------------------------------------------------------------------------- 1 | export default function nope(this: any[]) { 2 | // nothing to do here ¯\_(ツ)_/¯ 3 | return this; 4 | } 5 | -------------------------------------------------------------------------------- /src/smoosh.ts: -------------------------------------------------------------------------------- 1 | export default function smoosh(this: any[]) { 2 | return this.reduce((acc, item) => acc.concat(item), []); 3 | } 4 | -------------------------------------------------------------------------------- /src/floppy.ts: -------------------------------------------------------------------------------- 1 | export default function floppy(this: any[]) { 2 | return this.splice(this.length > 3 ? this.length - 3 : 0, 3); 3 | } 4 | -------------------------------------------------------------------------------- /src/moist.ts: -------------------------------------------------------------------------------- 1 | export default function moist(this: any[]) { 2 | return ` 3 | function generateArray() { 4 | return ${JSON.stringify(this, null, 0)} 5 | } 6 | `; 7 | } 8 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:recommended", "tslint-config-prettier"], 3 | "rules": { 4 | "object-literal-sort-keys": false, 5 | "interface-name": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/smooosh.ts: -------------------------------------------------------------------------------- 1 | export default function smooosh(this: any[]) { 2 | return this.reduce( 3 | (acc, item) => acc.concat(Array.isArray(item) ? item.smooosh() : item), 4 | [] 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /src/rad.ts: -------------------------------------------------------------------------------- 1 | const hearts = ["❤", "🧡", "💛", "💚", "💙", "💜"]; 2 | 3 | export default function rad(this: any[]): string[] { 4 | for (let i = 0; i < this.length; i++) { 5 | this[i] = hearts[i % hearts.length]; 6 | } 7 | return this; 8 | } 9 | -------------------------------------------------------------------------------- /src/squiggle.ts: -------------------------------------------------------------------------------- 1 | // Fisher-Yates 2 | export default function squiggle(this: any[]) { 3 | for (let i = this.length - 1; i > 0; i--) { 4 | const j = Math.floor(Math.random() * (i + 1)); 5 | [this[i], this[j]] = [this[j], this[i]]; 6 | } 7 | return this; 8 | } 9 | -------------------------------------------------------------------------------- /src/scrunch.ts: -------------------------------------------------------------------------------- 1 | export default function scrunch(this: number[]) { 2 | const start = this.length % 2 === 0 ? this.length - 1 : this.length - 2; 3 | for (let i = start; i >= 0; i -= 2) { 4 | this[i - 1] = this[i - 1] + this[i]; 5 | this.splice(i, 1); 6 | } 7 | return this; 8 | } 9 | -------------------------------------------------------------------------------- /src/fry.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | interface Array { 3 | fry(): T[]; 4 | } 5 | } 6 | 7 | export default function fry(this: number[]) { 8 | for (let i = 0; i < this.length; i++) { 9 | this[i] = +this[i] + 325; 10 | } 11 | Array.__privateLastAccessedArray__ = this; 12 | return this; 13 | } 14 | -------------------------------------------------------------------------------- /src/__tests__/fry.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("fry", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.fry).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | expect([1, 2, 3, 4, 5].fry()).toEqual([326, 327, 328, 329, 330]); 12 | expect([100].fry()).toEqual([425]); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /src/__tests__/nope.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("nope", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.nope).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const array = [5, 12, 7, 9, 12, 35, "thing", "not important"]; 12 | 13 | expect(array.nope()).toEqual(array); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/__tests__/lubricant.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("lubricant", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.lubricant).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const x = [1, 2, 3]; 12 | x.lubricant(5); 13 | expect(x).toEqual([1, 2, 3, void 0, void 0]); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/__tests__/pancake.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("pancake", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.pancake).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const x = [1, 2, 3, [13, 19], 4, 10, 36, 9]; 12 | 13 | expect(x.pancake()).toEqual(x.smoosh().fry()); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/__tests__/smoosh.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("smoosh", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.smoosh).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const x = [[1, 2, 3, 4], 5, [6, 7, 8], 9]; 12 | 13 | expect(x.smoosh()).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/__tests__/moist.test.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable no-eval */ 2 | import install from "../index"; 3 | 4 | install(); 5 | 6 | describe("moist", () => { 7 | test("installs on the array prototype", () => { 8 | expect(Array.prototype.moist).toBeDefined(); 9 | }); 10 | 11 | test("works on an array", () => { 12 | const x = [1, 2, 3, 4, 10, 36, 9]; 13 | 14 | expect(eval(`(${x.moist()})()`)).toEqual(x); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/__tests__/smooosh.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("smooosh", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.smooosh).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const x = [[1, [2, [3]], 4], 5, [[6, 7], 8], [[[9]]]]; 12 | 13 | expect(x.smooosh()).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/__tests__/eat.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("eat", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.eat).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | expect([1, 2, 3, 4, 5].eat()).toEqual([]); 12 | }); 13 | 14 | test("works on an empty array", () => { 15 | expect([].eat()).toEqual([]); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /src/__tests__/rad.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("rad", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.rad).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const array = [5, 12, 7, 9, 12, 35, "thing", "not important"]; 12 | 13 | expect(array.rad()).toEqual(["❤", "🧡", "💛", "💚", "💙", "💜", "❤", "🧡"]); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/__tests__/ginormous.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("ginormous", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.ginormous).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const array = [5, 12, 7, 9]; 12 | const previous = array.length; 13 | array.ginormous(); 14 | 15 | expect(array.length).toBe(2 ** previous); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /src/lubricant.ts: -------------------------------------------------------------------------------- 1 | export default function lubricant(this: any[], length: number) { 2 | if (length < this.length) { 3 | throw new Error( 4 | "lubricant can only be used to expand an array. otherwise it'd be drying it up" 5 | ); 6 | } 7 | 8 | const previousLength = this.length; 9 | 10 | for (let i = 0; i < length - previousLength; i++) { 11 | this.push(void 0); 12 | } 13 | Array.__privateLastAccessedArray__ = this; 14 | return this; 15 | } 16 | -------------------------------------------------------------------------------- /src/__tests__/squirt.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("squirt", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.squirt).toBeDefined(); 8 | }); 9 | 10 | test("squirts into the previously accessed array", () => { 11 | const x = []; 12 | const y = [1]; 13 | 14 | x.concat([]); 15 | y.squirt(); 16 | 17 | expect(x).toEqual([1]); 18 | expect(y).toEqual([]); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /src/mushyface.ts: -------------------------------------------------------------------------------- 1 | export default function mushyface(this: number[]) { 2 | const order = Array.from({ length: this.length }, (_, i) => i).squiggle(); 3 | const fuzzDistance = Math.max( 4 | 1, 5 | Math.round(this.reduce((acc, item) => acc + item) / this.length) 6 | ); 7 | 8 | for (let i = 0; i < this.length; i++) { 9 | const fuzzAmount = 10 | Math.round(Math.random() * fuzzDistance) * (Math.random() > 0.5 ? 1 : -1); 11 | 12 | this[i] += fuzzAmount; 13 | this[order[i]] -= fuzzAmount; 14 | } 15 | return this; 16 | } 17 | -------------------------------------------------------------------------------- /src/__tests__/squiggle.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("squiggle", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.squiggle).toBeDefined(); 8 | }); 9 | 10 | test("works on an array", () => { 11 | const array = [5, 12, 7, 9]; 12 | const copy = [5, 12, 7, 9]; 13 | 14 | array.squiggle(); 15 | 16 | expect(array.length).toEqual(copy.length); 17 | 18 | const leftOver = array.filter(item => !copy.includes(item)); 19 | 20 | expect(leftOver.length).toBe(0); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /src/squirt.ts: -------------------------------------------------------------------------------- 1 | export default function squirt(this: any[]) { 2 | if (!Array.__privateLastAccessedArray__) { 3 | throw new Error("lol I don't see any other arrays"); 4 | } 5 | const previousArray = Array.__privateLastAccessedArray__; 6 | const { length } = this; 7 | const toMove = this.splice(Math.floor(Math.random() * length), 1); 8 | if (toMove.length) { 9 | previousArray.splice( 10 | Math.floor(Math.random() * previousArray.length), 11 | 0, 12 | toMove[0] 13 | ); 14 | } 15 | Array.__privateLastAccessedArray__ = this; 16 | return this; 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Brian Holt 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /src/__tests__/scrunch.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("scrunch", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.scrunch).toBeDefined(); 8 | }); 9 | 10 | test("works on an even array", () => { 11 | const x = [5, 12, 7, 9]; 12 | const y = [17, 16]; 13 | 14 | expect(x.scrunch()).toEqual(y); 15 | }); 16 | 17 | test("works on an odd array", () => { 18 | const x = [1, 2, 3, 4, 10, 36, 9]; 19 | const y = [3, 7, 46, 9]; 20 | 21 | expect(x.scrunch()).toEqual(y); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /src/__tests__/mushyface.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("mushyface", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.mushyface).toBeDefined(); 8 | }); 9 | 10 | test("mushes faces", () => { 11 | const array = [1, 9, 13, 21, 3, 8, 2]; 12 | const total = array.reduce((acc, cur) => acc + cur); 13 | const previousLength = array.length; 14 | array.mushyface(); 15 | const newTotal = array.reduce((acc, cur) => acc + cur); 16 | 17 | expect(total).toEqual(newTotal); 18 | expect(array.length).toEqual(previousLength); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /src/__tests__/floppy.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("floppy", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.floppy).toBeDefined(); 8 | }); 9 | 10 | test("works on an array larger than length 3", () => { 11 | const array = [5, 12, 7, 9, 15, 19]; 12 | const flopped = array.floppy(); 13 | 14 | expect(array).toEqual([5, 12, 7]); 15 | expect(flopped).toEqual([9, 15, 19]); 16 | }); 17 | 18 | test("works on an array smaller than length 3", () => { 19 | const array = [5, 12]; 20 | const flopped = array.floppy(); 21 | 22 | expect(array).toEqual([]); 23 | expect(flopped).toEqual([5, 12]); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/__tests__/tickle.test.ts: -------------------------------------------------------------------------------- 1 | import install from "../index"; 2 | 3 | install(); 4 | 5 | describe("tickle", () => { 6 | test("installs on the array prototype", () => { 7 | expect(Array.prototype.tickle).toBeDefined(); 8 | }); 9 | 10 | test("tickles", () => { 11 | const array = [ 12 | 5, 13 | 12, 14 | "10", 15 | "1", 16 | { thing: 5 }, 17 | ["zero", "one"], 18 | null, 19 | void 0, 20 | true, 21 | false 22 | ]; 23 | 24 | expect(array.tickle()).toEqual([ 25 | "5", 26 | "12", 27 | 10, 28 | 1, 29 | [["thing", 5]], 30 | { 0: "zero", 1: "one" }, 31 | void 0, 32 | null, 33 | false, 34 | true 35 | ]); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /src/tickle.ts: -------------------------------------------------------------------------------- 1 | export default function tickle( 2 | this: Array 3 | ) { 4 | for (let i = 0; i < this.length; i++) { 5 | const current = this[i]; 6 | if (typeof current === "number") { 7 | this[i] = current.toString(); 8 | } else if (typeof current === "string") { 9 | this[i] = +current; 10 | } else if (typeof current === "boolean") { 11 | this[i] = !current; 12 | } else if (current === null) { 13 | this[i] = void 0; 14 | } else if (Array.isArray(current)) { 15 | this[i] = current.reduce((acc, item, index) => { 16 | acc[index] = item; 17 | return acc; 18 | }, {}); 19 | } else if (typeof current === "object") { 20 | this[i] = Object.keys(current).map(key => [key, current[key]]); 21 | } else { 22 | this[i] = null; 23 | } 24 | } 25 | return this; 26 | } 27 | -------------------------------------------------------------------------------- /src/proxyArray.ts: -------------------------------------------------------------------------------- 1 | const methods = [ 2 | "concat", 3 | "copyWithin", 4 | "entries", 5 | "every", 6 | "fill", 7 | "filter", 8 | "find", 9 | "findIndex", 10 | "flatMap", 11 | "flatten", 12 | "forEach", 13 | "includes", 14 | "indexOf", 15 | "join", 16 | "keys", 17 | "lastIndexOf", 18 | "map", 19 | "pop", 20 | "push", 21 | "reduce", 22 | "reduceRight", 23 | "reverse", 24 | "shift", 25 | "some", 26 | "sort", 27 | "splice", 28 | "unshift", 29 | "values" 30 | ]; 31 | 32 | export default function installFakeMethods() { 33 | methods.forEach(prop => { 34 | Object.defineProperty(Array.prototype, `_${prop}`, { 35 | enumerable: false, 36 | value: Array.prototype[prop] 37 | }); 38 | 39 | delete Array.prototype[prop]; 40 | Object.defineProperty(Array.prototype, prop, { 41 | enumerable: true, 42 | value(this: any[], ...input) { 43 | Array.__privateLastAccessedArray__ = this; 44 | return this[`_${prop}`](...input); 45 | } 46 | }); 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import commonjs from "rollup-plugin-commonjs"; 2 | import resolve from "rollup-plugin-node-resolve"; 3 | import typescript from "rollup-plugin-typescript2"; 4 | import uglify from "rollup-plugin-uglify"; 5 | 6 | const pkg = require("./package.json"); 7 | 8 | const libraryName = "loldash"; 9 | 10 | const isProduction = process.env.NODE_ENV === "production"; 11 | 12 | const plugins = [ 13 | typescript({ useTsconfigDeclarationDir: false }), 14 | commonjs(), 15 | resolve() 16 | ]; 17 | 18 | if (isProduction) { 19 | plugins.push(uglify()); 20 | } 21 | 22 | const banner = `/** loldash v${ 23 | pkg.version 24 | } - serious javascripts - written by Brian Holt - Apache 2.0 License */`; 25 | 26 | export default { 27 | input: `src/index.ts`, 28 | output: [ 29 | { 30 | file: `./dist/loldash${isProduction ? ".min" : ""}.umd.js`, 31 | name: libraryName, 32 | format: "umd", 33 | sourcemap: !isProduction, 34 | banner 35 | }, 36 | { 37 | file: `./dist/loldash${isProduction ? ".min" : ""}.esm.js`, 38 | format: "es", 39 | sourcemap: !isProduction, 40 | banner 41 | } 42 | ], 43 | external: [], 44 | watch: { 45 | include: "src/**" 46 | }, 47 | plugins 48 | }; 49 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNEXT", 4 | "module": "ESNEXT", 5 | "declaration": true, 6 | "strict": true /* Enable all strict type-checking options. */, 7 | "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */, 8 | "strictNullChecks": true /* Enable strict null checks. */, 9 | "strictFunctionTypes": true /* Enable strict checking of function types. */, 10 | "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, 11 | "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, 12 | "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, 13 | "noUnusedLocals": true /* Report errors on unused locals. */, 14 | "noUnusedParameters": true /* Report errors on unused parameters. */, 15 | "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, 16 | "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, 17 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import eat from "./eat"; 2 | import floppy from "./floppy"; 3 | import fry from "./fry"; 4 | import ginormous from "./ginormous"; 5 | import lubricant from "./lubricant"; 6 | import moist from "./moist"; 7 | import mushyface from "./mushyface"; 8 | import nope from "./nope"; 9 | import pancake from "./pancake"; 10 | import installProxyMethods from "./proxyArray"; 11 | import rad from "./rad"; 12 | import scrunch from "./scrunch"; 13 | import smooosh from "./smooosh"; 14 | import smoosh from "./smoosh"; 15 | import squiggle from "./squiggle"; 16 | import squirt from "./squirt"; 17 | import tickle from "./tickle"; 18 | 19 | declare global { 20 | interface Array { 21 | eat(): T[]; 22 | fry(): number[]; 23 | squirt(): T[]; 24 | lubricant(length: number): T[]; 25 | moist(): string; 26 | smoosh(): T[]; 27 | smooosh(): T[]; 28 | pancake(): number[]; 29 | scrunch(): T[]; 30 | floppy(): T[]; 31 | squiggle(): T[]; 32 | ginormous(): T[]; 33 | nope(): T[]; 34 | rad(): string[]; 35 | tickle(): string[]; 36 | mushyface(): string[]; 37 | toSource?(): string; 38 | } 39 | interface ArrayConstructor { 40 | __privateLastAccessedArray__?: any[]; 41 | } 42 | } 43 | 44 | export default function installLolDash() { 45 | Object.defineProperties(Array.prototype, { 46 | eat: { value: eat }, 47 | fry: { value: fry }, 48 | squirt: { value: squirt }, 49 | lubricant: { value: lubricant }, 50 | moist: { value: moist }, 51 | smoosh: { value: smoosh }, 52 | smooosh: { value: smooosh }, 53 | pancake: { value: pancake }, 54 | scrunch: { value: scrunch }, 55 | floppy: { value: floppy }, 56 | squiggle: { value: squiggle }, 57 | ginormous: { value: ginormous }, 58 | nope: { value: nope }, 59 | rad: { value: rad }, 60 | tickle: { value: tickle }, 61 | mushyface: { value: mushyface } 62 | }); 63 | installProxyMethods(); 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## loldash 2 | 3 | very serious javascripts 4 | 5 | ## wait what? 6 | 7 | [See here](https://twitter.com/sarah_edo/status/971761942556762112). 8 | 9 | ## usage 10 | 11 | ```bash 12 | npm install loldash 13 | ``` 14 | 15 | ```javascript 16 | import install from "loldash"; 17 | 18 | install(); 19 | ``` 20 | 21 | ## docs 22 | 23 | `Array.prototype.eat` - returns an empty array 24 | 25 | `Array.prototype.floppy` - removes the last three items of the array and returns the removed items 26 | 27 | `Array.prototype.fry` - adds 325 to every item in the array and returns itself 28 | 29 | `Array.prototype.ginormous` - increases the size of the array to be `2 ^ array.length` and returns itself 30 | 31 | `Array.prototype.lubricant` - accepts an integer as a parameter and increase the size of the array to that size and returns itself 32 | 33 | `Array.prototype.moist` - returns a string of generated JavaScript that returns that array. useful if your code is too DRY 34 | 35 | `Array.prototype.mushyface` - randomly adds and subtracts numbers from each number in the array without changing the average number of the array and returns itself 36 | 37 | `Array.prototype.nope` - no operation, just do nothing and returns itself 38 | 39 | `Array.prototype.pancake` - sugar for calling `smoosh` and `fry` 40 | 41 | `Array.prototype.rad` - overwrites all the values in the array to be a pretty rad string of hearts, returns itself 42 | 43 | `Array.prototype.scrunch` - cuts the size in half and combines values of items next to each other and returns itself 44 | 45 | `Array.prototype.smooosh` - recursively smooshes an array of arrays into one smooshed (or flattened) array, returns itself 46 | 47 | `Array.prototype.smoosh` - smooshes an array of arrays into one smooshed (or flattened) array, returns itself 48 | 49 | `Array.prototype.squiggle` - shuffles the array and returns itself 50 | 51 | `Array.prototype.squirt` - removes a random item in the array and puts it in the previously accessed array and returns itself 52 | 53 | `Array.prototype.tickle` - coerces all the items in the array to be a different type or value and returns itself 54 | 55 | ## why would you … 56 | 57 | YOU'RE NOT MY MOM! 58 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "loldash", 3 | "version": "9002.0.0", 4 | "description": "very serious javascripts", 5 | "main": "dist/loldash.umd.js", 6 | "module": "dist/loldash.esm.js", 7 | "files": ["dist/**/*"], 8 | "typings": "./dist/index.d.ts", 9 | "scripts": { 10 | "build": "NODE_ENV=production rollup -c && NODE_ENV=development rollup -c", 11 | "test": "jest --watch", 12 | "test:check": "jest --ci --silent", 13 | "lint": "tslint --project ./ --fix", 14 | "types": "tsc --noEmit", 15 | "types:gen": "tsc", 16 | "format:emit": 17 | "prettier package.json .prettierrc rollup.config.js tsconfig.json tslint.json README.md \"./src/**/*.{ts,js,json}\"", 18 | "format:check": "npm run format:emit -- --list-different", 19 | "format": "npm run format:emit -- --write", 20 | "check": "run-p format:check lint types test:check", 21 | "prepare": "npm run build -s" 22 | }, 23 | "repository": { 24 | "type": "git", 25 | "url": "git+https://github.com/btholt/loldash.git" 26 | }, 27 | "keywords": ["serious", "javascripts", "important", "array"], 28 | "author": "Brian Holt ", 29 | "license": "Apache-2.0", 30 | "bugs": { 31 | "url": "https://github.com/btholt/loldash/issues" 32 | }, 33 | "homepage": "http://www.loldash.com", 34 | "husky": { 35 | "hooks": { 36 | "pre-commit": "npm run check" 37 | } 38 | }, 39 | "devDependencies": { 40 | "@types/jest": "^22.2.0", 41 | "husky": "^0.14.3", 42 | "jest": "^22.4.2", 43 | "npm-run-all": "^4.1.2", 44 | "prettier": "^1.11.1", 45 | "rollup": "^0.56.5", 46 | "rollup-plugin-commonjs": "^9.0.0", 47 | "rollup-plugin-node-resolve": "^3.2.0", 48 | "rollup-plugin-typescript2": "^0.12.0", 49 | "rollup-plugin-uglify": "^3.0.0", 50 | "ts-jest": "^22.4.1", 51 | "tslint": "^5.9.1", 52 | "tslint-config-prettier": "^1.9.0", 53 | "typescript": "^2.7.2" 54 | }, 55 | "dependencies": {}, 56 | "jest": { 57 | "moduleFileExtensions": ["ts", "tsx", "js"], 58 | "transform": { 59 | "^.+\\.ts$": "/node_modules/ts-jest/preprocessor.js" 60 | }, 61 | "testMatch": ["**/__tests__/*.+(ts|js)"], 62 | "testPathIgnorePatterns": ["/dist/"] 63 | } 64 | } 65 | --------------------------------------------------------------------------------