GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - projectfluent/cached-iterable: Iterables which cache the values they yield

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
babel_config.js
babel_config.js
 
 
bundle_config.js
bundle_config.js
 
 
compat_config.js
compat_config.js
 
 
eslint_src.json
eslint_src.json
 
 
eslint_test.json
eslint_test.json
 
 
mocha_config.js
mocha_config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

cached-iterable

cached-iterable exposes two classes which implement the iterable protocol:

  • CachedSyncIterable,
  • CachedAsyncIterable.

You can wrap any iterable in these classes to create a new iterable which caches the yielded elements. This is useful for iterating over an iterable many times without depleting it.

Installation

cached-iterable can be used both on the client-side and the server-side. You can install it from the npm registry or use it as a standalone script (as the CachedIterable global).

npm install cached-iterable

How to use

import assert from "assert";
import {CachedSyncIterable} from "cached-iterable";

function * countdown(i) {
    while (i--) {
        yield i;
    }
}

let numbers = new CachedSyncIterable(countdown(3));

// `numbers` can be iterated over multiple times.
assert.deepEqual([...numbers], [3, 2, 1, 0]);
assert.deepEqual([...numbers], [3, 2, 1, 0]);

Compatibility

For legacy browsers, the compat build has been transpiled using Babel's env preset. It requires the regenerator runtime provided by babel-polyfill.

import {CachedSyncIterable} from 'cached-iterable/compat';

About

Iterables which cache the values they yield

Resources

Readme
Activity
Custom properties

Stars

6 stars

Watchers

5 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.