@kingjs/sequence

Yield arguments with the Enumerable interface.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/sequence
1.0.53 years ago3 years agoMinified + gzip package size for @kingjs/sequence in KB

Readme

@kingjs/sequence

Yield arguments with the Enumerable interface.

Usage

Create an Enumerable to yield the values 1, 2, and 3 like this:

var sequence = require('@kingjs/sequence')

var enumerable = sequence(0, 1, 2);

var enumerator = enumerable.getEnumerator();

var result = [];
while (enumerator.moveNext()) 
  result.push(enumerator.current);

result;

result:

[0, 1, 2];

API

declare interface Enumerable {
  getEnumerator: () => {
    moveNext: () => boolean,
    current
  }
}  

declare function sequence(...args: any[]): Enumerable

Interfaces

Enumerable: A sequence of values. If moveNext() returns true, then current has been set to the next (or first) value. If moveNext() returns false, then all values have been returned.

Parameters

args: The arguments to yield.

Return Value

An enumerable which returns the arguments as a sequence.

Install

With npm installed, run

$ npm install @kingjs/sequence

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.