This package has been deprecated

Author message:

see @kingjs/array.make-enumerable

@kingjs/array-enumerable

1.0.4 • Public • Published

@kingjs/array-enumerable

Wraps an array in an enumerable.

Usage

To allow someone to enumerate your array without allowing them to change the array, you can wrap it in an enumerable like this:

var ArrayEnumerable = require('@kingjs/array-enumerable')

var myArray = [0, 1, 2];

var yourEnumerable = new ArrayEnumerable(myArray);
var yourEnumerator = yourEnumerable.getEnumerator();

var yourArray = [];
while (yourEnumerator.moveNext()) 
  yourArray.push(yourEnumerator.current);

yourArray;

outputs:

[0, 1, 2];

API

function ArrayEnumerable(array?: any[]): {
  getEnumerator: {
    (): {
      moveNext: { (): Boolean },
      current: any
    }
  }
}

Parameters

array: the array like object to enumerate.

Return Value

An enumerable which returns the elements of the array.

Remarks

"Array like" objects like arguments which are not of type Array yet have a length property and a range of other properties from 0 to length -1 may also be enumerated with ArrayEnumerator.

ArrayEnumerable is registered as an IEnumerable implementation.

Install

With npm installed, run

$ npm install @kingjs/array-enumerable

Acknowledgments

ArrayEnumerable was inspired by LINQ.

See Also

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/array-enumerable

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

3.51 kB

Total Files

4

Last publish

Collaborators

  • kingces95