small API updates for highland 1.19.0

This commit is contained in:
Bart van der Schoor
2014-03-16 18:48:56 +01:00
parent 54d4f70ef8
commit a5e6460613
2 changed files with 87 additions and 13 deletions
+20 -11
View File
@@ -73,15 +73,15 @@ var barArr: Bar[];
var fooStream: Highland.Stream<Foo>;
var barStream: Highland.Stream<Bar>;
var fooStreamStream: Highland.Stream<Highland.Stream<Foo>>;
var barStreamStream: Highland.Stream<Highland.Stream<Bar>>;
var fooArrStream: Highland.Stream<Foo[]>;
var barArrStream: Highland.Stream<Bar[]>;
var fooStreamArr: Highland.Stream<Foo>[];
var barStreamArr: Highland.Stream<Bar>[];
var fooStreamArr: Highland.Stream<Foo>[];
var barStreamArr: Highland.Stream<Bar>[];
var strFooArrMapStream: Highland.Stream<StrFooArrMap>;
var strBarArrMapStream: Highland.Stream<StrBarArrMap>;
@@ -184,13 +184,13 @@ strStream = _.keys(obj);
anyArrStream = _.pairs(obj);
anyArrStream = _.pairs(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
obj = _.extend(obj, obj);
objCurObj = _.extend(obj);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
x = _.get(str, obj);
@@ -200,26 +200,26 @@ obj = _.set(str, foo, obj);
objCurAny = _.set(str, foo);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_.log(str);
_.log(str, num, foo);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
f = _.wrapCallback(func);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
num = _.add(num, num);
numCurNum = _.add(num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// instance methods
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooStream.pause();
fooStream.resume();
@@ -323,6 +323,10 @@ fooStream = fooStream.flatFilter((x: Foo) => {
return boolStream;
});
fooStream = fooStream.reject((x: Foo) => {
return bool;
});
fooStream = fooStream.find((x: Foo) => {
return bool;
});
@@ -343,6 +347,7 @@ fooStream = fooStream.where(obj);
fooStream = fooStream.zip(fooStream);
fooStream = fooStream.zip([foo, foo]);
fooStream = fooStream.head();
fooStream = fooStream.take(num);
fooStream = fooStream.last();
@@ -383,6 +388,10 @@ fooStream = fooStream.concat(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooStream = fooStream.merge(fooStreamStream);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barStream = fooStream.invoke<Bar>(str, anyArr);
fooStream = fooStream.throttle(num);
@@ -393,4 +402,4 @@ fooStream = fooStream.debounce(num);
fooStream = fooStream.latest();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+67 -2
View File
@@ -8,6 +8,7 @@
// TODO export the top-level functions
// TODO figure out curry arguments
// TODO create more overloads for nested data, like streams-of-streams or streams-of-array-of-streams etc
// TODO use externalised Thenable
// TODO use externalised Readable/Writable (not node's)
@@ -19,7 +20,6 @@
* Copyright (c) Caolan McMahon
*
*/
interface HighlandStatic {
/**
* The Stream constructor, accepts an array of values or a generator function
@@ -320,8 +320,9 @@ interface HighlandStatic {
* @api public
*/
add(a: number, b: number): number;
add(a: number): (b: number) => number;
not<R>(a: any): boolean;
}
declare module Highland {
@@ -660,6 +661,21 @@ declare module Highland {
*/
flatFilter(f: (x: R) => Stream<boolean>): Stream<R>;
/**
* The inverse of [filter](#filter).
*
* @id reject
* @section Streams
* @name Stream.reject(f)
* @param {Function} f - the truth test function
* @api public
*
* var odds = _([1, 2, 3, 4]).reject(function (x) {
* return x % 2 === 0;
* });
*/
reject(f: (x: R) => boolean): Stream<R>;
/**
* A convenient form of filter, which returns the first object from a
* Stream that passes the provided truth test
@@ -733,6 +749,18 @@ declare module Highland {
*/
take(n: number): Stream<R>;
/**
* Creates a new Stream with only the first value from the source.
*
* @id head
* @section Streams
* @name Stream.head()
* @api public
*
* _([1, 2, 3, 4]).head() // => 1
*/
head(): Stream<R>;
/**
* Drops all values from the Stream apart from the last one (if any).
*
@@ -871,6 +899,20 @@ declare module Highland {
*/
scan<U>(memo: U, x: (memo: U, x: R) => U): Stream<U>;
/**
* Same as [scan](#scan), but uses the first element as the initial
* state instead of passing in a `memo` value.
*
* @id scan1
* @section Streams
* @name Stream.scan1(iterator)
* @param {Function} iterator - the function which reduces the values
* @api public
*
* _([1, 2, 3, 4]).scan1(add) // => 1, 3, 6, 10
*/
scan1<U>(memo: U, x: (memo: U, x: R) => U): Stream<U>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
@@ -889,6 +931,29 @@ declare module Highland {
concat(ys: Stream<R>): Stream<R>;
concat(ys: R[]): Stream<R>;
/**
* Takes a Stream of Streams and merges their values and errors into a
* single new Stream. The merged stream ends when all source streams have
* ended.
*
* Note that no guarantee is made with respect to the order in which
* values for each stream end up in the merged stream. Values in the
* merged stream will, however, respect the order they were emitted from
* their respective streams.
*
* @id merge
* @section Streams
* @name Stream.merge()
* @api public
*
* var txt = _(['foo.txt', 'bar.txt']).map(readFile)
* var md = _(['baz.md']).map(readFile)
*
* _([txt, md]).merge();
* // => contents of foo.txt, bar.txt and baz.txt in the order they were read
*/
merge (ys: Stream<Stream<R>>): Stream<R>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**