style(*): Setup prettier and apply formatting (#24)

* chore: add prettierrc

* chore: apply format with prettier config

* chore: eslint error fix
This commit is contained in:
Minsoo Kim 2024-06-04 17:19:26 +09:00 committed by GitHub
parent 21fa121853
commit cf65b2c601
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
224 changed files with 890 additions and 884 deletions

View File

@ -14,8 +14,8 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v4
with:
cache: "yarn"
cache-dependency-path: "yarn.lock"
node-version-file: ".nvmrc"
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
node-version-file: '.nvmrc'
- run: yarn install
- run: yarn blc ${{ github.event.inputs.url }} --ro

View File

@ -3,9 +3,9 @@ name: Release
on:
push:
branches:
- "*"
- '*'
tags:
- "v*.*.*"
- 'v*.*.*'
jobs:
release:
@ -20,9 +20,9 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v4
with:
cache: "yarn"
cache-dependency-path: "yarn.lock"
node-version-file: ".nvmrc"
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
node-version-file: '.nvmrc'
- if: github.ref_type == 'branch'
run: |
jq \
@ -41,7 +41,7 @@ jobs:
heading-title-text: version ${{ github.ref_name }}
ignore-case: true
omit-heading: true
- run: "cat ${{ steps.extract-changelog.outputs.output-file }}"
- run: 'cat ${{ steps.extract-changelog.outputs.output-file }}'
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')

13
.prettierignore Normal file
View File

@ -0,0 +1,13 @@
.yarn/*
.pnp.cjs
.pnp.loader.mjs
node_modules
coverage
dist
esm
.junit
out
*.d.ts
*.tgz

14
.prettierrc Normal file
View File

@ -0,0 +1,14 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "lf",
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}

View File

@ -1,7 +1,3 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
"recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}

View File

@ -13,5 +13,5 @@
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
}
}

View File

@ -12,7 +12,6 @@ es-toolkit은 높은 성능과 작은 번들 사이즈, 강력한 타입을 자
- es-toolkit은 TypeScript 타입이 내장되어 있고, 직관적이고 정확한 타입을 추구해요. [isNotNil](https://es-toolkit.slash.page/ko/reference/predicate/isNotNil.html) 같은 사용하기 편리한 유틸리티 함수도 제공해요.
- es-toolkit은 100% 테스트 커버리지를 유지하면서, 높은 안정성을 자랑해요.
## 기여하기
커뮤니티에 있는 모든 분들에게 기여를 환영해요. 아래에 작성되어 있는 기여 가이드를 확인하세요.

View File

@ -12,7 +12,6 @@ es-toolkit is a state-of-the-art, high-performance JavaScript utility library wi
- es-toolkit includes built-in TypeScript support, with straightforward yet robust types. It also provides useful type guards such as [isNotNil](https://es-toolkit.slash.page/reference/predicate/isNotNil.html).
- es-toolkit is battle-tested with 100% test coverage, ensuring reliability and robustness.
## Contributing
We welcome contribution from everyone in the community. Read below for detailed contribution guide.

View File

@ -1,6 +1,3 @@
module.exports = {
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-typescript'),
],
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-typescript')],
};

View File

@ -5,9 +5,9 @@ import { chunk as chunkLodash } from 'lodash';
describe('chunk', () => {
bench('es-toolkit', () => {
chunkToolkit([1, 2, 3, 4, 5, 6], 3);
})
});
bench('lodash', () => {
chunkLodash([1, 2, 3, 4, 5, 6], 3);
})
});
});

View File

@ -4,12 +4,12 @@ import { clamp as clampLodash } from 'lodash';
describe('clamp', () => {
bench('es-toolkit', () => {
clampToolkit(10, 5, 15)
clampToolkit(10, 5)
})
clampToolkit(10, 5, 15);
clampToolkit(10, 5);
});
bench('lodash', () => {
clampLodash(10, 5, 15)
clampLodash(10, 5)
})
clampLodash(10, 5, 15);
clampLodash(10, 5);
});
});

View File

@ -5,9 +5,9 @@ import { difference as differenceLodash } from 'lodash';
describe('difference', () => {
bench('es-toolkit', () => {
differenceToolkit([1, 2, 3], [2]);
})
});
bench('lodash', () => {
differenceLodash([1, 2, 3], [2]);
})
});
});

View File

@ -5,9 +5,9 @@ import { differenceBy as differenceByLodash } from 'lodash';
describe('differenceBy', () => {
bench('es-toolkit', () => {
differenceByToolkit([1.2, 2.3, 3.4], [1.2], Math.floor);
})
});
bench('lodash', () => {
differenceByLodash([1.2, 2.3, 3.4], [1.2], Math.floor);
})
});
});

View File

@ -5,9 +5,9 @@ import { differenceWith as differenceWithLodash } from 'lodash';
describe('differenceWith', () => {
bench('es-toolkit', () => {
differenceWithToolkit([1.2, 2.3, 3.4], [1.2], (x, y) => Math.floor(x) === Math.floor(y));
})
});
bench('lodash', () => {
differenceWithLodash([1.2, 2.3, 3.4], [1.2], (x, y) => Math.floor(x) === Math.floor(y));
})
});
});

View File

@ -5,9 +5,9 @@ import { drop as dropLodash } from 'lodash';
describe('drop', () => {
bench('es-toolkit', () => {
dropToolkit([1, 2, 3, 4, 5, 6], 3);
})
});
bench('lodash', () => {
dropLodash([1, 2, 3, 4, 5, 6], 3);
})
});
});

View File

@ -5,9 +5,9 @@ import { dropRight as dropRightLodash } from 'lodash';
describe('dropRight', () => {
bench('es-toolkit', () => {
dropRightToolkit([1, 2, 3, 4, 5, 6], 3);
})
});
bench('lodash', () => {
dropRightLodash([1, 2, 3, 4, 5, 6], 3);
})
});
});

View File

@ -5,9 +5,9 @@ import { dropRightWhile as dropRightWhileLodash } from 'lodash';
describe('dropRightWhile', () => {
bench('es-toolkit', () => {
dropRightWhileToolkit([1.2, 2.3, 3.4], x => x < 2);
})
});
bench('lodash', () => {
dropRightWhileLodash([1.2, 2.3, 3.4], x => x < 2);
})
});
});

View File

@ -5,9 +5,9 @@ import { dropWhile as dropWhileLodash } from 'lodash';
describe('dropWhile', () => {
bench('es-toolkit', () => {
dropWhileToolkit([1.2, 2.3, 3.4], x => x < 2);
})
});
bench('lodash', () => {
dropWhileLodash([1.2, 2.3, 3.4], x => x < 2);
})
});
});

View File

@ -9,11 +9,11 @@ describe('groupBy', () => {
{ category: 'fruit', name: 'banana' },
{ category: 'vegetable', name: 'carrot' },
{ category: 'fruit', name: 'pear' },
{ category: 'vegetable', name: 'broccoli' }
{ category: 'vegetable', name: 'broccoli' },
];
groupByToolkit(array, item => item.category);
})
});
bench('lodash', () => {
const array = [
@ -21,9 +21,9 @@ describe('groupBy', () => {
{ category: 'fruit', name: 'banana' },
{ category: 'vegetable', name: 'carrot' },
{ category: 'fruit', name: 'pear' },
{ category: 'vegetable', name: 'broccoli' }
{ category: 'vegetable', name: 'broccoli' },
];
groupByLodash(array, item => item.category);
})
});
});

View File

@ -5,9 +5,9 @@ import { intersection as intersectionLodash } from 'lodash';
describe('intersection', () => {
bench('es-toolkit', () => {
intersectionToolkit([1, 2, 3], [2, 4]);
})
});
bench('lodash', () => {
intersectionLodash([1, 2, 3], [2, 4]);
})
});
});

View File

@ -8,12 +8,12 @@ describe('intersectionBy', () => {
const array2 = [{ id: 2 }, { id: 4 }];
const mapper = item => item.id;
intersectionByToolkit(array1, array2, mapper);
})
});
bench('lodash', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const mapper = item => item.id;
intersectionByLodash(array1, array2, mapper);
})
});
});

View File

@ -8,12 +8,12 @@ describe('intersectionWith', () => {
const array2 = [{ id: 2 }, { id: 4 }];
const areItemsEqual = (a, b) => a.id === b.id;
intersectionWithToolkit(array1, array2, areItemsEqual);
})
});
bench('lodash', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const areItemsEqual = (a, b) => a.id === b.id;
intersectionWithLodash(array1, array2, areItemsEqual);
})
});
});

View File

@ -8,12 +8,12 @@ describe('isNil', () => {
isNilToolkit(undefined);
isNilToolkit(123);
isNilToolkit([1, 2, 3]);
})
});
bench('lodash', () => {
isNilLodash(null);
isNilLodash(undefined);
isNilLodash(123);
isNilLodash([1, 2, 3]);
})
});
});

View File

@ -4,10 +4,10 @@ import { omit as omitLodash } from 'lodash';
describe('omit', () => {
bench('es-toolkit', () => {
omitToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar'])
})
omitToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});
bench('lodash', () => {
omitLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar'])
})
omitLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});
});

View File

@ -1,17 +1,17 @@
import { bench, describe } from 'vitest';
import { omitBy as omitByToolkit } from 'es-toolkit';
import { omitBy as omitByLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('omitBy', () => {
bench('es-toolkit', () => {
const obj = { a: 1, b: 'omit', c: 3 };
const shouldOmit = (value: number | string, key: string) => typeof value === 'string';
const shouldOmit = (value: number | string) => typeof value === 'string';
omitByToolkit(obj, shouldOmit);
})
});
bench('lodash', () => {
const obj = { a: 1, b: 'omit', c: 3 };
const shouldOmit = (value: number | string, key: string) => typeof value === 'string';
const shouldOmit = (value: number | string) => typeof value === 'string';
omitByLodash(obj, shouldOmit);
})
});
});

View File

@ -5,9 +5,9 @@ import { partition as partitionLodash } from 'lodash';
describe('partition', () => {
bench('es-toolkit', () => {
partitionToolkit([1, 2, 3, 4, 5], x => x < 3);
})
});
bench('lodash', () => {
partitionLodash([1, 2, 3], x => x < 3);
})
});
});

View File

@ -4,10 +4,10 @@ import { pick as pickLodash } from 'lodash';
describe('pick', () => {
bench('es-toolkit', () => {
pickToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar'])
})
pickToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});
bench('lodash', () => {
pickLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar'])
})
pickLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});
});

View File

@ -5,9 +5,9 @@ import { round as roundLodash } from 'lodash';
describe('round', () => {
bench('es-toolkit', () => {
roundToolkit(1.2345, 2);
})
});
bench('lodash', () => {
roundLodash(1.2345, 2);
})
});
});

View File

@ -6,10 +6,10 @@ describe('sample', () => {
bench('es-toolkit', () => {
const array = [1, 2, 3, 4, 5];
sampleToolkit(array);
})
});
bench('lodash', () => {
const array = [1, 2, 3, 4, 5];
sampleLodash(array);
})
});
});

View File

@ -6,10 +6,10 @@ describe('shuffle', () => {
bench('es-toolkit', () => {
const array = [1, 2, 3, 4, 5];
shuffleToolkit(array);
})
});
bench('lodash', () => {
const array = [1, 2, 3, 4, 5];
shuffleLodash(array);
})
});
});

View File

@ -5,9 +5,9 @@ import { sum as sumLodash } from 'lodash';
describe('sum', () => {
bench('es-toolkit', () => {
sumToolkit([1, 2, 3]);
})
});
bench('lodash', () => {
sumLodash([1, 2, 3]);
})
});
});

View File

@ -5,9 +5,9 @@ import { take as takeLodash } from 'lodash';
describe('take', () => {
bench('es-toolkit', () => {
takeToolkit([1, 2, 3, 4], 2);
})
});
bench('lodash', () => {
takeLodash([1, 2, 3, 4], 2);
})
});
});

View File

@ -5,9 +5,9 @@ import { takeRight as takeRightLodash } from 'lodash';
describe('takeRight', () => {
bench('es-toolkit', () => {
takeRightToolkit([1, 2, 3, 4], 2);
})
});
bench('lodash', () => {
takeRightLodash([1, 2, 3, 4], 2);
})
});
});

View File

@ -5,9 +5,9 @@ import { takeRightWhile as takeRightWhileLodash } from 'lodash';
describe('takeRightWhile', () => {
bench('es-toolkit', () => {
takeRightWhileToolkit([5, 4, 3, 2, 1], n => n < 4);
})
});
bench('lodash', () => {
takeRightWhileLodash([5, 4, 3, 2, 1], n => n < 4);
})
});
});

View File

@ -5,9 +5,9 @@ import { takeWhile as takeWhileLodash } from 'lodash';
describe('takeWhile', () => {
bench('es-toolkit', () => {
takeWhileToolkit([5, 4, 3, 2, 1], n => n < 4);
})
});
bench('lodash', () => {
takeWhileLodash([5, 4, 3, 2, 1], n => n < 4);
})
});
});

View File

@ -1,17 +1,17 @@
import { bench, describe } from 'vitest';
import { union as unionToolkit } from 'es-toolkit';
import { union as unionLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('union', () => {
bench('es-toolkit', () => {
const array1 = [1, 2, 3];
const array2 = [3, 4, 5];
const result = unionToolkit(array1, array2);
})
unionToolkit(array1, array2);
});
bench('lodash', () => {
const array1 = [1, 2, 3];
const array2 = [3, 4, 5];
const result = unionLodash(array1, array2);
})
unionLodash(array1, array2);
});
});

View File

@ -5,9 +5,9 @@ import { unionBy as unionByLodash } from 'lodash';
describe('unionBy', () => {
bench('es-toolkit', () => {
unionByToolkit([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], x => x.id);
})
});
bench('lodash', () => {
unionByLodash([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], x => x.id);
})
});
});

View File

@ -8,12 +8,12 @@ describe('unionWith', () => {
const array2 = [{ id: 2 }, { id: 3 }];
const areItemsEqual = (a, b) => a.id === b.id;
unionWithToolkit(array1, array2, areItemsEqual);
})
});
bench('lodash', () => {
const array1 = [{ id: 1 }, { id: 2 }];
const array2 = [{ id: 2 }, { id: 3 }];
const areItemsEqual = (a, b) => a.id === b.id;
unionWithLodash(array1, array2, areItemsEqual);
})
});
});

View File

@ -5,9 +5,9 @@ import { uniq as uniqLodash } from 'lodash';
describe('uniq', () => {
bench('es-toolkit', () => {
uniqToolkit([11, 2, 3, 44, 11, 2, 3]);
})
});
bench('lodash', () => {
uniqLodash([11, 2, 3, 44, 11, 2, 3]);
})
});
});

View File

@ -5,9 +5,9 @@ import { xor as xorLodash } from 'lodash';
describe('xor', () => {
bench('es-toolkit', () => {
xorToolkit([1, 2, 3, 4], [3, 4, 5, 6]);
})
});
bench('lodash', () => {
xorLodash([1, 2, 3, 4], [3, 4, 5, 6]);
})
});
});

View File

@ -6,10 +6,10 @@ describe('xorBy', () => {
bench('es-toolkit', () => {
const idMapper = obj => obj.id;
xorByToolkit([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
})
});
bench('lodash', () => {
const idMapper = obj => obj.id;
xorByLodash([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
})
});
});

View File

@ -1,14 +1,13 @@
import { bench, describe } from 'vitest';
import { xorWith as xorWithToolkit } from 'es-toolkit';
import { xorWith as xorWithLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('xorWith', () => {
bench('es-toolkit', () => {
xorWithToolkit([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], (x, y) => x.id === y.id);
})
});
bench('lodash', () => {
const idMapper = obj => obj.id;
xorWithLodash([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], (x, y) => x.id === y.id);
})
});
});

View File

@ -5,9 +5,9 @@ import { zip as zipLodash } from 'lodash';
describe('zip', () => {
bench('es-toolkit', () => {
zipToolkit([1, 2, 3, 4], [3, 4, 5, 6]);
})
});
bench('lodash', () => {
zipLodash([1, 2, 3, 4], [3, 4, 5, 6]);
})
});
});

View File

@ -8,12 +8,12 @@ describe('zipWith', () => {
const arr2 = [3, 4];
const arr3 = [5, 6];
zipWithToolkit(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
})
});
bench('lodash', () => {
const arr1 = [1, 2];
const arr2 = [3, 4];
const arr3 = [5, 6];
zipWithLodash(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
})
});
});

View File

@ -7,7 +7,6 @@ export default defineConfig({
...shared,
locales: {
root: { label: 'English', ...en },
ko: { label: '한국어', ...ko }
ko: { label: '한국어', ...ko },
},
})
});

View File

@ -1,8 +1,9 @@
import { defineConfig, type DefaultTheme } from 'vitepress'
import { defineConfig, type DefaultTheme } from 'vitepress';
export const en = defineConfig({
lang: 'en',
description: 'A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.',
description:
'A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.',
themeConfig: {
nav: nav(),
@ -11,22 +12,22 @@ export const en = defineConfig({
editLink: {
pattern: 'https://github.com/toss/es-toolkit/edit/main/docs/:path',
text: 'Edit this page on GitHub'
text: 'Edit this page on GitHub',
},
footer: {
message: 'Released under the MIT License.',
copyright: `Copyright © ${new Date().getFullYear()} Viva Republica, Inc.`
}
}
})
copyright: `Copyright © ${new Date().getFullYear()} Viva Republica, Inc.`,
},
},
});
function nav(): DefaultTheme.NavItem[] {
return [
{ text: 'Home', link: '/' },
{ text: 'Introduction', link: '/intro' },
{ text: 'Reference', link: '/reference/array/chunk' },
]
];
}
function sidebar(): DefaultTheme.Sidebar {
@ -38,7 +39,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'Installation', link: '/installation' },
{ text: 'Impact on Bundle Size', link: '/bundle-size' },
{ text: 'Performance', link: '/performance' },
]
],
},
{
text: 'Reference',
@ -74,7 +75,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'xorWith', link: '/reference/array/xorWith' },
{ text: 'zip', link: '/reference/array/zip' },
{ text: 'zipWith', link: '/reference/array/zipWith' },
]
],
},
{
text: 'Function Utilities',
@ -82,7 +83,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'debounce', link: '/reference/function/debounce' },
{ text: 'throttle', link: '/reference/function/throttle' },
{ text: 'once', link: '/reference/function/once' },
]
],
},
{
text: 'Math Utilities',
@ -90,7 +91,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'clamp', link: '/reference/math/clamp' },
{ text: 'round', link: '/reference/math/round' },
{ text: 'sum', link: '/reference/math/sum' },
]
],
},
{
text: 'Object Utilities',
@ -99,7 +100,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'omitBy', link: '/reference/object/omitBy' },
{ text: 'pick', link: '/reference/object/pick' },
{ text: 'pickBy', link: '/reference/object/pickBy' },
]
],
},
{
text: 'Predicates',
@ -108,15 +109,13 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'isNotNil', link: '/reference/predicate/isNotNil' },
{ text: 'isNull', link: '/reference/predicate/isNull' },
{ text: 'isUndefined', link: '/reference/predicate/isUndefined' },
]
],
},
{
text: 'Promise Utilities',
items: [
{ text: 'delay', link: '/reference/promise/delay' },
]
}
]
}
]
items: [{ text: 'delay', link: '/reference/promise/delay' }],
},
],
},
];
}

View File

@ -1,4 +1,4 @@
import { defineConfig, type DefaultTheme } from 'vitepress'
import { defineConfig, type DefaultTheme } from 'vitepress';
export const ko = defineConfig({
lang: 'ko',
@ -11,22 +11,22 @@ export const ko = defineConfig({
editLink: {
pattern: 'https://github.com/toss/es-toolkit/edit/main/docs/:path',
text: 'GitHub에서 수정하기'
text: 'GitHub에서 수정하기',
},
footer: {
message: 'MIT 라이선스에 따라 배포됩니다.',
copyright: `Copyright © ${new Date().getFullYear()} Viva Republica, Inc.`
}
}
})
copyright: `Copyright © ${new Date().getFullYear()} Viva Republica, Inc.`,
},
},
});
function nav(): DefaultTheme.NavItem[] {
return [
{ text: '홈', link: '/ko' },
{ text: '소개', link: '/ko/intro' },
{ text: '레퍼런스', link: '/ko/reference/array/chunk' },
]
];
}
function sidebar(): DefaultTheme.Sidebar {
@ -38,7 +38,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: '설치', link: '/ko/installation' },
{ text: '번들 사이즈', link: '/ko/bundle-size' },
{ text: '성능', link: '/ko/performance' },
]
],
},
{
text: '레퍼런스',
@ -74,7 +74,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'xorWith', link: '/ko/reference/array/xorWith' },
{ text: 'zip', link: '/ko/reference/array/zip' },
{ text: 'zipWith', link: '/ko/reference/array/zipWith' },
]
],
},
{
text: '함수',
@ -82,7 +82,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'debounce', link: '/ko/reference/function/debounce' },
{ text: 'throttle', link: '/ko/reference/function/throttle' },
{ text: 'once', link: '/ko/reference/function/once' },
]
],
},
{
text: '숫자',
@ -90,7 +90,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'clamp', link: '/ko/reference/math/clamp' },
{ text: 'round', link: '/ko/reference/math/round' },
{ text: 'sum', link: '/ko/reference/math/sum' },
]
],
},
{
text: '객체',
@ -99,7 +99,7 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'omitBy', link: '/ko/reference/object/omitBy' },
{ text: 'pick', link: '/ko/reference/object/pick' },
{ text: 'pickBy', link: '/ko/reference/object/pickBy' },
]
],
},
{
text: '타입 가드',
@ -108,21 +108,18 @@ function sidebar(): DefaultTheme.Sidebar {
{ text: 'isNotNil', link: '/ko/reference/predicate/isNotNil' },
{ text: 'isNull', link: '/ko/reference/predicate/isNull' },
{ text: 'isUndefined', link: '/ko/reference/predicate/isUndefined' },
]
],
},
{
text: 'Promise',
items: [
{ text: 'delay', link: '/ko/reference/promise/delay' },
]
}
]
}
]
items: [{ text: 'delay', link: '/ko/reference/promise/delay' }],
},
],
},
];
}
export const search: DefaultTheme.LocalSearchOptions["locales"] = {
export const search: DefaultTheme.LocalSearchOptions['locales'] = {
ko: {
translations: {
button: {
@ -143,7 +140,7 @@ export const search: DefaultTheme.LocalSearchOptions["locales"] = {
},
noResultsText: '검색 결과를 찾지 못했어요.',
resetButtonTitle: '모두 지우기',
}
}
}
}
},
},
},
};

View File

@ -3,7 +3,7 @@ import path from 'path';
import { defineConfig } from 'vitepress';
import { search as koSearch } from './ko.mts';
const require = createRequire(import.meta.url)
const require = createRequire(import.meta.url);
export const shared = defineConfig({
title: 'es-toolkit',
@ -58,25 +58,27 @@ export const shared = defineConfig({
options: {
locales: {
...koSearch,
}
}
},
},
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/toss/es-toolkit' }
],
socialLinks: [{ icon: 'github', link: 'https://github.com/toss/es-toolkit' }],
},
vite: {
resolve: {
alias: {
'vue': path.dirname(require.resolve('vue/package.json', {
vue: path.dirname(
require.resolve('vue/package.json', {
paths: [require.resolve('vitepress')],
})),
'vue/server-renderer': path.dirname(require.resolve('vue/server-renderer', {
})
),
'vue/server-renderer': path.dirname(
require.resolve('vue/server-renderer', {
paths: [require.resolve('vitepress')],
})),
}
}
})
),
},
})
},
},
});

View File

@ -1,8 +1,9 @@
:root {
--vp-nav-logo-height: 16px;
--vp-font-family-base: "Toss Product Sans", ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
--vp-font-family-base: 'Toss Product Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
:root[lang=ko] {
:root[lang='ko'] {
word-break: keep-all;
}

View File

@ -1,4 +1,4 @@
import DefaultTheme from 'vitepress/theme'
import './index.css'
import DefaultTheme from 'vitepress/theme';
import './index.css';
export default DefaultTheme
export default DefaultTheme;

View File

@ -1,8 +1,8 @@
---
description: The minimal bundle footprint offered by es-toolkit
---
Bundle Footprint
============
# Bundle Footprint
![Graph showing the difference in bundle size between es-toolkit and lodash. There is a difference up to 97% in bundle size.](/assets/bundle-size.png)
@ -13,7 +13,7 @@ This makes es-toolkit the most efficient in terms of bundle size, with some util
## Bundle Footprint Comparison
| | es-toolkit@0.0.1 | lodash-es@4.17.21 | Difference |
|-----------------------------------------------|------------------|--------------------|------------|
| ------------------------------------------ | ---------------- | ----------------- | ---------- |
| [sample](./reference/array/sample) | 88 bytes | 2000 bytes | -95.6% |
| [difference](./reference/array/difference) | 91 bytes | 3190 bytes | -97.2% |
| [sum](./reference/math/sum) | 152 bytes | 413 bytes | -63.2% |
@ -21,4 +21,3 @@ This makes es-toolkit the most efficient in terms of bundle size, with some util
| [throttle](./reference/function/throttle) | 110 bytes | 1460 bytes | -92.5% |
| [pick](./reference/object/pick) | 657 bytes | 3860 bytes | -83.0% |
| [zip](./reference/array/zip) | 797 bytes | 1790 bytes | -55.5% |

View File

@ -3,8 +3,8 @@
layout: home
hero:
name: "es-toolkit"
text: "State-of-the-art JavaScript utility library"
name: 'es-toolkit'
text: 'State-of-the-art JavaScript utility library'
# tagline:
actions:
- theme: brand
@ -29,4 +29,3 @@ features:
- title: Battle-tested
details: es-toolkit has 100% test coverage, ensuring maximum robustness.
---

View File

@ -7,14 +7,13 @@ next:
text: Impact on Bundle Size
link: ./bundle-size
---
Installation
============
# Installation
es-toolkit is available on [npm](https://npmjs.com/package/es-toolkit) for Node.js, Deno, and Bun.
## Node.js
Node.js
---
es-toolkit supports Node.js 18 or later. Install es-toolkit with the following command:
```sh
@ -23,9 +22,7 @@ yarn add es-toolkit
pnpm install es-toolkit
```
Deno
----
## Deno
es-toolkit is also available on npm for Deno. Use es-toolkit with the `npm:` specifier:
@ -33,9 +30,7 @@ es-toolkit is also available on npm for Deno. Use es-toolkit with the `npm:` spe
import { chunk } from 'npm:es-toolkit@1.0.0';
```
Bun
---
## Bun
es-toolkit is also available on Bun. You can install it via the following command:

View File

@ -1,5 +1,4 @@
About es-toolkit
===============
# About es-toolkit
es-toolkit is a modern JavaScript utility library that offers a collection of powerful functions for everyday use.
@ -7,7 +6,6 @@ Compared to alternatives like lodash, es-toolkit provides a [significantly small
es-toolkit comes with built-in TypeScript types and has been rigorously tested, ensuring 100% test coverage for maximum reliability.
## Features
Here are some of the features es-toolkit offers:
@ -23,4 +21,4 @@ Here are some of the features es-toolkit offers:
Please refer to the following links for more information about this project.
- [GitHub](https://github.com/toss/es-toolkit)
- [GitHub](https://github.com/toss/es-toolkit)

View File

@ -1,8 +1,8 @@
---
description: es-toolkit이 가지는 작은 번들 사이즈
---
번들 사이즈
============
# 번들 사이즈
![es-toolkit과 lodash의 번들 사이즈를 비교하는 그래프. es-toolkit이 최대 97% 작은 번들 사이즈를 가진다.](/assets/bundle-size.png)
@ -13,7 +13,7 @@ es-toolkit은 현대적인 구현을 가지고 있기 때문에, 다른 라이
## 번들 사이즈 비교
| | es-toolkit@0.0.1 | lodash-es@4.17.21 | 차이 |
|-----------------------------------------------|------------------|--------------------|------------|
| --------------------------------------------- | ---------------- | ----------------- | ------ |
| [sample](./reference/array/sample.md) | 88 bytes | 2000 bytes | -95.6% |
| [difference](./reference/array/difference.md) | 91 bytes | 3190 bytes | -97.2% |
| [sum](./reference/math/sum.md) | 152 bytes | 413 bytes | -63.2% |
@ -21,4 +21,3 @@ es-toolkit은 현대적인 구현을 가지고 있기 때문에, 다른 라이
| [throttle](./reference/function/throttle.md) | 110 bytes | 1460 bytes | -92.5% |
| [pick](./reference/object/pick.md) | 657 bytes | 3860 bytes | -83.0% |
| [zip](./reference/array/zip.md) | 797 bytes | 1790 bytes | -55.5% |

View File

@ -3,8 +3,8 @@
layout: home
hero:
name: "es-toolkit"
text: "현대적인 JavaScript 유틸리티 라이브러리"
name: 'es-toolkit'
text: '현대적인 JavaScript 유틸리티 라이브러리'
# tagline:
actions:
- theme: brand
@ -29,4 +29,3 @@ features:
- title: 테스트 커버리지 100%
details: 모든 함수와 분기에 대해서 꼼꼼하게 테스트가 작성되어 있어요.
---

View File

@ -7,14 +7,13 @@ next:
text: 번들 사이즈에 미치는 영향
link: ./bundle-size
---
설치
============
# 설치
Node.js나 Bun을 사용하는 경우, [npm](https://npmjs.com/package/es-toolkit)에서 설치할 수 있어요. Deno에서는 [JSR](https://jsr.io/es-toolkit)에서 설치할 수 있어요.
## Node.js
Node.js
---
es-toolkit은 Node.js 18 또는 이후 버전을 지원해요. es-toolkit을 설치하기 위해서는 아래 명령어를 사용해주세요.
```sh
@ -23,9 +22,7 @@ yarn add es-toolkit
pnpm install es-toolkit
```
Deno
----
## Deno
es-toolkit은 Deno도 지원해요. `npm:`을 이용해서 사용하세요.
@ -33,9 +30,7 @@ es-toolkit은 Deno도 지원해요. `npm:`을 이용해서 사용하세요.
import { chunk } from 'npm:es-toolkit@1.0.0';
```
Bun
---
## Bun
es-toolkit은 Bun에서도 사용할 수 있어요. 아래 명령어를 사용해주세요.

View File

@ -1,5 +1,4 @@
es-toolkit 소개
===============
# es-toolkit 소개
es-toolkit은 일상적인 개발에서 사용하는 다양한 함수들을 모은 현대적인 JavaScript 유틸리티 라이브러리예요.
@ -8,7 +7,6 @@ es-toolkit은 일상적인 개발에서 사용하는 다양한 함수들을 모
es-toolkit은 견고한 TypeScript 타입을 내장하여 제공하며, 신뢰성을 높일 수 있도록 100% 테스트 커버리지를 목표로 하고 있습니다.
## 제공하는 기능
es-toolkit이 제공하는 기능 목록은 다음과 같습니다.
@ -24,4 +22,4 @@ es-toolkit이 제공하는 기능 목록은 다음과 같습니다.
이 프로젝트에 대해서 더 많은 정보를 얻기 위해서는 아래 링크를 참고하세요.
- [GitHub](https://github.com/toss/es-toolkit)
- [GitHub](https://github.com/toss/es-toolkit)

View File

@ -1,8 +1,8 @@
---
description: es-toolkit과 다른 라이브러리의 성능 차이
---
성능
============
# 성능
![es-toolkit과 lodash 사이의 성능 차이를 보여주는 그래프. es-toolkit은 lodash를 쓸 때보다 최대 11배 높은 성능을 보여요.](/assets/performance.png)
@ -12,7 +12,7 @@ es-toolkit은 설계할 때 성능을 우선적으로 고려하고 있어요. lo
## 성능 비교
| | es-toolkit@0.0.1 | lodash-es@4.17.21 | 차이 |
|-----------------------------------------------------------|------------------|------------------|------------|
| --------------------------------------------------------- | ---------------- | ----------------- | ----- |
| [omit](./reference/object/omit.md) | 4,767,360회 | 403,624회 | 11.8× |
| [pick](./reference/object/pick.md) | 9,121,839회 | 2,663,072회 | 3.43× |
| [differenceWith](./reference/array/differenceWith.md) | 9,291,897회 | 4,275,222회 | 2.17× |

View File

@ -5,7 +5,6 @@
입력값으로 배열을 받아서, 정해진 길이를 따르는 더 작은 배열 여러 개로 나눠요.
입력 배열이 똑같은 길이로 나눠질 수 없다면, 나눠진 마지막 배열이 남은 요소들을 포함하게 돼요.
## 인터페이스
```typescript

View File

@ -5,7 +5,6 @@
이 함수는 파라미터로 두 배열을 받아서, 첫 번째 배열에 있지만 두 번째 배열에는 없는 요소들을 포함한 새로운 배열을 반환해요.
즉, 첫 번째 배열에서 두 번째 배열에 있는 요소들을 제외한 나머지 요소들로 구성된 배열을 만들어줘요.
## 인터페이스
```typescript
@ -17,8 +16,6 @@ function difference<T>(firstArr: T[], secondArr: T[]): T[];
- `firstArr` (`T[]`): 차이를 계산할 배열이에요. 이 배열이 주 배열이고, 이 배열의 요소들이 비교되고 필터링돼요.
- `secondArr` (`T[]`): 첫 번째 배열에서 제외할 요소들을 포함한 배열이에요. 이 배열의 각 요소는 첫 번째 배열과 비교되며, 일치하는 요소가 있으면 결과에서 제외돼요.
### 반환 값
(`T[]`): 첫 번째 배열에는 있지만 두 번째 배열에는 없는 요소들이 담긴 새로운 배열이에요.

View File

@ -7,7 +7,7 @@
## 인터페이스
```typescript
function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[]
function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[];
```
### 파라미터

View File

@ -7,7 +7,7 @@
## 인터페이스
```typescript
function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[]
function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
```
### 파라미터
@ -17,8 +17,8 @@ function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T,
- `areItemsEqual` (`(x: T, y: T) => boolean`): 두 요소가 동일한지 결정할 함수에요.
### 반환 값
(`T[]`) 비교 함수에 따라 첫 번째 배열에는 있지만 두 번째 배열에는 존재하지 않는다고 결정된 요소들이 담긴 새로운 배열이에요.
(`T[]`) 비교 함수에 따라 첫 번째 배열에는 있지만 두 번째 배열에는 존재하지 않는다고 결정된 요소들이 담긴 새로운 배열이에요.
## 예시

View File

@ -8,7 +8,7 @@
## 인터페이스
```typescript
function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[]
function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
```
### 파라미터

View File

@ -5,11 +5,10 @@
이 함수는 각 배열의 요소를 순회하면서, 배열의 시작부터 조건 함수가 `false`를 반환할 때까지 요소를 제거해요.
남은 요소들로 구성된 새로운 배열을 반환해요.
## 인터페이스
```typescript
function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[]
function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
```
### 파라미터

View File

@ -26,7 +26,7 @@ function groupBy<T, K extends string>(arr: T[], getKeyFromItem: (item: T) => K):
const array = [
{ category: 'fruit', name: 'apple' },
{ category: 'fruit', name: 'banana' },
{ category: 'vegetable', name: 'carrot' }
{ category: 'vegetable', name: 'carrot' },
];
const result = groupBy(array, item => item.category);
// 결괏값:

View File

@ -5,7 +5,6 @@
이 함수는 두 개의 배열을 받고, 두 배열 모두에 포함되어 있는 요소로 구성된 새로운 배열을 반환해요.
실제로는 첫 번째 배열의 요소들 중에서 두 번째 배열에 포함되어 있지 않은 요소들을 제거해요.
## 인터페이스
```typescript
@ -21,7 +20,6 @@ function intersection<T>(firstArr: T[], secondArr: T[]): T[];
(`T[]`) 두 배열 모두에 포함되어 있는 요소로 구성된 새로운 배열.
## 예시
```typescript

View File

@ -6,7 +6,6 @@
`mapper` 함수로 각 배열의 요소들을 변환했을 때, 두 배열에 모두 포함되는 요소들로 이루어진 새로운 배열을 반환해요.
실제 구현을 살펴보면, 첫 번째 배열과 두 번째 배열을 `mapper` 가 반환하는 값을 기준으로 비교하여, 첫 번째 배열의 요소들 중 두 번째 배열에 없는 요소들을 제거해요.
## 인터페이스
```typescript
@ -15,7 +14,6 @@ function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) =
### 파라미터
- `firstArr` (`T[]`): 비교할 첫 번째 배열.
- `secondArr` (`T[]`): 비교할 두 번째 배열.
- `mapper` (`(item: T) => U`): 비교하기 위해 요소를 새로운 값으로 변환할 함수.
@ -24,7 +22,6 @@ function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) =
(`T[]`): 첫 번째 배열과 두 번째 배열을 `mapper` 가 반환하는 값을 기준으로 비교하여, 두 배열 모두에 포함되는 요소들만 포함하는 새로운 배열.
## 예시
```typescript

View File

@ -22,7 +22,6 @@ function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T
(`T[]`): 커스텀 일치 함수의 반환 값을 기준으로, 두 배열에 모두 포함된 요소들을 포함하는 새로운 배열.
## 예시
```typescript

View File

@ -4,7 +4,6 @@
만약 count가 arr의 길이보다 크면, 전체 배열을 반환해요.
## 인터페이스
```typescript

View File

@ -4,7 +4,6 @@
만약 `count``arr`의 길이보다 크면, 전체 배열을 반환해요.
## 인터페이스
```typescript
@ -20,7 +19,6 @@ function takeRight<T>(arr: T[], count: number): T[];
(`T[]`) `arr` 에서 마지막 `count` 개의 요소를 포함하는 새로운 배열이에요.
## 예시
```typescript

View File

@ -6,7 +6,7 @@
## 인터페이스
```typescript
function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[]
function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
```
### 파라미터
@ -18,7 +18,6 @@ function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean)
(`T[]`): 조건 함수가 `true`를 반환하는 동안 배열의 끝에서부터 가져온 요소들을 포함하는 새로운 배열이에요.
## 예시
```typescript

View File

@ -3,7 +3,6 @@
주어진 조건 함수가 `true`를 반환하는 선행 요소들을 포함하는 새로운 배열을 반환해요.
조건을 만족하지 않는 요소가 나오면 멈춰요.
## 인터페이스
```typescript
@ -19,7 +18,6 @@ function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean):
(`T[]`) 조건 함수가 `true`를 반환하는 동안 처음부터 가져온 요소들을 포함하는 새로운 배열이에요.
## 예시
```typescript

View File

@ -5,11 +5,10 @@
이 함수는 파라미터로 두 개의 배열과 `mapper` 함수를 받아요.
`mapper` 함수로 두 배열의 요소들을 변환했을 때, 두 배열에 모두 포함되는 요소는 제거돼요.
## 인터페이스
```typescript
function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[]
function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
```
### 파라미터

View File

@ -17,7 +17,6 @@ function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T)
- `arr2` (`T[]`): 비교할 두 번째 배열.
- `areItemsEqual` (`(x: T, y: T) => boolean`): 두 요소가 일치하는지 판단하는 일치 함수예요. 두 요소가 일치한다면 `true`를, 일치하지 않는다면 `false`를 반환하게 해주세요.
### 반환 값
(`T[]`): 커스텀 일치 함수의 반환 값을 기준으로, 두 배열의 합집합을 나타내는 새로운 배열.

View File

@ -24,3 +24,4 @@ function uniq<T>(arr: T[]): T[];
const array = [1, 2, 2, 3, 4, 4, 5];
const result = uniq(array);
// result는 [1, 2, 3, 4, 5]가 될 거예요.
```

View File

@ -19,7 +19,6 @@ function debounce(func: () => void, debounceMs: number): { (): void; cancel: ()
(`{ (): void; cancel: () => void }`): `cancel` 메서드를 가지고 있는 debounce된 함수.
## 예시
```typescript

View File

@ -3,7 +3,6 @@
제공된 함수 `func`를 한 번만 호출하도록 제한하는 함수를 생성해요.
함수를 반복해서 호출하면 첫 번째 호출의 값을 반환해요.
## 인터페이스
function once<F extends () => any>(func: F): F;
@ -16,7 +15,6 @@ function once<F extends () => any>(func: F): F;
(`F`): `func`가 한 번 호출되면 결과를 캐시하고 반환할 새로운 함수예요.
## 예시
```typescript

View File

@ -2,14 +2,12 @@
제공된 함수를 매 `throttleMs` 밀리초마다 최대 한 번만 호출하는 throttle된 함수를 생성해요. 시간 안에 throttle된 함수를 다시 호출해도 원래 함수를 실행하지 않아요.
## 인터페이스
```typescript
function throttle(func: () => void, throttleMs: number): () => void;
```
### 파라미터
- `func` (`() => void`): throttle할 함수.
@ -19,7 +17,6 @@ function throttle(func: () => void, throttleMs: number): () => void;
(`() => void`): 새로운 throttle된 함수.
## 예시
```typescript

View File

@ -7,7 +7,10 @@
## 인터페이스
```typescript
function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: string) => boolean): Partial<T>;
function pickBy<T extends Record<string, any>>(
obj: T,
shouldPick: (value: T[keyof T], key: string) => boolean
): Partial<T>;
```
### 파라미터

View File

@ -9,10 +9,9 @@ TypeScript의 타입 가드로 주로 사용되는데요, 파라미터로 주어
## 인터페이스
```typescript
function isNil(x: unknown): x is null | undefined
function isNil(x: unknown): x is null | undefined;
```
## 예시
```typescript

View File

@ -1,18 +1,17 @@
---
description: The performance difference between es-toolkit and alternative libraries
---
Performance
============
# Performance
![Graph showing the difference in performance between es-toolkit and lodash. Using es-toolkit results in a performance gain of up to 11 times.](/assets/performance.png)
Designed with performance in mind, es-toolkit provides an average of 2× performance improvement compared to alternative libraries like lodash. Some functions achieve up to an 11× performance gain by fully utilizing modern JavaScript APIs.
## Performance Comparison
| | es-toolkit@0.0.1 | lodash-es@4.17.21 | Difference |
|-----------------------------------------------------------|------------------|--------------------|------------|
| --------------------------------------------------------- | ---------------- | ----------------- | ---------- |
| [omit](./reference/object/omit.md) | 4,767,360 times | 403,624 times | 11.8× |
| [pick](./reference/object/pick.md) | 9,121,839 times | 2,663,072 times | 3.43× |
| [differenceWith](./reference/array/differenceWith.md) | 9,291,897 times | 4,275,222 times | 2.17× |

View File

@ -6,7 +6,6 @@ This function takes an input array and divides it into multiple smaller arrays,
each of a specified length. If the input array cannot be evenly divided,
the final sub-array will contain the remaining elements.
## Signature
```typescript

View File

@ -6,7 +6,6 @@ This function takes two arrays and returns a new array containing the elements
that are present in the first array but not in the second array. It effectively
filters out any elements from the first array that also appear in the second array.
## Signature
```typescript
@ -18,7 +17,6 @@ function difference<T>(firstArr: T[], secondArr: T[]): T[];
- `firstArr` (`T[]`): The array from which to derive the difference. This is the primary array from which elements will be compared and filtered.
- `secondArr` (`T[]`): The array containing elements to be excluded from the first array. Each element in this array will be checked against the first array, and if a match is found, that element will be excluded from the result.
### Returns
(`T[]`) A new array containing the elements that are present in the first array but not

View File

@ -7,11 +7,10 @@ that are present in the first array but not in the second array, based on the id
by the mapper function. Essentially, it filters out any elements from the first array that, when
mapped, match an element in the mapped version of the second array.
## Signature
```typescript
function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[]
function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[];
```
### Parameters

View File

@ -9,7 +9,7 @@ if elements are equal is made using the provided custom function.
## Signature
```typescript
function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[]
function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
```
### Parameters
@ -19,8 +19,8 @@ function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T,
- `areItemsEqual` (`(x: T, y: T) => boolean`): A function to determine if two items are equal.
### Returns
(`T[]`) A new array containing the elements from the first array that do not match any elements in the second array according to the custom equality function.
(`T[]`) A new array containing the elements from the first array that do not match any elements in the second array according to the custom equality function.
## Examples

View File

@ -20,7 +20,6 @@ function dropRight<T>(arr: T[], itemsCount: number): T[];
(`T[]`) A new array with the specified number of elements removed from the end.
## Examples
```typescript

View File

@ -8,7 +8,7 @@ predicate function returns false. It then returns a new array with the remaining
## Signature
```typescript
function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[]
function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
```
### Parameters

View File

@ -5,11 +5,10 @@ Removes elements from the beginning of an array until the predicate returns fals
This function iterates over an array and drops elements from the start until the provided
predicate function returns false. It then returns a new array with the remaining elements.
## Signature
```typescript
function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[]
function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
```
### Parameters

View File

@ -6,7 +6,6 @@ This function takes an array and a function that generates a key from each eleme
an object where the keys are the generated keys and the values are arrays of elements that share
the same key.
## Signature
```typescript
@ -29,7 +28,7 @@ share that key.
const array = [
{ category: 'fruit', name: 'apple' },
{ category: 'fruit', name: 'banana' },
{ category: 'vegetable', name: 'carrot' }
{ category: 'vegetable', name: 'carrot' },
];
const result = groupBy(array, item => item.category);
// result will be:

View File

@ -6,7 +6,6 @@ This function takes two arrays and returns a new array containing the elements t
present in both arrays. It effectively filters out any elements from the first array that
are not found in the second array.
## Signature
```typescript
@ -22,7 +21,6 @@ function intersection<T>(firstArr: T[], secondArr: T[]): T[];
(`T[]`) A new array containing the elements that are present in both arrays.
## Examples
```typescript

View File

@ -7,7 +7,6 @@ the elements from the first array that, when mapped using the provided function,
mapped elements in the second array. It effectively filters out any elements from the first array
that do not have corresponding mapped values in the second array.
## Signature
```typescript
@ -24,7 +23,6 @@ function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) =
(`T[]`) A new array containing the elements from the first array that have corresponding mapped values in the second array.
## Examples
```typescript

View File

@ -23,7 +23,6 @@ function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T
(`T[]`) A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.
## Examples
```typescript

View File

@ -4,7 +4,6 @@ Returns a new array containing the first `count` elements from the input array `
If `count` is greater than the length of `arr`, the entire array is returned.
## Signature
```typescript

View File

@ -4,7 +4,6 @@ Returns a new array containing the last `count` elements from the input array `a
If `count` is greater than the length of `arr`, the entire array is returned.
## Signature
```typescript
@ -20,7 +19,6 @@ function takeRight<T>(arr: T[], count: number): T[];
(`T[]`) A new array containing the last `count` elements from `arr`.
## Examples
```typescript

View File

@ -5,7 +5,7 @@ Takes elements from the end of the array while the predicate function returns `t
## Signature
```typescript
function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[]
function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
```
### Parameters
@ -17,7 +17,6 @@ function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean)
(`T[]`) A new array containing the elements taken from the end while the predicate returns `true`.
## Examples
```typescript

View File

@ -4,7 +4,6 @@ Returns a new array containing the leading elements of the provided array
that satisfy the provided predicate function. It stops taking elements as soon
as an element does not satisfy the predicate.
## Signature
```typescript
@ -20,7 +19,6 @@ function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean):
(`T[]`) A new array containing the elements taken from the beginning while the predicate returns `true`.
## Examples
```typescript

View File

@ -5,7 +5,7 @@ Creates an array of unique values, in order, from all given arrays using a provi
## Signature
```typescript
function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[]
function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
```
### Parameters

View File

@ -1,4 +1,5 @@
===
# uniq
Creates a duplicate-free version of an array.
@ -26,3 +27,4 @@ function uniq<T>(arr: T[]): T[];
const array = [1, 2, 2, 3, 4, 4, 5];
const result = uniq(array);
// result will be [1, 2, 3, 4, 5]
```

View File

@ -19,7 +19,6 @@ function debounce(func: () => void, debounceMs: number): { (): void; cancel: ()
(`{ (): void; cancel: () => void }`): A new debounced function with a `cancel` method.
## Examples
```typescript

Some files were not shown because too many files have changed in this diff Show More