From ce9e0788317b25e5d297ed38d9fed0754a341288 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 1 Jul 2023 16:37:50 +0200 Subject: WIP sentence API --- util/array.ts | 6 ++++++ util/types.ts | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 util/types.ts (limited to 'util') diff --git a/util/array.ts b/util/array.ts index 5b8c512..f032935 100644 --- a/util/array.ts +++ b/util/array.ts @@ -6,6 +6,8 @@ declare global { peek(): T; /** @summary create Set from this array */ set(): Set; + /** @summary clear array */ + clear(): void; } } @@ -21,3 +23,7 @@ Array.prototype.set = function() { return new Set(this); } +Array.prototype.clear = function() { + while (this.length > 0) this.pop(); +} + diff --git a/util/types.ts b/util/types.ts new file mode 100644 index 0000000..f03a242 --- /dev/null +++ b/util/types.ts @@ -0,0 +1,8 @@ +/** + * @type DeepPartial makes all properties of type T optional, but keep + * array types intact + */ +export type DeepPartial = { + [K in keyof T]?: T[K] extends Array ? Array : DeepPartial; +}; + -- cgit v1.2.3