kingjs

    1.0.48 • Public • Published

    @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

    Analytics

    Keywords

    none

    Install

    npm i kingjs

    DownloadsWeekly Downloads

    0

    Version

    1.0.48

    License

    MIT

    Unpacked Size

    5.94 kB

    Total Files

    9

    Last publish

    Collaborators

    • kingces95