Skip to content

Commit

Permalink
fix(fromArray): rename from() producer to fromArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Medeiros committed Apr 8, 2016
1 parent 6c803ac commit 05f519a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
CombineFactorySignature,
CombineProjectFunction} from './factory/CombineProducer';
import {EventProducer} from './factory/EventProducer';
import {FromProducer} from './factory/FromProducer';
import {FromArrayProducer} from './factory/FromArrayProducer';
import {IntervalProducer} from './factory/IntervalProducer';
import {MergeProducer} from './factory/MergeProducer';
import {empty} from './utils/empty';
Expand Down Expand Up @@ -151,12 +151,12 @@ export class Stream<T> implements InternalListener<T> {
});
}

static from<T>(array: Array<T>): Stream<T> {
return new Stream<T>(new FromProducer(array));
static fromArray<T>(array: Array<T>): Stream<T> {
return new Stream<T>(new FromArrayProducer(array));
}

static of<T>(...items: Array<T>): Stream<T> {
return Stream.from(items);
return Stream.fromArray(items);
}

static interval(period: number): Stream<number> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {InternalProducer} from '../InternalProducer';
import {InternalListener} from '../InternalListener';
import {noop} from '../utils/noop';

export class FromProducer<T> implements InternalProducer<T> {
export class FromArrayProducer<T> implements InternalProducer<T> {
constructor(private a: Array<T>) {
}

Expand Down
12 changes: 6 additions & 6 deletions tests/factory/from.ts → tests/factory/fromArray.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import xs from '../../src/index';
import * as assert from 'assert';

describe('xs.from', () => {
describe('xs.fromArray', () => {
it('should convert an array to a stream', (done) => {
const stream = xs.from([10, 20, 30, 40, 50])
const stream = xs.fromArray([10, 20, 30, 40, 50])
.map(i => String(i));
let expected = ['10', '20', '30', '40', '50'];
let listener = {

stream.addListener({
next: (x: string) => {
assert.equal(x, expected.shift());
},
error: done.fail,
error: (err: any) => done(err),
complete: () => {
assert.equal(expected.length, 0);
done();
},
};
stream.addListener(listener);
});
});
});
2 changes: 1 addition & 1 deletion tests/operator/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Stream.prototype.flatten', () => {
});

it('should expand 3 sync events as an interval, only last one passes', (done) => {
const stream = xs.from([0, 1, 2])
const stream = xs.fromArray([0, 1, 2])
.map(i => xs.interval(100 * i).take(2).map(x => `${i}${x}`))
.flatten();
// ---x---x---x---x---x---x
Expand Down
2 changes: 1 addition & 1 deletion tests/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Stream', () => {
assert.equal(typeof xs.never, 'function');
assert.equal(typeof xs.empty, 'function');
assert.equal(typeof xs.throw, 'function');
assert.equal(typeof xs.from, 'function');
assert.equal(typeof xs.fromArray, 'function');
assert.equal(typeof xs.of, 'function');
assert.equal(typeof xs.interval, 'function');
assert.equal(typeof xs.merge, 'function');
Expand Down

0 comments on commit 05f519a

Please sign in to comment.