diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-09-07 00:52:21 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-09-07 00:52:21 +0900 |
| commit | 538bb978edab3cd566c4201674adadc0fd3040df (patch) | |
| tree | d55a4bc74c180f54a55dd60eb7219dd37d809b20 /src/prelude/array.ts | |
| parent | Fix bug & some refactor (diff) | |
| parent | Fix typo: serive -> service (#2647) (diff) | |
| download | misskey-538bb978edab3cd566c4201674adadc0fd3040df.tar.gz misskey-538bb978edab3cd566c4201674adadc0fd3040df.tar.bz2 misskey-538bb978edab3cd566c4201674adadc0fd3040df.zip | |
Merge branch 'develop' of https://github.com/syuilo/misskey into develop
Diffstat (limited to 'src/prelude/array.ts')
| -rw-r--r-- | src/prelude/array.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/prelude/array.ts b/src/prelude/array.ts index aee17640ed..abef6ca039 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -6,6 +6,18 @@ export function count<T>(x: T, xs: T[]): number { return countIf(y => x === y, xs); } +export function concat<T>(xss: T[][]): T[] { + return ([] as T[]).concat(...xss); +} + export function intersperse<T>(sep: T, xs: T[]): T[] { - return [].concat(...xs.map(x => [sep, x])).slice(1); + return concat(xs.map(x => [sep, x])).slice(1); +} + +export function erase<T>(x: T, xs: T[]): T[] { + return xs.filter(y => x !== y); +} + +export function unique<T>(xs: T[]): T[] { + return [...new Set(xs)]; } |