diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-11-09 14:14:53 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-09 14:14:53 +0900 |
| commit | 3c0d2db3bc746c405e9638f7c7ff98981e60831f (patch) | |
| tree | bb2a2c9037394d32d752268175a510181080ded4 /src/prelude | |
| parent | [Client] Fix bug (diff) | |
| download | sharkey-3c0d2db3bc746c405e9638f7c7ff98981e60831f.tar.gz sharkey-3c0d2db3bc746c405e9638f7c7ff98981e60831f.tar.bz2 sharkey-3c0d2db3bc746c405e9638f7c7ff98981e60831f.zip | |
Rename: setDifference -> difference (#3177)
* Improve setDifference
* Rename: setDifference -> difference
Diffstat (limited to 'src/prelude')
| -rw-r--r-- | src/prelude/array.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/prelude/array.ts b/src/prelude/array.ts index 8536e486d6..69b52fde87 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -18,8 +18,12 @@ export function erase<T>(x: T, xs: T[]): T[] { return xs.filter(y => x !== y); } -export function setDifference<T>(xs: T[], ys: T[]): T[] { - return xs.filter(x => !ys.includes(x)); +/** + * Finds the array of all elements in the first array not contained in the second array. + * The order of result values are determined by the first array. + */ +export function difference<T>(includes: T[], excludes: T[]): T[] { + return includes.filter(x => !excludes.includes(x)); } export function unique<T>(xs: T[]): T[] { |