npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

es6-iter

v0.5.0

Published

Functional programming utility library that works with ES6 iterable objects

Downloads

13

Readme

iter

Iter is a functional helper library for ES6 iterables. It's API is similiar to Underscore JS, with a few key differences. First it'll Iterate over any ES6 iterable or iterator, or any transpiled iterable or iterator from the Traceur ES6 Transpiler. Second, it's lazy by default...

Getting Started

In NodeJS

In your project directory run: npm install --save es6-iter

Start your Node program with the command line argument --harmony. Then use it like so: var iter = require('es6-iter').iter;

// A convoluted way to print 'Hello World'
iter(function*() { yield 'hello world!' })
  .forEach(function(string) {
    console.log(string);
  })
  .array();

In the Browser

Installing It

If you have Bower installed, in your project directory run:

bower install es6-iter

If you have Git installed, in your project directory run:

git clone https://github.com/jdt/es6-iter

Otherwise find the download repo button on this page and save it to your project directory.

Consuming It

Inside an ES6 JS File

Loading Iter in any ES6 environment is the simplest way to get the library.

import iter from 'es6-iter/src/iter';
console.log(iter([1,2,3]).array()); // Prints 1, 2, 3

With System Polyfill from Traceur

You can load Iter as a script that injects it's packages into the System polyfill used by Traceur. This is the suggested way to consume Iter in an ES5 JS environment given you have to load the Traceur runtime as a dependency to Iter. To do this you include the runtime and bundled script in your HTML page:

<script src="es6-iter/node_modules/traceur/bin/traceur-runtime.js"></script>
<script src="es6-iter/out/system/iter.js"></script>
<script>
  (function() {
    console.log(iter([1,2,3]).array()); // Prints 1, 2, 3
  })();
</script>

With AMD

Add iter and traceur-runtime to your requirejs config as a package:

requirejs.config({
  paths: {
    'traceur': 'es6-iter/node_modules/traceur/bin/traceur-runtime'
  },
  packages: [
    { name: 'iter', main: 'index.js', location: 'es6-iter/out/amd', }
  ]
})

Use it in any of your modules like so:

define(['iter'], function(iter) {
  iter = iter.iter;

  // Prints 1, 2, 3
  console.log(iter([1,2,3]).array());
})