kingjs
v1.0.48
Published
Adds Symbol.kingjs and implementations on builtin types.
Downloads
14
Readme
@kingjs/shim
Usage
require('@kingjs/shim');
Generators implement IIterable
Demonstrate the before and after behavior of this shim like this:
var assert = require('assert');
function* generator() { yield 0; }
// oddly, a generator is not it's own Symbol.iterator
assert(!generator[Symbol.iterator]);
require('@kingjs/shim');
// Shim generators so they implement the Symbol.iterator protocol
var iterator = generator[Symbol.iterator]();
assert(iterator);
var next;
assert(next = iterator.next(), !next.done);
assert(next.value == 0);
assert(next = iterator.next(), next.done);
API
declare function shim(
): any
Parameters
Returns
Remarks
Install
With npm installed, run
$ npm install @kingjs/shim
License
MIT