1.0.5 • Published 6 years ago

@kingjs/array.make-enumerable v1.0.5

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

@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

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