adding some missing methods, adding README with unsupported method list

This commit is contained in:
Bence Eros
2015-06-14 02:05:27 +02:00
parent a8871c9dfa
commit b9dab01b68
3 changed files with 30 additions and 4 deletions

22
streamjs/README.md Normal file
View File

@@ -0,0 +1,22 @@
# StreamJS Type Definitions
Unsupported StreamJS function / method signatures:
* Stream(collection)
* Stream(string)
* Stream.empty()
* filter(sample)
* map(path)
* flatMap(path)
* sorted(path)
* takeWhile(sample)
* dropWhile(sample)
* min(path)
* max(path)
* sum(path)
* average(path)
* allMatch(sample)
* anyMatch(sample)
* groupingBy(path)
* toMap(path, mergeFunction)
* partitioningBy(sample);
* Optional.empty()

View File

@@ -1,11 +1,9 @@
// <reference file="streamjs.d.ts" />
var numStream: Stream<number>;
// numStream = Stream.make(10, 20);
numStream = Stream.make([10, 20]);
numStream = Stream.of(1, 2, 3);
numStream = Stream.range(1, 5);
numStream = Stream.rangeClosed(1, 5);
// numStream = Stream.empty();
Stream.generate(function() {
return 1;
@@ -37,7 +35,9 @@ var strStream = numStream
;
var strArray = strStream.toArray();
strArray = strStream.toList();
strStream.each(s => console.log(s));
strStream.filter(/^$/);
strStream.forEach(s => console.log(s));
var opt: Stream.Optional<string> = strStream.findFirst();
opt = strStream.findAny();

View File

@@ -6,6 +6,7 @@
declare class Stream<T> {
// static make <T> (...elems: T[]): Stream<T>;
static make <T> (elems: T[]): Stream<T>;
static of<T>(...elems: T[]): Stream<T>;
static range (startInclusive: number, endExclusive: number): Stream<number>;
static rangeClosed (startInclusive: number, endInclusive: number): Stream<number>;
static generate <T> (supplier: Stream.Supplier<T>): Stream<T>;
@@ -23,7 +24,9 @@ declare class Stream<T> {
distinct(): Stream<T>;
dropWhile(predicate: Stream.Predicate<T>): Stream<T>;
dropWhile(regexp: RegExp): Stream<string>;
each(consumer: Stream.Consumer<T>): void;
filter(predicate: Stream.Predicate<T>): Stream<T>;
filter(regexp: RegExp): Stream<string>;
findAny(): Stream.Optional<T>;
findFirst(): Stream.Optional<T>;
forEach(consumer: Stream.Consumer<T>): void;
@@ -69,6 +72,7 @@ declare class Stream<T> {
takeWhile(predicate: Stream.Predicate<T>): Stream<T>;
takeWhile(regexp: RegExp): Stream<string>;
toArray(): T[];
toList(): T[];
toMap(keyMapper: Stream.Function<T, string>, mergeFunction?: Stream.Accumulator<T>): T[];
}