1.1.0 โข Published 2 months ago
@sonwonjae/builtin-extends v1.1.0
๐ก builtin-extends
์ ์ฉํ JavaScript ๋นํธ์ธ ๊ฐ์ฒด ํ์ฅ ๋ฉ์๋๋ค์ ๋ชจ์ ์ ํธ๋ฆฌํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋๋ค.
shuffle
,pureSort
๋ฑ ์์ฃผ ์ฌ์ฉํ๋ ๊ธฐ๋ฅ์ ํ๋กํ ํ์ ๋ฉ์๋๋ก ์ฌ์ฉํ ์ ์๋๋ก ๋์์ค๋๋ค.
โจ ํน์ง
[].shuffle()
์ฒ๋ผ ๊ฐํธํ๊ฒ ์ฌ์ฉ ๊ฐ๋ฅ- ๋ฐ๋ณต๋๋ ์ ํธ๋ฆฌํฐ ์ฝ๋ ์ ๊ฑฐ
- ํ ์คํธ์ ํ์ ์ ์ ํฌํจ
๐ฆ ์ค์น
npm install builtin-extends
yarn add builtin-extends
๐ ์ฌ์ฉ๋ฒ ์์
import "builtin-extends";
// ๋ฐฐ์ด์ ์
ํ
const arr = [1, 2, 3, 4, 5];
arr.shuffle(); // ์: [3, 5, 1, 4, 2]
// ์๋ณธ ๋ฐฐ์ด์ ์์ ํ์ง ์๊ณ ์ ๋ ฌ๋ ์ ๋ฐฐ์ด ๋ฐํ
const unsorted = [3, 1, 4, 2];
const sorted = unsorted.pureSort(); // [1, 2, 3, 4]
console.log(unsorted); // [3, 1, 4, 2]
๐ ์ง์ ๋ฉ์๋
Object
๋ฉ์๋ ์ด๋ฆ | ์ค๋ช |
---|---|
isString() | ํด๋น object๊ฐ string์ธ์ง ๊ฒ์ฆํด์ฃผ๋ ํ์ ๊ฐ๋์ ๋๋ค. |
isNumber() | ํด๋น object๊ฐ number์ธ์ง ๊ฒ์ฆํด์ฃผ๋ ํ์ ๊ฐ๋์ ๋๋ค. |
isBoolean() | ํด๋น object๊ฐ boolean์ธ์ง ๊ฒ์ฆํด์ฃผ๋ ํ์ ๊ฐ๋์ ๋๋ค. |
Array
๋ฉ์๋ ์ด๋ฆ | ์ค๋ช |
---|---|
shuffle() | ๋ฐฐ์ด ์์๋ฅผ ๋ฌด์์๋ก ์์ด์ค๋๋ค. |
draw() | ๋ฐฐ์ด์์ ๋ฌด์์ ์ธ์ ํ๋๋ฅผ ๋ฝ์์ค๋๋ค. |
String
๋ฉ์๋ ์ด๋ฆ | ์ค๋ช |
---|---|
toCamelCase() | ์ผ๋ฐฅ/์ค๋ค์ดํฌ/ํ์ค์นผ ์ผ์ด์ค๋ฅผ ์นด๋ฉ ์ผ์ด์ค๋ก ๋ณํํด์ค๋๋ค. |
toPascalCase() | ์ผ๋ฐฅ/์ค๋ค์ดํฌ/์นด๋ฉ ์ผ์ด์ค๋ฅผ ํ์ค์นผ ์ผ์ด์ค๋ก ๋ณํํด์ค๋๋ค. |
toSnakeCase() | ์ผ๋ฐฅ/์นด๋ฉ/ํ์ค์นผ ์ผ์ด์ค๋ฅผ ์ค๋ค์ดํฌ ์ผ์ด์ค๋ก ๋ณํํด์ค๋๋ค. |
toKebabCase() | ์ค๋ค์ดํฌ/์นด๋ฉ/ํ์ค์นผ ์ผ์ด์ค๋ฅผ ์ผ๋ฐฅ ์ผ์ด์ค๋ก ๋ณํํด์ค๋๋ค. |
Number
๋ฉ์๋ ์ด๋ฆ | ์ค๋ช |
---|---|
isEven() | ์ง์์ธ์ง ํ๋ณํด์ค๋๋ค. |
isOdd() | ํ์์ธ์ง ํ๋ณํด์ค๋๋ค. |
๐ฅฎ ํ ์คํธ
npm run test
๐ ๋ผ์ด์ผ์ค
MIT License