aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/src/internal/operators/skipWhile.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/skipWhile.ts
initial commit: scaffolding
Diffstat (limited to 'node_modules/rxjs/src/internal/operators/skipWhile.ts')
-rw-r--r--node_modules/rxjs/src/internal/operators/skipWhile.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/node_modules/rxjs/src/internal/operators/skipWhile.ts b/node_modules/rxjs/src/internal/operators/skipWhile.ts
new file mode 100644
index 0000000..84b7379
--- /dev/null
+++ b/node_modules/rxjs/src/internal/operators/skipWhile.ts
@@ -0,0 +1,60 @@
+import { Falsy, MonoTypeOperatorFunction, OperatorFunction } from '../types';
+import { operate } from '../util/lift';
+import { createOperatorSubscriber } from './OperatorSubscriber';
+
+export function skipWhile<T>(predicate: BooleanConstructor): OperatorFunction<T, Extract<T, Falsy> extends never ? never : T>;
+export function skipWhile<T>(predicate: (value: T, index: number) => true): OperatorFunction<T, never>;
+export function skipWhile<T>(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction<T>;
+
+/**
+ * Returns an Observable that skips all items emitted by the source Observable as long as a specified condition holds
+ * true, but emits all further source items as soon as the condition becomes false.
+ *
+ * ![](skipWhile.png)
+ *
+ * Skips all the notifications with a truthy predicate. It will not skip the notifications when the predicate is falsy.
+ * It can also be skipped using index. Once the predicate is true, it will not be called again.
+ *
+ * ## Example
+ *
+ * Skip some super heroes
+ *
+ * ```ts
+ * import { from, skipWhile } from 'rxjs';
+ *
+ * const source = from(['Green Arrow', 'SuperMan', 'Flash', 'SuperGirl', 'Black Canary'])
+ * // Skip the heroes until SuperGirl
+ * const example = source.pipe(skipWhile(hero => hero !== 'SuperGirl'));
+ * // output: SuperGirl, Black Canary
+ * example.subscribe(femaleHero => console.log(femaleHero));
+ * ```
+ *
+ * Skip values from the array until index 5
+ *
+ * ```ts
+ * import { from, skipWhile } from 'rxjs';
+ *
+ * const source = from([1, 2, 3, 4, 5, 6, 7, 9, 10]);
+ * const example = source.pipe(skipWhile((_, i) => i !== 5));
+ * // output: 6, 7, 9, 10
+ * example.subscribe(value => console.log(value));
+ * ```
+ *
+ * @see {@link last}
+ * @see {@link skip}
+ * @see {@link skipUntil}
+ * @see {@link skipLast}
+ *
+ * @param predicate A function to test each item emitted from the source Observable.
+ * @return A function that returns an Observable that begins emitting items
+ * emitted by the source Observable when the specified predicate becomes false.
+ */
+export function skipWhile<T>(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction<T> {
+ return operate((source, subscriber) => {
+ let taking = false;
+ let index = 0;
+ source.subscribe(
+ createOperatorSubscriber(subscriber, (value) => (taking || (taking = !predicate(value, index++))) && subscriber.next(value))
+ );
+ });
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage