new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operator/filter"));
|
||||
//# sourceMappingURL=filter.js.map
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/operator/mergeScan");
|
||||
//# sourceMappingURL=mergeScan.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00671,"53":0,"54":0,"55":0,"56":0.04694,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.00335,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00335,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0.00335,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.00335,"103":0,"104":0,"105":0.00335,"106":0.00335,"107":0.00671,"108":0.20453,"109":0.11736,"110":0,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0.00335,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0.00335,"39":0,"40":0,"41":0,"42":0,"43":0.00335,"44":0,"45":0,"46":0,"47":0,"48":0.00335,"49":0.01341,"50":0,"51":0,"52":0,"53":0.00335,"54":0,"55":0,"56":0.00335,"57":0,"58":0,"59":0,"60":0.00335,"61":0,"62":0,"63":0,"64":0,"65":0.00335,"66":0,"67":0,"68":0.00335,"69":0.00335,"70":0.00335,"71":0.00335,"72":0.06371,"73":0.00335,"74":0.00671,"75":0.00335,"76":0.00335,"77":0.00335,"78":0.00335,"79":0.02682,"80":0.00671,"81":0.00671,"83":0.01006,"84":0.01006,"85":0.01006,"86":0.01006,"87":0.01341,"88":0.01006,"89":0.00671,"90":0.00671,"91":0.02012,"92":0.02347,"93":0.00335,"94":0.01006,"95":0.00671,"96":0.01006,"97":0.01341,"98":0.00335,"99":0.00671,"100":0.01677,"101":0.01341,"102":0.00671,"103":0.02682,"104":0.01677,"105":0.02347,"106":0.03018,"107":0.0503,"108":3.37647,"109":3.53742,"110":0.00335,"111":0.00335,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0.00335,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0.00335,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0.00335,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.00335,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.03353,"94":0.08383,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0.00335,"79":0,"80":0,"81":0,"83":0,"84":0.00335,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00335,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0.00335,"105":0.00335,"106":0.00335,"107":0.01006,"108":0.4426,"109":0.46607},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.00335,"14":0.01341,"15":0.00671,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0.01006,"10.1":0,"11.1":0,"12.1":0.00335,"13.1":0.01341,"14.1":0.04694,"15.1":0.00671,"15.2-15.3":0.00671,"15.4":0.02347,"15.5":0.06035,"15.6":0.33865,"16.0":0.01677,"16.1":0.23806,"16.2":0.25148,"16.3":0.01677},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0.00565,"8.1-8.4":0,"9.0-9.2":0.00283,"9.3":0.05372,"10.0-10.2":0.00565,"10.3":0.04806,"11.0-11.2":0.01131,"11.3-11.4":0.01131,"12.0-12.1":0.01696,"12.2-12.5":0.52302,"13.0-13.1":0.01414,"13.2":0.07916,"13.3":0.0311,"13.4-13.7":0.10178,"14.0-14.4":0.4269,"14.5-14.8":0.95275,"15.0-15.1":0.26575,"15.2-15.3":0.29402,"15.4":0.48627,"15.5":0.86511,"15.6":3.00808,"16.0":4.82028,"16.1":7.93862,"16.2":5.39136,"16.3":0.47496},P:{"4":0.13368,"5.0-5.4":0.01028,"6.2-6.4":0,"7.2-7.4":0.08227,"8.2":0,"9.2":0.01028,"10.1":0,"11.1-11.2":0.05142,"12.0":0.01028,"13.0":0.04113,"14.0":0.05142,"15.0":0.03085,"16.0":0.09255,"17.0":0.08227,"18.0":0.16453,"19.0":2.18003},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":0.04677},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0.00724,"9":0.00362,"10":0.00362,"11":0.07605,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},S:{"2.5":0},R:{_:"0"},M:{"0":0.113},Q:{"13.1":0},O:{"0":0.17282},H:{"0":0.20137},L:{"0":59.25204}};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"B","2":"J E F G A BC"},B:{"1":"C K L H M N O","2":"P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"2":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d OC PC QC RC qB 9B SC rB"},G:{"2":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"2":"nC"},I:{"2":"tB I D oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"2":"A B C e qB 9B rB"},L:{"2":"D"},M:{"2":"D"},N:{"1":"B","2":"A"},O:{"2":"uC"},P:{"2":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"2":"9C"}},B:7,C:"Resource Hints: Lazyload"};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"race.js","sources":["../src/observable/race.ts"],"names":[],"mappings":";;;;;AAAA,iDAA4C"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","16":"C"},C:{"1":"AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB","2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z DC EC"},D:{"1":"HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB"},E:{"1":"A B K L H KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E F G GC zB HC IC JC","129":"C"},F:{"1":"5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d","2":"0 1 2 3 4 G B C H M N O v w x y z OC PC QC RC qB 9B SC rB"},G:{"1":"YC ZC aC bC cC dC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"F zB TC AC UC VC WC XC","129":"eC"},H:{"2":"nC"},I:{"1":"D","2":"tB I oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"1":"e","2":"A B C qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"2":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:6,C:"ES6 Template Literals (Template Strings)"};
|
||||
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
}
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Scheduler_1 = require("../Scheduler");
|
||||
var AsyncScheduler = (function (_super) {
|
||||
__extends(AsyncScheduler, _super);
|
||||
function AsyncScheduler(SchedulerAction, now) {
|
||||
if (now === void 0) { now = Scheduler_1.Scheduler.now; }
|
||||
var _this = _super.call(this, SchedulerAction, function () {
|
||||
if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
|
||||
return AsyncScheduler.delegate.now();
|
||||
}
|
||||
else {
|
||||
return now();
|
||||
}
|
||||
}) || this;
|
||||
_this.actions = [];
|
||||
_this.active = false;
|
||||
_this.scheduled = undefined;
|
||||
return _this;
|
||||
}
|
||||
AsyncScheduler.prototype.schedule = function (work, delay, state) {
|
||||
if (delay === void 0) { delay = 0; }
|
||||
if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
|
||||
return AsyncScheduler.delegate.schedule(work, delay, state);
|
||||
}
|
||||
else {
|
||||
return _super.prototype.schedule.call(this, work, delay, state);
|
||||
}
|
||||
};
|
||||
AsyncScheduler.prototype.flush = function (action) {
|
||||
var actions = this.actions;
|
||||
if (this.active) {
|
||||
actions.push(action);
|
||||
return;
|
||||
}
|
||||
var error;
|
||||
this.active = true;
|
||||
do {
|
||||
if (error = action.execute(action.state, action.delay)) {
|
||||
break;
|
||||
}
|
||||
} while (action = actions.shift());
|
||||
this.active = false;
|
||||
if (error) {
|
||||
while (action = actions.shift()) {
|
||||
action.unsubscribe();
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
return AsyncScheduler;
|
||||
}(Scheduler_1.Scheduler));
|
||||
exports.AsyncScheduler = AsyncScheduler;
|
||||
//# sourceMappingURL=AsyncScheduler.js.map
|
||||
@@ -0,0 +1,120 @@
|
||||
interface TinroRoute {
|
||||
url: string
|
||||
from: string
|
||||
path: string
|
||||
query: Record<string, string>
|
||||
hash: string
|
||||
}
|
||||
|
||||
interface TinroBreadcrumb {
|
||||
url: string
|
||||
name: string
|
||||
}
|
||||
|
||||
interface TinroRouteMeta {
|
||||
url: string
|
||||
from?: string
|
||||
match: string
|
||||
pattern: string
|
||||
breadcrumbs?: Array<TinroBreadcrumb>
|
||||
query: Record<string, string>
|
||||
params: Record<string, string>
|
||||
subscribe(handler: (meta: TinroRouteMeta) => void)
|
||||
}
|
||||
|
||||
interface TinroRouterModeSwitcher {
|
||||
/** Set HistoryAPI navigation method */
|
||||
history(): ()=>void
|
||||
/** Set hash navigation method */
|
||||
hash(): ()=>void
|
||||
/** Set memory navigation method */
|
||||
memory(): ()=>void
|
||||
}
|
||||
|
||||
interface TinroRouterLocationHash {
|
||||
/** Get current hash value*/
|
||||
get(): string
|
||||
/** Set current hash value*/
|
||||
set(value:string): void
|
||||
/** Clear current hash value*/
|
||||
clear(): void
|
||||
}
|
||||
|
||||
interface TinroRouterLocationQuery {
|
||||
/** Get the query object or a value from it by property name */
|
||||
get(name?:string): Record<string, string>|string
|
||||
/** Update or add a property in the query object */
|
||||
set(name:string,value:string|number): void
|
||||
/** Delete a property from the query object */
|
||||
delete(name:string): void
|
||||
/** Replace value of the query object */
|
||||
replace(value: Record<string, string>): void
|
||||
/** Clear the query object */
|
||||
clear(): void
|
||||
}
|
||||
|
||||
interface TinroRouterLocation {
|
||||
hash: TinroRouterLocationHash
|
||||
query: TinroRouterLocationQuery
|
||||
}
|
||||
|
||||
declare interface TinroRouter {
|
||||
/** Point browser to the URL */
|
||||
goto(url: string, replace?: boolean): void
|
||||
/** Get current route object on URL change */
|
||||
subscribe(handler: (currentRoute: TinroRoute) => void)
|
||||
/** Switch navigatin method */
|
||||
mode: TinroRouterModeSwitcher
|
||||
/** Location object methods */
|
||||
location: TinroRouterLocation
|
||||
|
||||
/** @deprecated Use meta().params instead */
|
||||
params(): Record<string, string>
|
||||
/** @deprecated Use router.mode.hash() instead*/
|
||||
useHashNavigation(use?: boolean): void
|
||||
/** @deprecated Import `meta` from `tinro` package directly */
|
||||
meta(): TinroRouteMeta
|
||||
}
|
||||
|
||||
export const active: any
|
||||
export function meta(): TinroRouteMeta
|
||||
export const router: TinroRouter
|
||||
export class Route {
|
||||
$$prop_def: {
|
||||
/**
|
||||
* Exact o relative path of the route
|
||||
* @default "/*"
|
||||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* Is route fallback
|
||||
* @default false
|
||||
*/
|
||||
fallback?: boolean;
|
||||
|
||||
/**
|
||||
* Redirect route to the specified path
|
||||
*/
|
||||
redirect?: string;
|
||||
|
||||
/**
|
||||
* Will be show only first matched with URL nested route
|
||||
* @default false
|
||||
*/
|
||||
firstmatch?: boolean;
|
||||
|
||||
/**
|
||||
* Name of the route to use in breadcrumbs
|
||||
* @default null
|
||||
*/
|
||||
breadcrumb?: string;
|
||||
};
|
||||
|
||||
$$slot_def: { default: {
|
||||
/** Current meta for the route */
|
||||
meta: TinroRouteMeta
|
||||
/** @deprecated Use meta.params instead */
|
||||
params: Record<string, string>
|
||||
} };
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","2":"C K L H M N O"},C:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB","2":"0 1 2 3 4 CC tB I u J E F G A B C K L H M N O v w x y z DC EC","194":"5 6 7 8 9 AB BB"},D:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB"},E:{"1":"A B C K L H KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E F G GC zB HC IC JC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d","2":"G B C H M N O v w x y z OC PC QC RC qB 9B SC rB"},G:{"1":"ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"F zB TC AC UC VC WC XC YC"},H:{"2":"nC"},I:{"1":"D","2":"tB I oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"1":"e","2":"A B C qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"2":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:4,C:"CSS will-change property"};
|
||||
@@ -0,0 +1 @@
|
||||
import 'rxjs-compat/add/operator/onErrorResumeNext';
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/scheduler/animationFrame';
|
||||
@@ -0,0 +1,10 @@
|
||||
Modernizr.addTest('fullscreen',function(){
|
||||
for(var i = 0; i < Modernizr._domPrefixes.length; i++) {
|
||||
if( document[Modernizr._domPrefixes[i].toLowerCase() + 'CancelFullScreen'])
|
||||
return true;
|
||||
}
|
||||
return !!document['cancelFullScreen'] || false;
|
||||
});
|
||||
|
||||
// http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/ControllingMediaWithJavaScript/ControllingMediaWithJavaScript.html#//apple_ref/doc/uid/TP40009523-CH3-SW20
|
||||
// https://developer.mozilla.org/en/API/Fullscreen
|
||||
@@ -0,0 +1,131 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { Operator } from '../Operator';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { MonoTypeOperatorFunction, TeardownLogic } from '../types';
|
||||
import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
|
||||
|
||||
/**
|
||||
* Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from previous items.
|
||||
*
|
||||
* If a keySelector function is provided, then it will project each value from the source observable into a new value that it will
|
||||
* check for equality with previously projected values. If a keySelector function is not provided, it will use each value from the
|
||||
* source observable directly with an equality check against previous values.
|
||||
*
|
||||
* In JavaScript runtimes that support `Set`, this operator will use a `Set` to improve performance of the distinct value checking.
|
||||
*
|
||||
* In other runtimes, this operator will use a minimal implementation of `Set` that relies on an `Array` and `indexOf` under the
|
||||
* hood, so performance will degrade as more values are checked for distinction. Even in newer browsers, a long-running `distinct`
|
||||
* use might result in memory leaks. To help alleviate this in some scenarios, an optional `flushes` parameter is also provided so
|
||||
* that the internal `Set` can be "flushed", basically clearing it of values.
|
||||
*
|
||||
* ## Examples
|
||||
* A simple example with numbers
|
||||
* ```ts
|
||||
* import { of } from 'rxjs';
|
||||
* import { distinct } from 'rxjs/operators';
|
||||
*
|
||||
* of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).pipe(
|
||||
* distinct(),
|
||||
* )
|
||||
* .subscribe(x => console.log(x)); // 1, 2, 3, 4
|
||||
* ```
|
||||
*
|
||||
* An example using a keySelector function
|
||||
* ```typescript
|
||||
* import { of } from 'rxjs';
|
||||
* import { distinct } from 'rxjs/operators';
|
||||
*
|
||||
* interface Person {
|
||||
* age: number,
|
||||
* name: string
|
||||
* }
|
||||
*
|
||||
* of<Person>(
|
||||
* { age: 4, name: 'Foo'},
|
||||
* { age: 7, name: 'Bar'},
|
||||
* { age: 5, name: 'Foo'},
|
||||
* ).pipe(
|
||||
* distinct((p: Person) => p.name),
|
||||
* )
|
||||
* .subscribe(x => console.log(x));
|
||||
*
|
||||
* // displays:
|
||||
* // { age: 4, name: 'Foo' }
|
||||
* // { age: 7, name: 'Bar' }
|
||||
* ```
|
||||
* @see {@link distinctUntilChanged}
|
||||
* @see {@link distinctUntilKeyChanged}
|
||||
*
|
||||
* @param {function} [keySelector] Optional function to select which value you want to check as distinct.
|
||||
* @param {Observable} [flushes] Optional Observable for flushing the internal HashSet of the operator.
|
||||
* @return {Observable} An Observable that emits items from the source Observable with distinct values.
|
||||
* @method distinct
|
||||
* @owner Observable
|
||||
*/
|
||||
export function distinct<T, K>(keySelector?: (value: T) => K,
|
||||
flushes?: Observable<any>): MonoTypeOperatorFunction<T> {
|
||||
return (source: Observable<T>) => source.lift(new DistinctOperator(keySelector, flushes));
|
||||
}
|
||||
|
||||
class DistinctOperator<T, K> implements Operator<T, T> {
|
||||
constructor(private keySelector?: (value: T) => K, private flushes?: Observable<any>) {
|
||||
}
|
||||
|
||||
call(subscriber: Subscriber<T>, source: any): TeardownLogic {
|
||||
return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @ignore
|
||||
* @extends {Ignored}
|
||||
*/
|
||||
export class DistinctSubscriber<T, K> extends SimpleOuterSubscriber<T, T> {
|
||||
private values = new Set<K>();
|
||||
|
||||
constructor(destination: Subscriber<T>, private keySelector?: (value: T) => K, flushes?: Observable<any>) {
|
||||
super(destination);
|
||||
|
||||
if (flushes) {
|
||||
this.add(innerSubscribe(flushes, new SimpleInnerSubscriber(this)));
|
||||
}
|
||||
}
|
||||
|
||||
notifyNext(): void {
|
||||
this.values.clear();
|
||||
}
|
||||
|
||||
notifyError(error: any): void {
|
||||
this._error(error);
|
||||
}
|
||||
|
||||
protected _next(value: T): void {
|
||||
if (this.keySelector) {
|
||||
this._useKeySelector(value);
|
||||
} else {
|
||||
this._finalizeNext(value, value);
|
||||
}
|
||||
}
|
||||
|
||||
private _useKeySelector(value: T): void {
|
||||
let key: K;
|
||||
const { destination } = this;
|
||||
try {
|
||||
key = this.keySelector!(value);
|
||||
} catch (err) {
|
||||
destination.error!(err);
|
||||
return;
|
||||
}
|
||||
this._finalizeNext(key, value);
|
||||
}
|
||||
|
||||
private _finalizeNext(key: K|T, value: T) {
|
||||
const { values } = this;
|
||||
if (!values.has(<K>key)) {
|
||||
values.add(<K>key);
|
||||
this.destination.next!(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user