Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/iter/lib/transformers.ts>dropWhile

A bunch of utilities for working with iterables, many inspired by the native array methods.
Latest
function dropWhile
import { dropWhile } from "https://deno.land/x/iter@v3.2.3/lib/transformers.ts";

Returns a new iterable which skips items from it while f returns true. true.

Examples

Example 1

import * as iter from "https://deno.land/x/iter/mod.ts";

const numbers = iter.create.range(1, 10);
const dropped = iter.dropWhile(numbers, (n) => n < 5);

for (const num of dropped) {
  console.log(num);
}

// -> 5
// -> 6
// -> 7
// -> 8
// -> 9
// -> 10

Parameters

it: Iterable<T>
  • The iterable being skipped.
  • A function that accepts up to three arguments. The dropWhile function calls f one time for each item in the iterable.

Returns

A new iterable of it which begins at the first element where f returns false