• Stars
    star
    3,427
  • Rank 13,041 (Top 0.3 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

High-level streams library for Node.js and the browser

Highland

The high-level streams library for Node.js and the browser. View the Highland website for more in-depth documentation.

build status Join the chat at https://gitter.im/caolan/highland

Introduction

Re-thinking the JavaScript utility belt, Highland manages synchronous and asynchronous code easily, using nothing more than standard JavaScript and Node-like Streams. You may be familiar with Promises, EventEmitters and callbacks, but moving between them is far from seamless. Thankfully, there exists a deeper abstraction which can free our code. By updating the tools we use on Arrays, and applying them to values distributed in time instead of space, we can discard plumbing and focus on the important things. With Highland, you can switch between synchronous and asynchronous data sources at will, without having to re-write your code. Time to dive in!

Made by @caolan, with help and patience from friends :)

Highland v3

This branch tracks the ongoing development of version 3.0, which will feature a rewritten Highland core implementation, extensibility support, limited stream lifecycle, and some breaking changes to certain transforms. See #179 and the 3.x label for more details. New features will only be added to this branch. However, until 3.0 is released, we will still be doing bug fixes for the 2.x releases. See the 2.x branch for those files.

Currently, the code is in a semi-stable state. The only major missing feature is onDestroy for higher-level transforms. To try out the new goodness, install the next tag from NPM.

npm install --save highland@next

Interoperability

Highland implements the Fantasy Land Alternative, Filterable, and Monad specifications.

Highland supports Transducers via the transduce transform.

Examples

Usage as a Node.js module

var _ = require('highland');

Converting to/from Highland Streams

_([1,2,3,4]).toArray(function (xs) {
    // xs is [1,2,3,4]
});

Mapping over a Stream

var doubled = _([1,2,3,4]).map(function (x) {
    return x * 2;
});

Reading files in parallel (4 at once)

var data = _(filenames).map(readFile).parallel(4);

Handling errors

data.errors(function (err, rethrow) {
    // handle or rethrow error
});

Piping to a Node Stream

data.pipe(output);

Piping in data from Node Streams

var output = fs.createWriteStream('output');
var docs = db.createReadStream();

// wrap a node stream and pipe to file
_(docs).filter(isBlogpost).pipe(output);

// or, pipe in a node stream directly:
var through = _.pipeline(_.filter(isBlogpost));
docs.pipe(through).pipe(output);

Handling events

var clicks = _('click', btn).map(1);
var counter = clicks.scan(0, _.add);

counter.each(function (n) {
    $('#count').text(n);
});

Learn more at https://caolan.github.io/highland/

More Repositories

1

async

Async utilities for node and the browser
JavaScript
28,095
star
2

nodeunit

Easy unit testing in node.js and the browser, based on the assert module.
JavaScript
1,899
star
3

jam

JavaScript package manager - using a browser-focused and RequireJS compatible repository
JavaScript
1,497
star
4

forms

An easy way to create, parse and validate forms in node.js
JavaScript
1,010
star
5

pithy

An internal DSL for generating HTML in JavaScript
JavaScript
435
star
6

nimble

A really tiny functional JavaScript and async flow-control library
JavaScript
329
star
7

petrify

A flexible static site generator for node.js
JavaScript
259
star
8

cookie-sessions

Secure cookie-based session middleware for Connect
JavaScript
97
star
9

quip

A chainable API for response objects in node
JavaScript
92
star
10

dispatch

A regular expression URL dispatcher for Connect
JavaScript
84
star
11

magery

JavaScript templates for progressive enhancement
JavaScript
56
star
12

copykitten

Tiny immutable JSON data structures
JavaScript
40
star
13

jquery.notify.js

Ubuntu-style notifications within a web browser
JavaScript
25
star
14

couchr

Lightweight CouchDB request library for Node and the browser
JavaScript
22
star
15

hoodie-drawing

Hoodie drawing demo app
JavaScript
20
star
16

cpm

CouchDB Package Manager - a tool for the management of CouchApps and associated libraries
JavaScript
16
star
17

wmd

wanton markdown - a markdown parser based on showdown
JavaScript
15
star
18

blog

CouchApp code used to run my blog
JavaScript
15
star
19

tamawiki

I'm learning Rust!
Rust
13
star
20

chicken-toml

A TOML parser for CHICKEN Scheme built with comparse
Scheme
11
star
21

docker-hoodie

Basic docker file for trying out hoodie
Shell
10
star
22

bootstrap-less

Kanso package providing uncompiled less files for bootstrap with images and js as attachments
JavaScript
10
star
23

behaviors

A (really) simple way to check a modules export's in node.js. Inspired by behaviors in Erlang.
JavaScript
9
star
24

snowy

HTTP server for CHICKEN Scheme
C
8
star
25

events

Browser port of the node.js events module
JavaScript
8
star
26

lolcorp

Intentionally insecure example Node.js applications
JavaScript
7
star
27

raspberry-pi-gpio

Raspberry Pi GPIO library for CHICKEN Scheme
Scheme
6
star
28

scrawl

Dumb comment parsing
JavaScript
6
star
29

pithy2

A Typescript-friendly and human-friendly API for building DOM elements
TypeScript
5
star
30

snake

Snake game for the BBC micro:bit
Python
5
star
31

erlmpd

An Erlang client module for MPD
Erlang
5
star
32

chicken-leveldb

CHICKEN Scheme bindings to LevelDB
Scheme
5
star
33

python-magery

Python implementation of Magery templates
Python
5
star
34

highland-couchr

Highland streams style API to CouchDB, using couchr under the hood
JavaScript
4
star
35

mutiny

Rust
4
star
36

chicken-sodium

CHICKEN Scheme bindings to libsodium crypto library
Scheme
3
star
37

0

3
star
38

ghstats

allows you to compare github users followers and project watchers
JavaScript
3
star
39

couchr-browser

Lightweight library for making CouchDB requests, based on jQuery
JavaScript
2
star
40

couchi

CouchDB command-line interface
JavaScript
2
star
41

magery-tests

Test suite for server implementations of Magery templates
HTML
2
star
42

chat

Kanso chat app
JavaScript
2
star
43

lmdb-lolevel

Low-level CHICKEN Scheme bindings to LMDB, closely following the C API
Scheme
2
star
44

condor

C O N D O R
JavaScript
2
star
45

chicken-level

abstract API layer for chicken-leveldb
Scheme
2
star
46

gamejam

First Play Sheffield Game Jam!
JavaScript
2
star
47

chicken-ldap-bind

Implements LDAP bind for authentication using OpenLDAP
Scheme
2
star
48

library

CouchApp for storing templates
JavaScript
2
star
49

chicken-gumbo

C binding to the Gumbo HTML parser for CHICKEN Scheme
Scheme
2
star
50

dust

P2P event streams
Scheme
2
star
51

users-core

Core resources for the users app, must be used with a theme (eg, users-default)
JavaScript
2
star
52

gh-label-dashboard

An example of using the github search API to query labels across all repositories in an organisation
1
star
53

validatejs

JavaScript
1
star
54

webhook-test

1
star
55

users-default

Default bootstrap theme for users app
1
star
56

chicken-sublevel

Namespaced access to leveldb implementations
Scheme
1
star
57

chicken-level-sexp

Automatically read and write s-expressions to leveldb
Scheme
1
star
58

chicken-fnmatch

Test filenames against shell wildcard patterns using fnmatch
Scheme
1
star
59

jambot

IRC bot for #jamjs
JavaScript
1
star
60

mochiproxy

Easily proxy mochiweb requests, based on the CouchDB proxy module
Erlang
1
star
61

highland-couchdb-alldocs

Provides Highland streams for reading all keys/docs in a CouchDB database
JavaScript
1
star