1.0.5 • Published 6 years ago

@kingjs/sequence v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@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

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago