aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-28 17:26:46 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-28 17:43:56 -0700
commite4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch)
tree06284a538a6008eca75051399e47db4e5d50301c /node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts
initial commit: scaffolding
Diffstat (limited to 'node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts')
-rw-r--r--node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts b/node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts
new file mode 100644
index 0000000..483bef9
--- /dev/null
+++ b/node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts
@@ -0,0 +1,30 @@
+const { isArray } = Array;
+const { getPrototypeOf, prototype: objectProto, keys: getKeys } = Object;
+
+/**
+ * Used in functions where either a list of arguments, a single array of arguments, or a
+ * dictionary of arguments can be returned. Returns an object with an `args` property with
+ * the arguments in an array, if it is a dictionary, it will also return the `keys` in another
+ * property.
+ */
+export function argsArgArrayOrObject<T, O extends Record<string, T>>(args: T[] | [O] | [T[]]): { args: T[]; keys: string[] | null } {
+ if (args.length === 1) {
+ const first = args[0];
+ if (isArray(first)) {
+ return { args: first, keys: null };
+ }
+ if (isPOJO(first)) {
+ const keys = getKeys(first);
+ return {
+ args: keys.map((key) => first[key]),
+ keys,
+ };
+ }
+ }
+
+ return { args: args as T[], keys: null };
+}
+
+function isPOJO(obj: any): obj is object {
+ return obj && typeof obj === 'object' && getPrototypeOf(obj) === objectProto;
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage