1.0.1 • Published 7 years ago
@kingjs/make-enumerable v1.0.1
@kingjs/make-enumerable
Make an array enumerable by adding a getEnumerable method.
Usage
Make an array enumerable like this:
makeEnumerable = require('@kingjs/make-enumerable');
var sequence = makeEnumerable([ 1, 2 ]);
// sequence is still an array...
sequence.push(3);
// ...that can enumerated!
var enumerator = sequence.getEnumerator();
var result = [];
while (enumerator.moveNext())
result.push(enumerator.current);
result;result:
[ 1, 2, 3 ]API
declare function makeEnumerable(
array?: Array
): EnumerableInterfaces
Enumerable: See @kingjs/sequence.
Parameters
array: The array to augment with functiongetEnumerator.
Returns
The array passed as array augmented with a getEnumerable function.
Remarks
Passing null or undefined will return an empty array that is also enumerable.
The array is frozen by the first call to getEnumerator to prevent mutating the array during enumeration.
Install
With npm installed, run
$ npm install @kingjs/make-enumerableLicense
MIT