diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-06-29 14:25:29 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-06-29 14:25:29 +0200 |
commit | 3f7ae147fb969db479c10eaa871a840a30e281b3 (patch) | |
tree | 2e99c35f59f0effb260c26118e9edf3199bb8de7 /util/array.ts | |
parent | c998e1c0477d51c886f9e4246e102dec4d7ef8dd (diff) |
http proof of concept api
Diffstat (limited to 'util/array.ts')
-rw-r--r-- | util/array.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/util/array.ts b/util/array.ts index 76e2a9e..5b8c512 100644 --- a/util/array.ts +++ b/util/array.ts @@ -1,17 +1,23 @@ declare global { interface Array<T> { + /** @summary check if any of the elements of `arr2` are included in `this` */ anyOf(arr2: Array<T>): boolean; + /** @summary return last element of array without removing it */ peek(): T; + /** @summary create Set from this array */ + set(): Set<T>; } } -/** @summary check if any of the elements of `arr2` are included in `this` */ Array.prototype.anyOf = function(arr2) { return !!this.filter(e => arr2.includes(e)).length; }; -/** @summary return last element of array without removing it */ Array.prototype.peek = function() { return this[this.length - 1]; }; +Array.prototype.set = function() { + return new Set(this); +} + |