aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/src/internal/operators/pluck.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/operators/pluck.ts
initial commit: scaffolding
Diffstat (limited to 'node_modules/rxjs/src/internal/operators/pluck.ts')
-rw-r--r--node_modules/rxjs/src/internal/operators/pluck.ts106
1 files changed, 106 insertions, 0 deletions
diff --git a/node_modules/rxjs/src/internal/operators/pluck.ts b/node_modules/rxjs/src/internal/operators/pluck.ts
new file mode 100644
index 0000000..b80da73
--- /dev/null
+++ b/node_modules/rxjs/src/internal/operators/pluck.ts
@@ -0,0 +1,106 @@
+import { map } from './map';
+import { OperatorFunction } from '../types';
+
+/* tslint:disable:max-line-length */
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<T, K1 extends keyof T>(k1: K1): OperatorFunction<T, T[K1]>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1]>(k1: K1, k2: K2): OperatorFunction<T, T[K1][K2]>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(
+ k1: K1,
+ k2: K2,
+ k3: K3
+): OperatorFunction<T, T[K1][K2][K3]>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(
+ k1: K1,
+ k2: K2,
+ k3: K3,
+ k4: K4
+): OperatorFunction<T, T[K1][K2][K3][K4]>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<
+ T,
+ K1 extends keyof T,
+ K2 extends keyof T[K1],
+ K3 extends keyof T[K1][K2],
+ K4 extends keyof T[K1][K2][K3],
+ K5 extends keyof T[K1][K2][K3][K4]
+>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5): OperatorFunction<T, T[K1][K2][K3][K4][K5]>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<
+ T,
+ K1 extends keyof T,
+ K2 extends keyof T[K1],
+ K3 extends keyof T[K1][K2],
+ K4 extends keyof T[K1][K2][K3],
+ K5 extends keyof T[K1][K2][K3][K4],
+ K6 extends keyof T[K1][K2][K3][K4][K5]
+>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6): OperatorFunction<T, T[K1][K2][K3][K4][K5][K6]>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<
+ T,
+ K1 extends keyof T,
+ K2 extends keyof T[K1],
+ K3 extends keyof T[K1][K2],
+ K4 extends keyof T[K1][K2][K3],
+ K5 extends keyof T[K1][K2][K3][K4],
+ K6 extends keyof T[K1][K2][K3][K4][K5]
+>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6, ...rest: string[]): OperatorFunction<T, unknown>;
+/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
+export function pluck<T>(...properties: string[]): OperatorFunction<T, unknown>;
+/* tslint:enable:max-line-length */
+
+/**
+ * Maps each source value to its specified nested property.
+ *
+ * <span class="informal">Like {@link map}, but meant only for picking one of
+ * the nested properties of every emitted value.</span>
+ *
+ * ![](pluck.png)
+ *
+ * Given a list of strings or numbers describing a path to a property, retrieves
+ * the value of a specified nested property from all values in the source
+ * Observable. If a property can't be resolved, it will return `undefined` for
+ * that value.
+ *
+ * ## Example
+ *
+ * Map every click to the tagName of the clicked target element
+ *
+ * ```ts
+ * import { fromEvent, pluck } from 'rxjs';
+ *
+ * const clicks = fromEvent(document, 'click');
+ * const tagNames = clicks.pipe(pluck('target', 'tagName'));
+ *
+ * tagNames.subscribe(x => console.log(x));
+ * ```
+ *
+ * @see {@link map}
+ *
+ * @param properties The nested properties to pluck from each source
+ * value.
+ * @return A function that returns an Observable of property values from the
+ * source values.
+ * @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8.
+ */
+export function pluck<T, R>(...properties: Array<string | number | symbol>): OperatorFunction<T, R> {
+ const length = properties.length;
+ if (length === 0) {
+ throw new Error('list of properties cannot be empty.');
+ }
+ return map((x) => {
+ let currentProp: any = x;
+ for (let i = 0; i < length; i++) {
+ const p = currentProp?.[properties[i]];
+ if (typeof p !== 'undefined') {
+ currentProp = p;
+ } else {
+ return undefined;
+ }
+ }
+ return currentProp;
+ });
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage