/libfree

LibFree an experiment for using Iterables and :: operator

Primary LanguageJavaScriptMIT LicenseMIT

LibFree is an experiment in Tranducers using Iterables and :: operator

A simple iterator library for JavaScript meant for exploration of Transducers.

Inspired by experimental ES7syntax proposed by Kevin Smith (@zenparsing).

Also heavily influenced by C# Linq

Here is a good explanation on Transducers using JavaScript, though the approach is very different. Understanding Transducers in JavaScript

Installation:

git clone git@github.com:dax70/libfree.git
cd libfree
npm install

Run tests to see API usage and working code.

npm test

There has been a proposal for ES7 (EcmaScript 2016) for function binding syntax for a while.

Here is an example from the proposal and using an iterator library as an example.

/* ES7 */
import { map, takeWhile, forEach } from "iterlib";

getPlayers()
::map(x => x.character())
::takeWhile(x => x.strength > 100)
::forEach(x => console.log(x));

As you may notice, in this case it enables a now common pattern in Javascript thanks to jQuery, namely the Fluent Interface, but more on that later.

Development:

  • Build once: npm run webpack
  • Run dev server: npm start