@kingjs/array.make-enumerable

Makes an array enumerable by adding a `getEnumerable` method.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/array.make-enumerable
081.0.54 years ago4 years agoMinified + gzip package size for @kingjs/array.make-enumerable in KB

Readme

@kingjs/array.make-enumerable
Makes an array enumerable by adding a getEnumerable method.

Usage

Make an array enumerable like this:
var makeEnumerable = require('@kingjs/array.make-enumerable');
var array = makeEnumerable.call([ 1, 2 ]);

// array is an Array...
array.push(3); 

// ...that can also be enumerated...
var enumerator = array.getEnumerator();

// ...at the cost of becoming frozen.
// sequence.push(4); 

var result = [];
while (enumerator.moveNext())
  result.push(enumerator.current);
result;
result:
[ 1, 2, 3 ]

API

declare function makeEnumerable(
  this: Array
): Enumerable

Interfaces

Parameters

  • this: The array to augment with function getEnumerator.

Returns

Returns this after adding a getEnumerable function.

Remarks

The array is frozen by the first call to getEnumerator.

Install

With npm installed, run
$ npm install @kingjs/array.make-enumerable

License

MIT
Analytics