Skip to content

Commit

Permalink
Merge branch 'master' into distinct-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps authored Oct 26, 2016
2 parents 11894d0 + d13dbb4 commit 4f11da2
Show file tree
Hide file tree
Showing 15 changed files with 6,552 additions and 55 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
perf
spec
.git
yarn.lock
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ cache:
env:
global:
- CXX=g++-4.8
- alias tsc=./node_modules/.bin/tsc
- alias grunt=./node_modules/grunt-cli/bin/grunt

before_install:
- npm install -g npm@3 && npm install grunt@0.4.1 grunt-cli grunt-contrib-connect grunt-run
- npm install -g npm@latest && npm install -g yarn

install:
- npm install && npm run lint
- yarn && npm install grunt-cli && npm install grunt@0.4.1 grunt-contrib-connect grunt-run && npm run lint

script:
- npm run build_spec && npm run test_mocha && node ./node_modules/markdown-doctest/bin/cmd.js
Expand Down
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"build_es6": "npm-run-all clean_dist_es6 copy_src_es6 compile_dist_es6",
"build_es6_for_docs": "npm-run-all clean_dist_es6 copy_src_es6 compile_dist_es6_for_docs",
"build_closure_core": "node ./tools/make-closure-core.js",
"build_global": "npm-run-all clean_dist_global build_es6 && mkdirp ./dist/global && node tools/make-umd-bundle.js && npm-run-all build_closure_core",
"build_global": "npm-run-all clean_dist_global build_es6 && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core",
"build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf",
"build_test": "shx rm -rf ./dist/ && npm-run-all build_cjs clean_spec build_spec test_mocha",
"build_cover": "shx rm -rf ./dist/ && npm-run-all build_cjs build_spec cover",
Expand All @@ -83,10 +83,10 @@
"lint_spec": "tslint -c tslint.json spec/*.ts spec/**/*.ts spec/**/**/*.ts",
"lint_src": "tslint -c tslint.json src/*.ts src/**/*.ts src/**/**/*.ts",
"lint_staged": "lint-staged",
"lint": "npm-run-all lint_src lint_spec lint_perf",
"lint": "npm-run-all --parallel lint_*",
"perf": "protractor protractor.conf.js",
"perf_micro": "node ./perf/micro/index.js",
"prepublish": "shx rm -rf ./typings && typings install && npm run build_all",
"prepublish": "npm run build_all",
"publish_docs": "./publish_docs.sh",
"test_mocha": "mocha --opts spec/support/default.opts spec-js",
"debug_mocha": "node-debug _mocha --opts spec/support/debug.opts spec-js",
Expand Down Expand Up @@ -144,6 +144,11 @@
},
"homepage": "https://github.com/ReactiveX/RxJS",
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/lodash": "^4.14.37",
"@types/mocha": "^2.2.32",
"@types/sinon": "^1.16.31",
"@types/sinon-chai": "^2.7.27",
"babel-core": "6.17.0",
"babel-polyfill": "6.16.0",
"babel-preset-es2015": "6.16.0",
Expand All @@ -158,18 +163,18 @@
"doctoc": "^1.0.0",
"escape-string-regexp": "^1.0.5 ",
"esdoc": "^0.4.7",
"eslint": "^2.12.0",
"eslint": "^3.8.0",
"fs-extra": "^0.30.0",
"ghooks": "1.2.3",
"ghooks": "^1.3.2",
"glob": "^7.0.3",
"gm": "^1.22.0",
"google-closure-compiler-js": "^20160916.0.0",
"gzip-size": "^3.0.0",
"http-server": "^0.9.0",
"lint-staged": "^1.0.2",
"lint-staged": "^3.1.0",
"lodash": "^4.15.0",
"madge": "^0.5.4",
"markdown-doctest": "^0.7.0",
"madge": "^1.4.3",
"markdown-doctest": "^0.8.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"mocha": "^3.0.2",
Expand All @@ -189,9 +194,9 @@
"source-map-support": "^0.4.0",
"tslint": "^3.15.1",
"typescript": "^2.0.3",
"typings": "^1.3.3",
"validate-commit-msg": "^2.3.1",
"watch": "^0.18.0",
"watch": "^1.0.1",
"watchify": "3.7.0",
"webpack": "^1.13.1",
"xmlhttprequest": "1.8.0"
},
Expand All @@ -202,4 +207,4 @@
"dependencies": {
"symbol-observable": "^1.0.1"
}
}
}
1 change: 0 additions & 1 deletion spec/helpers/marble-testing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
///<reference path='../../typings/index.d.ts'/>
import {Observable} from '../../dist/cjs/Observable';
import {SubscriptionLog} from '../../dist/cjs/testing/SubscriptionLog';
import {ColdObservable} from '../../dist/cjs/testing/ColdObservable';
Expand Down
1 change: 0 additions & 1 deletion spec/helpers/test-helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
///<reference path='../../typings/index.d.ts'/>
declare const global: any;
declare const Symbol: any;

Expand Down
1 change: 0 additions & 1 deletion spec/helpers/testScheduler-ui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
///<reference path='../../typings/index.d.ts'/>
///<reference path='ambient.d.ts'/>

import * as _ from 'lodash';
Expand Down
21 changes: 21 additions & 0 deletions spec/operators/bufferCount-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Rx from '../../dist/cjs/Rx';
import { expect } from 'chai';
declare const {hot, asDiagram, expectObservable, expectSubscriptions};

const Observable = Rx.Observable;
Expand Down Expand Up @@ -31,6 +32,26 @@ describe('Observable.prototype.bufferCount', () => {
expectObservable(e1.bufferCount(2)).toBe(expected, values);
});

it('should buffer properly (issue #2062)', () => {
const item$ = new Rx.Subject();
const results = [];
item$
.bufferCount(3, 1)
.subscribe(value => {
results.push(value);

if (value.join() === '1,2,3') {
item$.next(4);
}
});

item$.next(1);
item$.next(2);
item$.next(3);

expect(results).to.deep.equal([[1, 2, 3], [2, 3, 4]]);
});

it('should emit partial buffers if source completes before reaching specified buffer count', () => {
const e1 = hot('--a--b--c--d--|');
const expected = '--------------(x|)';
Expand Down
2 changes: 1 addition & 1 deletion src/observable/ConnectableObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class RefCountSubscriber<T> extends Subscriber<T> {
// Compare the local RefCountSubscriber's connection Subscription to the
// connection Subscription on the shared ConnectableObservable. In cases
// where the ConnectableObservable source synchronously emits values, and
// the RefCountSubscriber's dowstream Observers synchronously unsubscribe,
// the RefCountSubscriber's downstream Observers synchronously unsubscribe,
// execution continues to here before the RefCountOperator has a chance to
// supply the RefCountSubscriber with the shared connection Subscription.
// For example:
Expand Down
2 changes: 1 addition & 1 deletion src/observable/FromEventObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class FromEventObservable<T, R> extends Observable<T> {
* EventEmitter, NodeList or HTMLCollection to attach the event handler to.
* @param {string} eventName The event name of interest, being emitted by the
* `target`.
* @parm {EventListenerOptions} [options] Options to pass through to addEventListener
* @param {EventListenerOptions} [options] Options to pass through to addEventListener
* @param {SelectorMethodSignature<T>} [selector] An optional function to
* post-process results. It takes the arguments from the event handler and
* should return a single value.
Expand Down
6 changes: 3 additions & 3 deletions src/observable/GenerateObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface SchedulerState<T, S> {

export interface GenerateBaseOptions<S> {
/**
* Inital state.
* Initial state.
*/
initialState: S;
/**
Expand Down Expand Up @@ -124,7 +124,7 @@ export class GenerateObservable<T, S> extends Observable<T> {
* Generates an observable sequence by running a state-driven loop
* producing the sequence's elements, using the specified scheduler
* to send out observer messages.
* The overload accepts options object that might contain inital state, iterate,
* The overload accepts options object that might contain initial state, iterate,
* condition and scheduler.
*
* <img src="./img/generate.png" width="100%">
Expand All @@ -148,7 +148,7 @@ export class GenerateObservable<T, S> extends Observable<T> {
* Generates an observable sequence by running a state-driven loop
* producing the sequence's elements, using the specified scheduler
* to send out observer messages.
* The overload accepts options object that might contain inital state, iterate,
* The overload accepts options object that might contain initial state, iterate,
* condition, result selector and scheduler.
*
* <img src="./img/generate.png" width="100%">
Expand Down
22 changes: 7 additions & 15 deletions src/operator/bufferCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,30 @@ class BufferCountOperator<T> implements Operator<T, T[]> {
* @extends {Ignored}
*/
class BufferCountSubscriber<T> extends Subscriber<T> {
private buffers: Array<T[]> = [[]];
private buffers: Array<T[]> = [];
private count: number = 0;

constructor(destination: Subscriber<T[]>, private bufferSize: number, private startBufferEvery: number) {
super(destination);
}

protected _next(value: T) {
const count = (this.count += 1);
const destination = this.destination;
const bufferSize = this.bufferSize;
const startBufferEvery = (this.startBufferEvery == null) ? bufferSize : this.startBufferEvery;
const buffers = this.buffers;
const len = buffers.length;
let remove = -1;
const count = this.count++;
const { destination, bufferSize, startBufferEvery, buffers } = this;
const startOn = (startBufferEvery == null) ? bufferSize : startBufferEvery;

if (count % startBufferEvery === 0) {
if (count % startOn === 0) {
buffers.push([]);
}

for (let i = 0; i < len; i++) {
for (let i = buffers.length; i--; ) {
const buffer = buffers[i];
buffer.push(value);
if (buffer.length === bufferSize) {
remove = i;
buffers.splice(i, 1);
destination.next(buffer);
}
}

if (remove !== -1) {
buffers.splice(remove, 1);
}
}

protected _complete() {
Expand Down
2 changes: 1 addition & 1 deletion tools/make-umd-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rollup.rollup({
var out = babel.transform(result.code, {
compact: false,
presets: [
['es2015', {loose: true}]
['es2015', { loose: true }]
],
});

Expand Down
17 changes: 12 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
"suppressImplicitAnyIndexErrors": true,
"moduleResolution": "node",
"target": "es6",
"outDir": "dist/es6"
"outDir": "dist/es6",
"lib": [
"es5",
"es2015.iterable",
"es2015.collection",
"es2015.promise",
"dom"
]
},
"formatCodeOptions": {
"indentSize": 2,
"tabSize": 2
},
"files": [
"src/Rx.ts"
]
}
"files": [
"src/Rx.ts"
]
}
12 changes: 0 additions & 12 deletions typings.json

This file was deleted.

Loading

0 comments on commit 4f11da2

Please sign in to comment.