aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/src/internal/operators/last.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-29 11:49:28 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-29 11:49:28 -0700
commitd55b767039605256c736166a942a9138e3eacfd7 (patch)
tree947063b634c50d438a794325f13275e134aa5993 /node_modules/rxjs/src/internal/operators/last.ts
parent864ce67d89c77d8ef9c3361f80d619853abcf91c (diff)
remove dev node_modules (oops)
Diffstat (limited to 'node_modules/rxjs/src/internal/operators/last.ts')
-rw-r--r--node_modules/rxjs/src/internal/operators/last.ts91
1 files changed, 0 insertions, 91 deletions
diff --git a/node_modules/rxjs/src/internal/operators/last.ts b/node_modules/rxjs/src/internal/operators/last.ts
deleted file mode 100644
index 698ce23..0000000
--- a/node_modules/rxjs/src/internal/operators/last.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-import { Observable } from '../Observable';
-import { EmptyError } from '../util/EmptyError';
-import { OperatorFunction, TruthyTypesOf } from '../types';
-import { filter } from './filter';
-import { takeLast } from './takeLast';
-import { throwIfEmpty } from './throwIfEmpty';
-import { defaultIfEmpty } from './defaultIfEmpty';
-import { identity } from '../util/identity';
-
-export function last<T>(predicate: BooleanConstructor): OperatorFunction<T, TruthyTypesOf<T>>;
-export function last<T, D>(predicate: BooleanConstructor, defaultValue: D): OperatorFunction<T, TruthyTypesOf<T> | D>;
-export function last<T, D = T>(predicate?: null, defaultValue?: D): OperatorFunction<T, T | D>;
-export function last<T, S extends T>(
- predicate: (value: T, index: number, source: Observable<T>) => value is S,
- defaultValue?: S
-): OperatorFunction<T, S>;
-export function last<T, D = T>(
- predicate: (value: T, index: number, source: Observable<T>) => boolean,
- defaultValue?: D
-): OperatorFunction<T, T | D>;
-
-/**
- * Returns an Observable that emits only the last item emitted by the source Observable.
- * It optionally takes a predicate function as a parameter, in which case, rather than emitting
- * the last item from the source Observable, the resulting Observable will emit the last item
- * from the source Observable that satisfies the predicate.
- *
- * ![](last.png)
- *
- * It will emit an error notification if the source completes without notification or one that matches
- * the predicate. It returns the last value or if a predicate is provided last value that matches the
- * predicate. It returns the given default value if no notification is emitted or matches the predicate.
- *
- * ## Examples
- *
- * Last alphabet from the sequence
- *
- * ```ts
- * import { from, last } from 'rxjs';
- *
- * const source = from(['x', 'y', 'z']);
- * const result = source.pipe(last());
- *
- * result.subscribe(value => console.log(`Last alphabet: ${ value }`));
- *
- * // Outputs
- * // Last alphabet: z
- * ```
- *
- * Default value when the value in the predicate is not matched
- *
- * ```ts
- * import { from, last } from 'rxjs';
- *
- * const source = from(['x', 'y', 'z']);
- * const result = source.pipe(last(char => char === 'a', 'not found'));
- *
- * result.subscribe(value => console.log(`'a' is ${ value }.`));
- *
- * // Outputs
- * // 'a' is not found.
- * ```
- *
- * @see {@link skip}
- * @see {@link skipUntil}
- * @see {@link skipLast}
- * @see {@link skipWhile}
- * @see {@link first}
- *
- * @throws {EmptyError} Delivers an `EmptyError` to the Observer's `error`
- * callback if the Observable completes before any `next` notification was sent.
- *
- * @param predicate The condition any source emitted item has to satisfy.
- * @param defaultValue An optional default value to provide if last `predicate`
- * isn't met or no values were emitted.
- * @return A function that returns an Observable that emits only the last item
- * satisfying the given condition from the source, or an error notification
- * with an `EmptyError` object if no such items are emitted.
- */
-export function last<T, D>(
- predicate?: ((value: T, index: number, source: Observable<T>) => boolean) | null,
- defaultValue?: D
-): OperatorFunction<T, T | D> {
- const hasDefaultValue = arguments.length >= 2;
- return (source: Observable<T>) =>
- source.pipe(
- predicate ? filter((v, i) => predicate(v, i, source)) : identity,
- takeLast(1),
- hasDefaultValue ? defaultIfEmpty(defaultValue!) : throwIfEmpty(() => new EmptyError())
- );
-}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage