Highland: the high-level streams library
Highland may be freely distributed under the Apache 2.0 license. http://github.com/caolan/highland Copyright (c) Caolan McMahon
The Stream constructor, accepts an array of values or a generator function as an optional argument. This is typically the entry point to the Highland APIs, providing a convenient way of chaining calls together.
Arrays - Streams created from Arrays will emit each value of the Array and then emit a nil value to signal the end of the Stream.
Generators - These are functions which provide values for the Stream.
They are lazy and can be infinite, they can also be asynchronous (for
example, making a HTTP request). You emit values on the Stream by calling
push(err, val)
, much like a standard Node.js callback. You call next()
to signal you've finished processing the current data. If the Stream is
still being consumed the generator function will then be called again.
You can also redirect a generator Stream by passing a new source Stream
to read from to next. For example: next(other_stream)
- then any subsequent
calls will be made to the new source.
Node Readable Stream - Pass in a Node Readable Stream object to wrap it with the Highland API. Reading from the resulting Highland Stream will begin piping the data from the Node Stream to the Highland Stream.
EventEmitter / jQuery Elements - Pass in both an event name and an event emitter as the two arguments to the constructor and the first argument emitted to the event handler will be written to the new Stream.
Promise - Accepts an ES6 / jQuery style promise and returns a Highland Stream which will emit a single value (or an error).
The end of stream marker. This is sent along the data channel of a Stream to tell consumers that the Stream has ended. See the following map code for an example of detecting the end of a Stream:
Add two values. Can be partially applied.
number
(b: number) => number
Creates a composite function, which is the application of function1 to the results of function2. You can pass an arbitrary number of arguments and have them composed. This means you can't partially apply the compose function itself.
Function
Transforms a function with specific arity (all arguments must be defined) in a way that it can be called as a chain of functions until the arguments list is saturated.
This function is not itself curryable.
Function
Function
Extends one object with the properties of another. Note: The arguments are in the reverse order of other libraries such as underscore. This is so it follows the convention of other functions in this library and so you can more meaningfully partially apply it.
Object
(extensions: Object) => Object
Evaluates the function fn
with the argument positions swapped. Only
works with functions that accept two arguments.
Function
Returns a property from an object.
string
(obj: Object) => Object
Returns true if x
is a Highland Stream.
boolean
boolean
boolean
Returns keys from an Object as a Stream.
Logs values to the console, a simple wrapper around console.log
that
it suitable for passing to other functions by reference without having to
call bind
.
Same as curry
but with a specific number of arguments. This can be
useful when functions do not explicitly define all its parameters.
This function is not itself curryable.
Function
Function
boolean
Returns key/value pairs for an Object as a Stream. Reads properties lazily, so if you don't read from all keys on an object, not all properties will be read from (may have an effect where getters are used).
Partially applies the function (regardless of whether it has had curry called on it). This will always postpone execution until at least the next call of the partially applied function.
Function
The reversed version of compose. Where arguments are in the order of application.
Function
Updates a property on an object, returning the updated object.
Object
(obj: Object) => Object
Returns values from an Object as a Stream. Reads properties lazily, so if you don't read from all keys on an object, not all properties will be read from (may have an effect where getters are used).
Wraps a node-style async function which accepts a callback, transforming it to a function which accepts the same arguments minus the callback and returns a Highland Stream instead. Only the first argument to the callback (or an error) will be pushed onto the Stream.
Function