Skip to content

Commit

Permalink
refactor: remove toplevel property access
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed May 10, 2019
1 parent d0dd728 commit 9fe10d3
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 2,618 deletions.
581 changes: 0 additions & 581 deletions integration/side-effects/snapshots/esm2015/index.js

Large diffs are not rendered by default.

581 changes: 0 additions & 581 deletions integration/side-effects/snapshots/esm2015/operators.js

Large diffs are not rendered by default.

623 changes: 1 addition & 622 deletions integration/side-effects/snapshots/esm5/index.js

Large diffs are not rendered by default.

623 changes: 1 addition & 622 deletions integration/side-effects/snapshots/esm5/operators.js

Large diffs are not rendered by default.

152 changes: 13 additions & 139 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -189,7 +189,7 @@
"benchmark": "2.1.0",
"benchpress": "2.0.0-beta.1",
"chai": "4.1.2",
"check-side-effects": "0.0.17",
"check-side-effects": "0.0.20",
"color": "3.0.0",
"colors": "1.1.2",
"commitizen": "2.9.6",
Expand Down Expand Up @@ -241,6 +241,7 @@
"tsconfig-paths": "3.2.0",
"tslint": "5.9.1",
"tslint-etc": "1.2.6",
"tslint-no-toplevel-property-access": "0.0.2",
"tslint-no-unused-expression-chai": "0.0.3",
"typescript": "^3.0.1",
"validate-commit-msg": "2.14.0",
Expand Down
27 changes: 14 additions & 13 deletions src/internal/observable/ConnectableObservable.ts
Expand Up @@ -55,19 +55,20 @@ export class ConnectableObservable<T> extends Observable<T> {
}
}

const connectableProto = <any>ConnectableObservable.prototype;

export const connectableObservableDescriptor: PropertyDescriptorMap = {
operator: { value: null },
_refCount: { value: 0, writable: true },
_subject: { value: null, writable: true },
_connection: { value: null, writable: true },
_subscribe: { value: connectableProto._subscribe },
_isComplete: { value: connectableProto._isComplete, writable: true },
getSubject: { value: connectableProto.getSubject },
connect: { value: connectableProto.connect },
refCount: { value: connectableProto.refCount }
};
export const connectableObservableDescriptor: PropertyDescriptorMap = (() => {
const connectableProto = <any>ConnectableObservable.prototype;
return {
operator: { value: null as null },
_refCount: { value: 0, writable: true },
_subject: { value: null as null, writable: true },
_connection: { value: null as null, writable: true },
_subscribe: { value: connectableProto._subscribe },
_isComplete: { value: connectableProto._isComplete, writable: true },
getSubject: { value: connectableProto.getSubject },
connect: { value: connectableProto.connect },
refCount: { value: connectableProto.refCount }
};
})();

class ConnectableSubscriber<T> extends SubjectSubscriber<T> {
constructor(destination: Subject<T>,
Expand Down
28 changes: 15 additions & 13 deletions src/internal/observable/dom/AjaxObservable.ts
Expand Up @@ -486,19 +486,21 @@ export interface AjaxErrorCtor {
new(message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError;
}

function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError {
Error.call(this);
this.message = message;
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType || request.responseType;
this.response = parseXhrResponse(this.responseType, xhr);
return this;
}

AjaxErrorImpl.prototype = Object.create(Error.prototype);
const AjaxErrorImpl = (() => {
function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError {
Error.call(this);
this.message = message;
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType || request.responseType;
this.response = parseXhrResponse(this.responseType, xhr);
return this;
}
AjaxErrorImpl.prototype = Object.create(Error.prototype);
return AjaxErrorImpl;
})();

export const AjaxError: AjaxErrorCtor = AjaxErrorImpl as any;

Expand Down
2 changes: 1 addition & 1 deletion src/internal/observable/dom/ajax.ts
Expand Up @@ -79,4 +79,4 @@ import { AjaxObservable, AjaxCreationMethod } from './AjaxObservable';
*
* ```
*/
export const ajax: AjaxCreationMethod = AjaxObservable.create;
export const ajax: AjaxCreationMethod = (() => AjaxObservable.create)();
2 changes: 1 addition & 1 deletion src/internal/observable/fromEvent.ts
Expand Up @@ -4,7 +4,7 @@ import { isFunction } from '../util/isFunction';
import { Subscriber } from '../Subscriber';
import { map } from '../operators/map';

const toString: Function = Object.prototype.toString;
const toString: Function = (() => Object.prototype.toString)();

export interface NodeStyleEventEmitter {
addListener: (eventName: string | symbol, handler: NodeEventHandler) => this;
Expand Down
2 changes: 1 addition & 1 deletion src/internal/symbol/observable.ts
Expand Up @@ -8,4 +8,4 @@ declare global {
}

/** Symbol.observable or a string "@@observable". Used for interop */
export const observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
export const observable = (() => typeof Symbol === 'function' && Symbol.observable || '@@observable')();
4 changes: 2 additions & 2 deletions src/internal/symbol/rxSubscriber.ts
@@ -1,8 +1,8 @@
/** @deprecated do not use, this is no longer checked by RxJS internals */
export const rxSubscriber =
export const rxSubscriber = (() =>
typeof Symbol === 'function'
? Symbol('rxSubscriber')
: '@@rxSubscriber_' + Math.random();
: '@@rxSubscriber_' + Math.random())();

/**
* @deprecated use rxSubscriber instead
Expand Down
18 changes: 11 additions & 7 deletions src/internal/util/ArgumentOutOfRangeError.ts
Expand Up @@ -5,14 +5,18 @@ export interface ArgumentOutOfRangeErrorCtor {
new(): ArgumentOutOfRangeError;
}

function ArgumentOutOfRangeErrorImpl(this: any) {
Error.call(this);
this.message = 'argument out of range';
this.name = 'ArgumentOutOfRangeError';
return this;
}
const ArgumentOutOfRangeErrorImpl = (() => {
function ArgumentOutOfRangeErrorImpl(this: any) {
Error.call(this);
this.message = 'argument out of range';
this.name = 'ArgumentOutOfRangeError';
return this;
}

ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);

ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
return ArgumentOutOfRangeErrorImpl;
})();

/**
* An error thrown when an element was queried at a certain index of an
Expand Down
18 changes: 11 additions & 7 deletions src/internal/util/EmptyError.ts
Expand Up @@ -5,14 +5,18 @@ export interface EmptyErrorCtor {
new(): EmptyError;
}

function EmptyErrorImpl(this: any) {
Error.call(this);
this.message = 'no elements in sequence';
this.name = 'EmptyError';
return this;
}
const EmptyErrorImpl = (() => {
function EmptyErrorImpl(this: any) {
Error.call(this);
this.message = 'no elements in sequence';
this.name = 'EmptyError';
return this;
}

EmptyErrorImpl.prototype = Object.create(Error.prototype);

EmptyErrorImpl.prototype = Object.create(Error.prototype);
return EmptyErrorImpl;
})();

/**
* An error thrown when an Observable or a sequence was queried but has no
Expand Down

0 comments on commit 9fe10d3

Please sign in to comment.