@kingjs/linq.skip-while

Generates a sequence identical to another sequence after bypassing the first contiguous set of elements which satisfy a specified condition.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/linq.skip-while
1.0.93 years ago3 years agoMinified + gzip package size for @kingjs/linq.skip-while in KB

Readme

@kingjs/linq.skip-while

Generates a sequence identical to another sequence after bypassing the first contiguous set of elements which satisfy a specified condition.

Usage

Skip numbers in -2, -1, 0, -1, -2 so long as they're negative like this:

var skipWhile = require('@kingjs/linq.skip-while');
var sequence = require('@kingjs/enumerable.create');
var toArray = require('@kingjs/linq.to-array');

function isNegative(x) {
  return x < 0;
}

var result = skipWhile.call(sequence(-2, -1, 0, -1, -2), isNegative);

toArray.call(result);

result:

[0, -1, -2]

API

declare function skipWhile(
  this: Enumerable,
  predicate: function(x, i): boolean
): Enumerable

Interfaces

Parameters

  • this: The sequence.
  • predicate: Predicates elements must satisfy in order to continue skipping elements.
    • x: The element to test.
    • i: The zero based index of the element.

Return Value

A sequence where the first elements that satisfy predicate have been skipped over.

Install

With npm installed, run

$ npm install @kingjs/linq.skip-while

Acknowledgments

Like Element.SkipWhile.

License

MIT

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.