From cb5920ab598d890c33e096f745e1afc6f9b58ec5 Mon Sep 17 00:00:00 2001 From: queicherius Date: Sun, 4 Jul 2021 22:30:33 +0000 Subject: [PATCH] Run the formatter --- src/average/average.ts | 2 -- src/benchmarkHelper.ts | 6 +----- src/chunk/chunk.spec.ts | 13 +------------ src/chunk/chunk.ts | 2 -- src/clone/clone.ts | 11 +---------- src/compact/compact.spec.ts | 21 ++------------------- src/compact/compact.ts | 2 -- src/debounce/debounce.ts | 7 +------ src/duplicates/duplicates.spec.ts | 6 +----- src/duplicates/duplicates.ts | 12 ++---------- src/escapeRegExp/escapeRegExp.spec.ts | 4 +--- src/escapeRegExp/escapeRegExp.ts | 2 -- src/generateDocs.ts | 10 ++-------- src/get/BENCHMARK.md | 10 +++++----- src/get/get.ts | 2 -- src/hash/BENCHMARK.md | 8 ++++---- src/hash/hash.ts | 2 -- src/identifier/identifier.spec.ts | 3 +-- src/identifier/identifier.ts | 2 -- src/matchAll/matchAll.spec.ts | 4 +--- src/matchAll/matchAll.ts | 2 -- src/max/max.ts | 2 -- src/memoize/BENCHMARK.md | 10 +++++----- src/memoize/memoize.benchmark.ts | 4 +--- src/memoize/memoize.spec.ts | 10 +++------- src/memoize/memoize.ts | 17 +++++++---------- src/min/min.ts | 2 -- src/omit/BENCHMARK.md | 12 ++++++------ src/omit/omit.ts | 7 +------ src/parseModules.ts | 7 ++----- src/pick/pick.ts | 7 +------ src/random/random.spec.ts | 3 +-- src/random/random.ts | 2 -- src/randomString/randomString.ts | 5 +---- src/roundTo/roundTo.ts | 2 -- src/sample/sample.ts | 2 -- src/shuffle/shuffle.ts | 2 -- src/sleep/sleep.ts | 2 -- src/slugify/slugify.ts | 2 -- src/sum/sum.ts | 2 -- src/testHelpers.ts | 16 +++++++--------- src/toMap/toMap.ts | 6 +----- src/unique/BENCHMARK.md | 8 ++++---- src/unique/unique.spec.ts | 6 +----- src/unique/unique.ts | 2 -- 45 files changed, 64 insertions(+), 205 deletions(-) diff --git a/src/average/average.ts b/src/average/average.ts index e4d8af20..efee95da 100644 --- a/src/average/average.ts +++ b/src/average/average.ts @@ -12,5 +12,3 @@ export function average(array: Array): number { return array.reduce((a, b) => a + b, 0) / array.length } - - diff --git a/src/benchmarkHelper.ts b/src/benchmarkHelper.ts index 0fd5833f..b2430ce8 100644 --- a/src/benchmarkHelper.ts +++ b/src/benchmarkHelper.ts @@ -73,11 +73,7 @@ export class Benchmark { ].join(''), ].join('\n') - fs.writeFileSync( - path.join(__dirname, `./${this.name}/BENCHMARK.md`), - content, - 'utf-8' - ) + fs.writeFileSync(path.join(__dirname, `./${this.name}/BENCHMARK.md`), content, 'utf-8') } generateResultTable(): string { diff --git a/src/chunk/chunk.spec.ts b/src/chunk/chunk.spec.ts index 16a27b6c..824a8fce 100644 --- a/src/chunk/chunk.spec.ts +++ b/src/chunk/chunk.spec.ts @@ -17,18 +17,7 @@ describe('chunk', () => { it('splits an array of objects into chunks', () => { expect( - chunk( - [ - { a: '1' }, - { a: '2' }, - { a: '3' }, - { a: '4' }, - { a: '5' }, - { a: '6' }, - { a: '7' }, - ], - 4 - ) + chunk([{ a: '1' }, { a: '2' }, { a: '3' }, { a: '4' }, { a: '5' }, { a: '6' }, { a: '7' }], 4) ).toEqual([ [{ a: '1' }, { a: '2' }, { a: '3' }, { a: '4' }], [{ a: '5' }, { a: '6' }, { a: '7' }], diff --git a/src/chunk/chunk.ts b/src/chunk/chunk.ts index 317a9952..4b536cfb 100644 --- a/src/chunk/chunk.ts +++ b/src/chunk/chunk.ts @@ -19,5 +19,3 @@ export function chunk(array: Array, size: number): Array> { return chunked } - - diff --git a/src/clone/clone.ts b/src/clone/clone.ts index c67dace8..e8e91c87 100644 --- a/src/clone/clone.ts +++ b/src/clone/clone.ts @@ -12,14 +12,7 @@ * ``` */ -type JSONValue = - | string - | number - | boolean - | null - | undefined - | JSONObject - | JSONArray +type JSONValue = string | number | boolean | null | undefined | JSONObject | JSONArray interface JSONObject { [key: string]: JSONValue @@ -30,5 +23,3 @@ interface JSONArray extends Array {} export function clone(value: T): T { return JSON.parse(JSON.stringify(value)) } - - diff --git a/src/compact/compact.spec.ts b/src/compact/compact.spec.ts index f96ea582..d7e57827 100644 --- a/src/compact/compact.spec.ts +++ b/src/compact/compact.spec.ts @@ -13,18 +13,7 @@ describe('compact', () => { const original = ['a', false, 'b', null, 'c', 0, 'd', '', 'e', undefined] const compacted = compact(original) - expect(original).toEqual([ - 'a', - false, - 'b', - null, - 'c', - 0, - 'd', - '', - 'e', - undefined, - ]) + expect(original).toEqual(['a', false, 'b', null, 'c', 0, 'd', '', 'e', undefined]) expect(compacted).toEqual(['a', 'b', 'c', 'd', 'e']) }) @@ -55,13 +44,7 @@ describe('compact', () => { { e: 1 }, undefined, ]) - expect(compacted).toEqual([ - { a: 1 }, - { b: 1 }, - { c: 1 }, - { d: 1 }, - { e: 1 }, - ]) + expect(compacted).toEqual([{ a: 1 }, { b: 1 }, { c: 1 }, { d: 1 }, { e: 1 }]) }) it('compacts completely falsy arrays', () => { diff --git a/src/compact/compact.ts b/src/compact/compact.ts index b7dd67a9..4505ced6 100644 --- a/src/compact/compact.ts +++ b/src/compact/compact.ts @@ -14,5 +14,3 @@ type Falsy = undefined | null | false | 0 | '' export function compact(array: Array): Array { return array.filter(Boolean) as Array } - - diff --git a/src/debounce/debounce.ts b/src/debounce/debounce.ts index 925ad2b6..cbbaeb77 100644 --- a/src/debounce/debounce.ts +++ b/src/debounce/debounce.ts @@ -10,10 +10,7 @@ * ``` */ -export function debounce void>( - func: TFunc, - wait: number -) { +export function debounce void>(func: TFunc, wait: number) { let timeoutID: number | null = null return function (this: any, ...args: any[]) { @@ -21,5 +18,3 @@ export function debounce void>( timeoutID = window.setTimeout(() => func.apply(this, args), wait) } as (...args: Parameters) => void } - - diff --git a/src/duplicates/duplicates.spec.ts b/src/duplicates/duplicates.spec.ts index 6a62d1f7..529ad1d2 100644 --- a/src/duplicates/duplicates.spec.ts +++ b/src/duplicates/duplicates.spec.ts @@ -7,11 +7,7 @@ describe('duplicates', () => { }) it('filters the duplicate occurrences of an array of strings', () => { - expect(duplicates(['foo', 'bar', 'foo', 'foobar', 'foo', 'foo'])).toEqual([ - 'foo', - 'foo', - 'foo', - ]) + expect(duplicates(['foo', 'bar', 'foo', 'foobar', 'foo', 'foo'])).toEqual(['foo', 'foo', 'foo']) }) it('filters the duplicate occurrences of an array of objects with an identity function', () => { diff --git a/src/duplicates/duplicates.ts b/src/duplicates/duplicates.ts index 53409ddf..a38ac90a 100644 --- a/src/duplicates/duplicates.ts +++ b/src/duplicates/duplicates.ts @@ -18,10 +18,7 @@ * ``` */ -export function duplicates( - array: Array, - identity?: (x: T) => any -): Array { +export function duplicates(array: Array, identity?: (x: T) => any): Array { if (!identity) { return primitiveDuplicates(array) } @@ -33,12 +30,7 @@ function primitiveDuplicates(array: Array): Array { return array.filter((x, i, self) => self.indexOf(x) !== i) } -function objectDuplicates( - array: Array, - identity: (x: T) => any -): Array { +function objectDuplicates(array: Array, identity: (x: T) => any): Array { const identities = array.map((x) => identity(x)) return array.filter((_, i) => identities.indexOf(identities[i]) !== i) } - - diff --git a/src/escapeRegExp/escapeRegExp.spec.ts b/src/escapeRegExp/escapeRegExp.spec.ts index 5316fb7e..4240b2cf 100644 --- a/src/escapeRegExp/escapeRegExp.spec.ts +++ b/src/escapeRegExp/escapeRegExp.spec.ts @@ -2,9 +2,7 @@ import { escapeRegExp } from './escapeRegExp' describe('escapeRegExp', () => { it('can escape the special characters in a string', () => { - expect(escapeRegExp('How much $$$ for this?')).toEqual( - 'How much \\$\\$\\$ for this\\?' - ) + expect(escapeRegExp('How much $$$ for this?')).toEqual('How much \\$\\$\\$ for this\\?') expect(escapeRegExp('\\')).toEqual('\\\\') expect(escapeRegExp('^^')).toEqual('\\^\\^') }) diff --git a/src/escapeRegExp/escapeRegExp.ts b/src/escapeRegExp/escapeRegExp.ts index 30b35a88..6635e979 100644 --- a/src/escapeRegExp/escapeRegExp.ts +++ b/src/escapeRegExp/escapeRegExp.ts @@ -14,5 +14,3 @@ export function escapeRegExp(string: string): string { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') } - - diff --git a/src/generateDocs.ts b/src/generateDocs.ts index 0fdb077f..591911d6 100644 --- a/src/generateDocs.ts +++ b/src/generateDocs.ts @@ -23,10 +23,7 @@ async function run() { subText.push(`[Source](./src/${module.name}/index.ts)`) // Link to the benchmark - const benchmarkPath = path.join( - __dirname, - `./${module.name}/BENCHMARK.md` - ) + const benchmarkPath = path.join(__dirname, `./${module.name}/BENCHMARK.md`) const hasBenchmark = fs.existsSync(benchmarkPath) if (hasBenchmark) { subText.push(`[Benchmark](./src/${module.name}/BENCHMARK.md)`) @@ -56,10 +53,7 @@ async function run() { // ---------------------------------------------------------------------------- async function calculateModuleSizes(name: string) { - const content = fs.readFileSync( - path.join(__dirname, `../dist/esm/${name}/${name}.js`), - 'utf-8' - ) + const content = fs.readFileSync(path.join(__dirname, `../dist/esm/${name}/${name}.js`), 'utf-8') const contentMin = (await terser.minify(content)).code || '' const contentMinZip = pako.deflate(contentMin) diff --git a/src/get/BENCHMARK.md b/src/get/BENCHMARK.md index 70ed7055..5b7e3f2e 100644 --- a/src/get/BENCHMARK.md +++ b/src/get/BENCHMARK.md @@ -2,9 +2,9 @@ [Source for this benchmark](./benchmark.ts) -| | lodash | flocky | -| --- | --- | --- | -| array path | **577,865 ops/sec (100.00%)** | 460,501 ops/sec (79.69%) | -| string path | 215,076 ops/sec (47.18%) | **455,867 ops/sec (100.00%)** | +| | lodash | flocky | +| ----------- | ----------------------------- | ----------------------------- | +| array path | **577,865 ops/sec (100.00%)** | 460,501 ops/sec (79.69%) | +| string path | 215,076 ops/sec (47.18%) | **455,867 ops/sec (100.00%)** | -Generated at 2020-06-27 with Node.JS v14.4.0 \ No newline at end of file +Generated at 2020-06-27 with Node.JS v14.4.0 diff --git a/src/get/get.ts b/src/get/get.ts index 9621c982..7c25f896 100644 --- a/src/get/get.ts +++ b/src/get/get.ts @@ -58,5 +58,3 @@ function getWithArrayPath(object: object, path: Array): any { return index === length ? current : undefined } - - diff --git a/src/hash/BENCHMARK.md b/src/hash/BENCHMARK.md index 7b5098d5..0f4dfc45 100644 --- a/src/hash/BENCHMARK.md +++ b/src/hash/BENCHMARK.md @@ -2,9 +2,9 @@ [Source for this benchmark](./benchmark.ts) -| | flocky | -| --- | --- | +| | flocky | +| ---------- | ----------------------------- | | 1KB String | **109,262 ops/sec (100.00%)** | -| 1MB String | **122 ops/sec (100.00%)** | +| 1MB String | **122 ops/sec (100.00%)** | -Generated at 2020-06-27 with Node.JS v14.4.0 \ No newline at end of file +Generated at 2020-06-27 with Node.JS v14.4.0 diff --git a/src/hash/hash.ts b/src/hash/hash.ts index 11b46c69..3a655086 100644 --- a/src/hash/hash.ts +++ b/src/hash/hash.ts @@ -79,5 +79,3 @@ function mul32(m: number, n: number) { return (((nHigh * m) | 0) + ((nLow * m) | 0)) | 0 } - - diff --git a/src/identifier/identifier.spec.ts b/src/identifier/identifier.spec.ts index a4d555ae..5d09e4a8 100644 --- a/src/identifier/identifier.spec.ts +++ b/src/identifier/identifier.spec.ts @@ -1,8 +1,7 @@ import { dateNow, mathRandom } from '../testHelpers' import { identifier } from './identifier' -const UUID_FORMAT = - /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i +const UUID_FORMAT = /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i describe('identifier', () => { beforeEach(() => { diff --git a/src/identifier/identifier.ts b/src/identifier/identifier.ts index 58a92d17..115ca4de 100644 --- a/src/identifier/identifier.ts +++ b/src/identifier/identifier.ts @@ -51,5 +51,3 @@ export function identifier(): string { return uuid } - - diff --git a/src/matchAll/matchAll.spec.ts b/src/matchAll/matchAll.spec.ts index c4d1fce8..8d58725e 100644 --- a/src/matchAll/matchAll.spec.ts +++ b/src/matchAll/matchAll.spec.ts @@ -16,9 +16,7 @@ describe('matchAll', () => { }) it('matches all occurrences of the regular expression with multiple submatches', () => { - expect( - matchAll(/(\d+) and (\d+)/g, '200 and 400 or also 300 and 500') - ).toEqual([ + expect(matchAll(/(\d+) and (\d+)/g, '200 and 400 or also 300 and 500')).toEqual([ { match: '200 and 400', subMatches: ['200', '400'], index: 0 }, { match: '300 and 500', subMatches: ['300', '500'], index: 20 }, ]) diff --git a/src/matchAll/matchAll.ts b/src/matchAll/matchAll.ts index 390354ee..52bbfe21 100644 --- a/src/matchAll/matchAll.ts +++ b/src/matchAll/matchAll.ts @@ -23,5 +23,3 @@ function formatMatch(match: RegExpMatchArray) { index: match.index, } } - - diff --git a/src/max/max.ts b/src/max/max.ts index a292fed2..1cea384f 100644 --- a/src/max/max.ts +++ b/src/max/max.ts @@ -12,5 +12,3 @@ export function max(array: Array): number { return Math.max.apply(null, array) } - - diff --git a/src/memoize/BENCHMARK.md b/src/memoize/BENCHMARK.md index 82a876ec..bd103127 100644 --- a/src/memoize/BENCHMARK.md +++ b/src/memoize/BENCHMARK.md @@ -2,9 +2,9 @@ [Source for this benchmark](./benchmark.ts) -| | lodash | fast-memoize | flocky | -| --- | --- | --- | --- | -| monadic | 61,516,142 ops/sec (40.39%) | **152,318,396 ops/sec (100.00%)** | 150,923,324 ops/sec (99.08%) | -| variadic | **2,121,499 ops/sec (100.00%)** | 1,020,555 ops/sec (48.11%) | 1,948,001 ops/sec (91.82%) | +| | lodash | fast-memoize | flocky | +| -------- | ------------------------------- | --------------------------------- | ---------------------------- | +| monadic | 61,516,142 ops/sec (40.39%) | **152,318,396 ops/sec (100.00%)** | 150,923,324 ops/sec (99.08%) | +| variadic | **2,121,499 ops/sec (100.00%)** | 1,020,555 ops/sec (48.11%) | 1,948,001 ops/sec (91.82%) | -Generated at 2021-02-17 with Node.JS v14.4.0 \ No newline at end of file +Generated at 2021-02-17 with Node.JS v14.4.0 diff --git a/src/memoize/memoize.benchmark.ts b/src/memoize/memoize.benchmark.ts index 89fa2836..977e2517 100644 --- a/src/memoize/memoize.benchmark.ts +++ b/src/memoize/memoize.benchmark.ts @@ -36,9 +36,7 @@ benchmark.add({ func: () => flockyMonadicFunc(1), }) -const lodashVariadicFunc = lodash.memoize(variadicFunc, (...args) => - JSON.stringify(args) -) +const lodashVariadicFunc = lodash.memoize(variadicFunc, (...args) => JSON.stringify(args)) benchmark.add({ library: 'lodash', input: 'variadic', diff --git a/src/memoize/memoize.spec.ts b/src/memoize/memoize.spec.ts index a37a169c..e0a66327 100644 --- a/src/memoize/memoize.spec.ts +++ b/src/memoize/memoize.spec.ts @@ -1,4 +1,4 @@ -import {sleep} from '../sleep/sleep' +import { sleep } from '../sleep/sleep' import { memoize } from './memoize' type NumberObject = { n: number } @@ -114,10 +114,7 @@ describe('memoize', () => { it('memoizes function calls with spread non-primitive arguments', () => { const calls: Array> = [] - const func = ( - multiplier: NumberObject, - ...numbers: Array - ) => { + const func = (multiplier: NumberObject, ...numbers: Array) => { calls.push([multiplier, ...numbers]) return numbers.map((x) => multiplier.n * x.n) } @@ -136,8 +133,7 @@ describe('memoize', () => { }) it('passes arguments as their original primitive', () => { - const func = (x: any) => - typeof x === 'object' ? x.constructor.name : typeof x + const func = (x: any) => (typeof x === 'object' ? x.constructor.name : typeof x) const memoizedFunc = memoize(func) diff --git a/src/memoize/memoize.ts b/src/memoize/memoize.ts index 08c1b5a4..92b1e87d 100644 --- a/src/memoize/memoize.ts +++ b/src/memoize/memoize.ts @@ -27,14 +27,13 @@ type MemoizeStrategy = 'monadic' | 'variadic' type MemoizeSerializer = (...args: Array) => string -export function memoize< - TThis, - TReturn, - TFunc extends (...args: any[]) => TReturn ->(this: TThis, func: TFunc, options: MemoizeOptions = {}): TFunc { +export function memoize TReturn>( + this: TThis, + func: TFunc, + options: MemoizeOptions = {} +): TFunc { const strategy = - options.strategy === 'monadic' || - (options.strategy !== 'variadic' && func.length <= 1) + options.strategy === 'monadic' || (options.strategy !== 'variadic' && func.length <= 1) ? monadic : variadic const cache = options.ttl ? ttlCache(options.ttl) : defaultCache() @@ -45,9 +44,7 @@ export function memoize< function isPrimitive(value: any) { // We can not treat strings as primitive, because they overwrite numbers - return ( - value == null || typeof value === 'number' || typeof value === 'boolean' - ) + return value == null || typeof value === 'number' || typeof value === 'boolean' } function monadic TReturn>( diff --git a/src/min/min.ts b/src/min/min.ts index 273ec5d7..48a437a7 100644 --- a/src/min/min.ts +++ b/src/min/min.ts @@ -12,5 +12,3 @@ export function min(array: Array): number { return Math.min.apply(null, array) } - - diff --git a/src/omit/BENCHMARK.md b/src/omit/BENCHMARK.md index c33b9f97..c1e51d6d 100644 --- a/src/omit/BENCHMARK.md +++ b/src/omit/BENCHMARK.md @@ -2,10 +2,10 @@ [Source for this benchmark](./benchmark.ts) -| | flocky | -| --- | --- | -| 5 properties / 3 omitted | **5,352,332 ops/sec (100.00%)** | -| 26 properties / 3 omitted | **291,222 ops/sec (100.00%)** | -| 10 properties / 55 omitted | **736,211 ops/sec (100.00%)** | +| | flocky | +| -------------------------- | ------------------------------- | +| 5 properties / 3 omitted | **5,352,332 ops/sec (100.00%)** | +| 26 properties / 3 omitted | **291,222 ops/sec (100.00%)** | +| 10 properties / 55 omitted | **736,211 ops/sec (100.00%)** | -Generated at 2020-09-14 with Node.JS v14.4.0 \ No newline at end of file +Generated at 2020-09-14 with Node.JS v14.4.0 diff --git a/src/omit/omit.ts b/src/omit/omit.ts index 73d5f9d3..603ea121 100644 --- a/src/omit/omit.ts +++ b/src/omit/omit.ts @@ -12,10 +12,7 @@ type Omit = Pick> -export function omit( - object: T, - keys: Array -): Omit { +export function omit(object: T, keys: Array): Omit { const objectKeys = Object.keys(object) as Array let result: Partial = {} @@ -29,5 +26,3 @@ export function omit( return result as Omit } - - diff --git a/src/parseModules.ts b/src/parseModules.ts index 661a1ce3..3f2b898f 100644 --- a/src/parseModules.ts +++ b/src/parseModules.ts @@ -24,7 +24,7 @@ export function parseModules(): Array { function getModulePaths() { const paths = glob.sync(path.join(__dirname, '../src/*/*.ts')) - return paths.filter(path => path.match(/src\/(.*?)\/\1.ts/)) + return paths.filter((path) => path.match(/src\/(.*?)\/\1.ts/)) } function parseModule(filePath: string): ModuleFile | false { @@ -83,9 +83,6 @@ function parseExample(example: string): Example { return { code, - expected: - expected === '' || expected === 'undefined' - ? undefined - : eval(`(${expected})`), + expected: expected === '' || expected === 'undefined' ? undefined : eval(`(${expected})`), } } diff --git a/src/pick/pick.ts b/src/pick/pick.ts index 9cb7e604..f909ed07 100644 --- a/src/pick/pick.ts +++ b/src/pick/pick.ts @@ -10,10 +10,7 @@ * ``` */ -export function pick( - object: T, - keys: Array -): Pick { +export function pick(object: T, keys: Array): Pick { let result: Partial = {} keys.forEach((key) => { @@ -22,5 +19,3 @@ export function pick( return result as Pick } - - diff --git a/src/random/random.spec.ts b/src/random/random.spec.ts index fb4528ed..00a80457 100644 --- a/src/random/random.spec.ts +++ b/src/random/random.spec.ts @@ -38,8 +38,7 @@ describe('random (fuzzing)', () => { }) it('generates valid integers with minimum and maximum bounds', () => { - const isInBounds = (x: number) => - x >= Number.MIN_SAFE_INTEGER && x <= Number.MAX_SAFE_INTEGER + const isInBounds = (x: number) => x >= Number.MIN_SAFE_INTEGER && x <= Number.MAX_SAFE_INTEGER for (let i = 0; i !== ITERATIONS; i++) { const number = random(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER) diff --git a/src/random/random.ts b/src/random/random.ts index 8a48588a..338c43d8 100644 --- a/src/random/random.ts +++ b/src/random/random.ts @@ -31,5 +31,3 @@ function randomFloat(lower: number, upper: number): number { function randomInteger(lower: number, upper: number): number { return Math.floor(Math.random() * (upper - lower + 1) + lower) } - - diff --git a/src/randomString/randomString.ts b/src/randomString/randomString.ts index cb87024b..bc8631c7 100644 --- a/src/randomString/randomString.ts +++ b/src/randomString/randomString.ts @@ -9,8 +9,7 @@ * ``` */ -const CHARACTERS = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' +const CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' export function randomString(length: number): string { let string = '' @@ -22,5 +21,3 @@ export function randomString(length: number): string { return string } - - diff --git a/src/roundTo/roundTo.ts b/src/roundTo/roundTo.ts index ce809b44..fd2e6be3 100644 --- a/src/roundTo/roundTo.ts +++ b/src/roundTo/roundTo.ts @@ -51,5 +51,3 @@ function shift(number: number, exponent: number): number { const [numberBase, numberExponent] = `${number}e`.split('e') return Number(`${numberBase}e${Number(numberExponent) + exponent}`) } - - diff --git a/src/sample/sample.ts b/src/sample/sample.ts index 1568b436..d88b96c4 100644 --- a/src/sample/sample.ts +++ b/src/sample/sample.ts @@ -13,5 +13,3 @@ export function sample(array: Array): T { const index = Math.floor(Math.random() * array.length) return array[index] } - - diff --git a/src/shuffle/shuffle.ts b/src/shuffle/shuffle.ts index 8f2047fc..6e639866 100644 --- a/src/shuffle/shuffle.ts +++ b/src/shuffle/shuffle.ts @@ -38,5 +38,3 @@ export function shuffle(array: Array): Array { return array } - - diff --git a/src/sleep/sleep.ts b/src/sleep/sleep.ts index d062f37c..3b86f087 100644 --- a/src/sleep/sleep.ts +++ b/src/sleep/sleep.ts @@ -11,5 +11,3 @@ export function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)) } - - diff --git a/src/slugify/slugify.ts b/src/slugify/slugify.ts index 0aad6615..880ef33a 100644 --- a/src/slugify/slugify.ts +++ b/src/slugify/slugify.ts @@ -16,5 +16,3 @@ export function slugify(string: string): string { .replace(/[^a-z0-9]+/g, '-') // Replace all clusters of non-word characters with a single "-" .replace(/^-|-$/g, '') // Trim "-" from start and end } - - diff --git a/src/sum/sum.ts b/src/sum/sum.ts index ecaec610..38f34c64 100644 --- a/src/sum/sum.ts +++ b/src/sum/sum.ts @@ -12,5 +12,3 @@ export function sum(array: Array): number { return array.reduce((a, b) => a + b, 0) } - - diff --git a/src/testHelpers.ts b/src/testHelpers.ts index 684d1170..13593cbb 100644 --- a/src/testHelpers.ts +++ b/src/testHelpers.ts @@ -1,13 +1,11 @@ const RANDOM_OUTPUT = [ - 0.7341312319841373, 0.5153569814278522, 0.6039244693324568, - 0.8485123814547479, 0.5305323323446391, 0.9936904462715297, 0.152741118641178, - 0.6284452050928289, 0.1333952722446896, 0.19323989178442735, - 0.6210946032149509, 0.715356956262492, 0.1601444486850756, 0.2826657106671773, - 0.3360975043209571, 0.7686446730864509, 0.2482518764495567, - 0.39590294569110873, 0.8810226597671855, 0.8645898520605233, - 0.08819117131655063, 0.9746880765364763, 0.8191862710617215, - 0.6093775445189631, 0.5680783823402815, 0.4094440218703661, - 0.03730391719730841, 0.17578915337316725, 0.8865419358339801, + 0.7341312319841373, 0.5153569814278522, 0.6039244693324568, 0.8485123814547479, + 0.5305323323446391, 0.9936904462715297, 0.152741118641178, 0.6284452050928289, 0.1333952722446896, + 0.19323989178442735, 0.6210946032149509, 0.715356956262492, 0.1601444486850756, + 0.2826657106671773, 0.3360975043209571, 0.7686446730864509, 0.2482518764495567, + 0.39590294569110873, 0.8810226597671855, 0.8645898520605233, 0.08819117131655063, + 0.9746880765364763, 0.8191862710617215, 0.6093775445189631, 0.5680783823402815, + 0.4094440218703661, 0.03730391719730841, 0.17578915337316725, 0.8865419358339801, 0.2227008300658413, ] diff --git a/src/toMap/toMap.ts b/src/toMap/toMap.ts index 847422f1..4bd935ea 100644 --- a/src/toMap/toMap.ts +++ b/src/toMap/toMap.ts @@ -47,11 +47,7 @@ export function toMap< Element extends object, Key extends MapableKeys, Target extends keyof Element ->( - array: Array, - key: Key, - target: Target -): { [key: string]: Element[Target] | undefined } +>(array: Array, key: Key, target: Target): { [key: string]: Element[Target] | undefined } export function toMap< Element extends object, diff --git a/src/unique/BENCHMARK.md b/src/unique/BENCHMARK.md index f2c52357..f264ab11 100644 --- a/src/unique/BENCHMARK.md +++ b/src/unique/BENCHMARK.md @@ -2,9 +2,9 @@ [Source for this benchmark](./benchmark.ts) -| | es6 filter | lodash | flocky | -| --- | --- | --- | --- | -| large array | 32 ops/sec (3.15%) | 825 ops/sec (81.28%) | **1,015 ops/sec (100.00%)** | +| | es6 filter | lodash | flocky | +| ----------- | ------------------------ | ------------------------ | ----------------------------- | +| large array | 32 ops/sec (3.15%) | 825 ops/sec (81.28%) | **1,015 ops/sec (100.00%)** | | small array | 155,905 ops/sec (96.98%) | 137,664 ops/sec (85.64%) | **160,755 ops/sec (100.00%)** | -Generated at 2020-06-27 with Node.JS v14.4.0 \ No newline at end of file +Generated at 2020-06-27 with Node.JS v14.4.0 diff --git a/src/unique/unique.spec.ts b/src/unique/unique.spec.ts index 9bdeacb5..b1f24cba 100644 --- a/src/unique/unique.spec.ts +++ b/src/unique/unique.spec.ts @@ -7,11 +7,7 @@ describe('unique', () => { }) it('filters the unique occurrences of an array of strings', () => { - expect(unique(['foo', 'bar', 'foo', 'foobar', 'foo', 'foo'])).toEqual([ - 'foo', - 'bar', - 'foobar', - ]) + expect(unique(['foo', 'bar', 'foo', 'foobar', 'foo', 'foo'])).toEqual(['foo', 'bar', 'foobar']) }) it('filters the unique occurrences of an array of objects with an identity function', () => { diff --git a/src/unique/unique.ts b/src/unique/unique.ts index d0abc475..da0e14a1 100644 --- a/src/unique/unique.ts +++ b/src/unique/unique.ts @@ -34,5 +34,3 @@ function objectUnique(array: Array, identity: (x: T) => any): Array { const identities = array.map((x) => identity(x)) return array.filter((_, i) => identities.indexOf(identities[i]) === i) } - -