Giter Site home page Giter Site logo

hoity-grasp's Introduction

Hoity (High Order ITerators Yielded) predefined classes grasping

This is the very beginning of the Hoity project: it grasps (and gives names to) the predefined classes related to iterators and generators.

For some reason the EcmaScript standards defines a set of classes and prototypes that any implementation must have, but non of them are accesible through a name. Nevertheless, JavaScript is so powerful that it is trivial to find those clases and prototypes, to create classes when absent, and to make then available.

This package (re)exports the following classes:

  • Iterator. Neither this class nor its prototype exists in EcmaScript. But the ES hierarchy has a prototype that deserves a class with this name. So, this package introduces such a class.

All predefined iterators extends from this class (have its prototype in theirs prototype chains). So any method added to this class will be available to any standar iterator.

This class has a predefined method @@iterator that returns itself. This is what makes possible to use an iterator where an iterable is expected.

When defining an iterator by hand, better extend this class to get for free at least @@iterator method, but any other method introduced by other Hoity modules (see hoity-core).

  • GeneratorFunction. This is the class of all generators functions. Because generators functions are build with the function* syntax, no class will extend GeneratorFunction. But can be used to test if something is a generator with gen instanceof GeneratorFunction.

  • AsyncIterator and AsyncGeneratorFunction. Similar classes for the async side of the generators. They only exist if the JavaScript implementation support async generators.

hoity-grasp's People

Contributors

apbarrero avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.