new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/operators/catchError';
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"all": true,
|
||||
"check-coverage": false,
|
||||
"reporter": ["text-summary", "text", "html", "json"],
|
||||
"lines": 86,
|
||||
"statements": 85.93,
|
||||
"functions": 82.43,
|
||||
"branches": 76.06,
|
||||
"exclude": [
|
||||
"coverage",
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"last.js","sources":["../src/operators/last.ts"],"names":[],"mappings":";;;;;AAAA,gDAA2C"}
|
||||
@@ -0,0 +1,51 @@
|
||||
import Container, { ContainerProps } from './container.js'
|
||||
import { ProcessOptions } from './postcss.js'
|
||||
import Result from './result.js'
|
||||
|
||||
interface RootRaws {
|
||||
/**
|
||||
* The space symbols after the last child to the end of file.
|
||||
*/
|
||||
after?: string
|
||||
|
||||
/**
|
||||
* Is the last child has an (optional) semicolon.
|
||||
*/
|
||||
semicolon?: boolean
|
||||
}
|
||||
|
||||
export interface RootProps extends ContainerProps {
|
||||
raws?: RootRaws
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a CSS file and contains all its parsed nodes.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('a{color:black} b{z-index:2}')
|
||||
* root.type //=> 'root'
|
||||
* root.nodes.length //=> 2
|
||||
* ```
|
||||
*/
|
||||
export default class Root extends Container {
|
||||
type: 'root'
|
||||
parent: undefined
|
||||
raws: RootRaws
|
||||
|
||||
constructor(defaults?: RootProps)
|
||||
|
||||
/**
|
||||
* Returns a `Result` instance representing the root’s CSS.
|
||||
*
|
||||
* ```js
|
||||
* const root1 = postcss.parse(css1, { from: 'a.css' })
|
||||
* const root2 = postcss.parse(css2, { from: 'b.css' })
|
||||
* root1.append(root2)
|
||||
* const result = root1.toResult({ to: 'all.css', map: true })
|
||||
* ```
|
||||
*
|
||||
* @param opts Options.
|
||||
* @return Result with current root’s CSS.
|
||||
*/
|
||||
toResult(options?: ProcessOptions): Result
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"2":"C 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"},C:{"33":"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 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","164":"CC tB 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:{"33":"D"},N:{"2":"A B"},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:{"33":"9C"}},B:5,C:"CSS element() function"};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"B","2":"J E F BC","132":"G A"},B:{"1":"C 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"},C:{"1":"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 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 EC","2":"CC tB DC"},D:{"1":"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:{"1":"u J E F G A B C K L H HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I GC zB"},F:{"1":"0 1 2 3 4 5 6 7 8 9 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 SC rB","2":"G B OC PC QC RC qB 9B"},G:{"1":"F TC AC 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","2":"zB","260":"UC"},H:{"1":"nC"},I:{"1":"tB I D oC pC qC rC AC sC tC"},J:{"1":"E A"},K:{"1":"C e rB","2":"A B qB 9B"},L:{"1":"D"},M:{"1":"D"},N:{"1":"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:"rem (root em) units"};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"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","2":"C K L H"},C:{"1":"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 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB DC EC"},D:{"1":"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 HB IB JB","16":"KB LB MB","388":"NB OB PB QB RB SB TB UB VB"},E:{"1":"K L H 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E F G A GC zB HC IC JC KC 0B","516":"B C qB rB"},F:{"1":"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 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 OC PC QC RC qB 9B SC rB"},G:{"1":"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 ZC aC bC"},H:{"2":"nC"},I:{"1":"D","2":"oC pC qC","16":"tB I rC AC sC tC"},J:{"1":"A","2":"E"},K:{"1":"e rB","16":"A B C qB 9B"},L:{"1":"D"},M:{"1":"D"},N:{"2":"A B"},O:{"1":"uC"},P:{"1":"vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C","129":"I"},Q:{"1":"1B"},R:{"1":"8C"},S:{"2":"9C"}},B:6,C:"FLAC audio format"};
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/Subscription';
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var concat_1 = require("../observable/concat");
|
||||
var of_1 = require("../observable/of");
|
||||
function endWith() {
|
||||
var array = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
array[_i] = arguments[_i];
|
||||
}
|
||||
return function (source) { return concat_1.concat(source, of_1.of.apply(void 0, array)); };
|
||||
}
|
||||
exports.endWith = endWith;
|
||||
//# sourceMappingURL=endWith.js.map
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "json-buffer",
|
||||
"description": "JSON parse & stringify that supports binary via bops & base64",
|
||||
"version": "3.0.0",
|
||||
"homepage": "https://github.com/dominictarr/json-buffer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dominictarr/json-buffer.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tape": "^4.6.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "set -e; for t in test/*.js; do node $t; done"
|
||||
},
|
||||
"author": "Dominic Tarr <dominic.tarr@gmail.com> (http://dominictarr.com)",
|
||||
"license": "MIT",
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/17..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/22..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function default_1(from, to, events) {
|
||||
const fns = {};
|
||||
for (const event of events) {
|
||||
fns[event] = (...args) => {
|
||||
to.emit(event, ...args);
|
||||
};
|
||||
from.on(event, fns[event]);
|
||||
}
|
||||
return () => {
|
||||
for (const event of events) {
|
||||
from.off(event, fns[event]);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.default = default_1;
|
||||
@@ -0,0 +1,6 @@
|
||||
/** @deprecated do not use, this is no longer checked by RxJS internals */
|
||||
export declare const rxSubscriber: string | symbol;
|
||||
/**
|
||||
* @deprecated use rxSubscriber instead
|
||||
*/
|
||||
export declare const $$rxSubscriber: string | symbol;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subscribeOn.js","sources":["../../src/add/operator/subscribeOn.ts"],"names":[],"mappings":";;AAAA,gDAA8C"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"elementAt.js","sources":["../src/operators/elementAt.ts"],"names":[],"mappings":";;;;;AAAA,qDAAgD"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"from.js","sources":["../src/observable/from.ts"],"names":[],"mappings":";;;;;AAAA,iDAA4C"}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Subscriber } from '../Subscriber';
|
||||
export function find(predicate, thisArg) {
|
||||
if (typeof predicate !== 'function') {
|
||||
throw new TypeError('predicate is not a function');
|
||||
}
|
||||
return (source) => source.lift(new FindValueOperator(predicate, source, false, thisArg));
|
||||
}
|
||||
export class FindValueOperator {
|
||||
constructor(predicate, source, yieldIndex, thisArg) {
|
||||
this.predicate = predicate;
|
||||
this.source = source;
|
||||
this.yieldIndex = yieldIndex;
|
||||
this.thisArg = thisArg;
|
||||
}
|
||||
call(observer, source) {
|
||||
return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
|
||||
}
|
||||
}
|
||||
export class FindValueSubscriber extends Subscriber {
|
||||
constructor(destination, predicate, source, yieldIndex, thisArg) {
|
||||
super(destination);
|
||||
this.predicate = predicate;
|
||||
this.source = source;
|
||||
this.yieldIndex = yieldIndex;
|
||||
this.thisArg = thisArg;
|
||||
this.index = 0;
|
||||
}
|
||||
notifyComplete(value) {
|
||||
const destination = this.destination;
|
||||
destination.next(value);
|
||||
destination.complete();
|
||||
this.unsubscribe();
|
||||
}
|
||||
_next(value) {
|
||||
const { predicate, thisArg } = this;
|
||||
const index = this.index++;
|
||||
try {
|
||||
const result = predicate.call(thisArg || this, value, index, this.source);
|
||||
if (result) {
|
||||
this.notifyComplete(this.yieldIndex ? index : value);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.destination.error(err);
|
||||
}
|
||||
}
|
||||
_complete() {
|
||||
this.notifyComplete(this.yieldIndex ? -1 : undefined);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=find.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F BC","132":"A B","388":"G"},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","132":"C K L H M N O"},C:{"1":"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","16":"CC tB DC EC","132":"0 1 2 3 4 5 6 7 8 9 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","388":"I u"},D:{"1":"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","16":"I u J E F G A B C K L","132":"0 1 2 3 4 5 6 7 8 9 H M N O v w x y z AB BB CB DB EB"},E:{"1":"B C K L H 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","16":"I u J GC zB","132":"E F G A IC JC KC","388":"HC"},F:{"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","16":"G B OC PC QC RC qB 9B","132":"0 1 H M N O v w x y z","516":"C SC rB"},G:{"1":"bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","16":"zB TC AC UC VC","132":"F WC XC YC ZC aC"},H:{"516":"nC"},I:{"1":"D","16":"tB oC pC qC tC","132":"sC","388":"I rC AC"},J:{"16":"E","132":"A"},K:{"1":"e","16":"A B C qB 9B","516":"rB"},L:{"1":"D"},M:{"1":"D"},N:{"132":"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:{"132":"9C"}},B:5,C:":indeterminate CSS pseudo-class"};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"concat.js","sources":["../src/operator/concat.ts"],"names":[],"mappings":";;;;;AAAA,iDAA4C"}
|
||||
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var internal = require('./internal/index.js');
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, 'SvelteComponent', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.SvelteComponentDev;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'SvelteComponentTyped', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.SvelteComponentTyped;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'afterUpdate', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.afterUpdate;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'beforeUpdate', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.beforeUpdate;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createEventDispatcher', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.createEventDispatcher;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.getContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'hasContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.hasContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'onDestroy', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.onDestroy;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'onMount', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.onMount;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'setContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.setContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'tick', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return internal.tick;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"latest-version","version":"5.1.0","files":{"license":{"checkedAt":1678887829653,"integrity":"sha512-nIst73auX/5NY2Fmv5Y116vWnNrEv4GaIUX3lpZG05rpXJY2S8EX+fpUS5hRjClCM0VdT2Za9DDHXXB5jdSrEw==","mode":420,"size":1109},"package.json":{"checkedAt":1678887830280,"integrity":"sha512-7hHNA3x4ufd9uEMBoKGYdeYb4a1SmUbzlZw4JtxUlmogiz0B/ubAngVjVv9LYPLM/FN8cstajFP45QzZJL2sSg==","mode":420,"size":710},"index.js":{"checkedAt":1678887830280,"integrity":"sha512-nK5pxnzt9ZPWZh0sR/d7rgQvUC/fEfdJN+QKqgq7H5SgeWVat6tV0uAcC2LjtNE4jwEFBDUPrFqXbhnnFsuTEw==","mode":420,"size":334},"index.d.ts":{"checkedAt":1678887830280,"integrity":"sha512-xbOT/2LW+F3jsNOsg6PRjqYIdZD0kXV/kK90Gf5TaBmKsL75mf/pfMpXiAQTO6r8Kjc//nmpE9FBgMpxsvLGMw==","mode":420,"size":981},"readme.md":{"checkedAt":1678887830280,"integrity":"sha512-ntVT1yFQW9VzRoB3tNRPtttI27OmjKFnlOhi1VPrvBG27JSesWpZkF0t0Jeh6pBTivsBkI3VwkvtOxmXUpdv/w==","mode":420,"size":1158}}}
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var distinctUntilChanged_1 = require("./distinctUntilChanged");
|
||||
function distinctUntilKeyChanged(key, compare) {
|
||||
return distinctUntilChanged_1.distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
|
||||
}
|
||||
exports.distinctUntilKeyChanged = distinctUntilKeyChanged;
|
||||
//# sourceMappingURL=distinctUntilKeyChanged.js.map
|
||||
@@ -0,0 +1,13 @@
|
||||
Copyright (C) 2015-present SheetJS
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,145 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { ReplaySubject } from '../ReplaySubject';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
|
||||
export interface ShareReplayConfig {
|
||||
bufferSize?: number;
|
||||
windowTime?: number;
|
||||
refCount: boolean;
|
||||
scheduler?: SchedulerLike;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share source and replay specified number of emissions on subscription.
|
||||
*
|
||||
* This operator is a specialization of `replay` that connects to a source observable
|
||||
* and multicasts through a `ReplaySubject` constructed with the specified arguments.
|
||||
* A successfully completed source will stay cached in the `shareReplayed observable` forever,
|
||||
* but an errored source can be retried.
|
||||
*
|
||||
* ## Why use shareReplay?
|
||||
* You generally want to use `shareReplay` when you have side-effects or taxing computations
|
||||
* that you do not wish to be executed amongst multiple subscribers.
|
||||
* It may also be valuable in situations where you know you will have late subscribers to
|
||||
* a stream that need access to previously emitted values.
|
||||
* This ability to replay values on subscription is what differentiates {@link share} and `shareReplay`.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* ## Example
|
||||
* ```ts
|
||||
* import { interval } from 'rxjs';
|
||||
* import { shareReplay, take } from 'rxjs/operators';
|
||||
*
|
||||
* const obs$ = interval(1000);
|
||||
* const shared$ = obs$.pipe(
|
||||
* take(4),
|
||||
* shareReplay(3)
|
||||
* );
|
||||
* shared$.subscribe(x => console.log('source A: ', x));
|
||||
* shared$.subscribe(y => console.log('source B: ', y));
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @see {@link publish}
|
||||
* @see {@link share}
|
||||
* @see {@link publishReplay}
|
||||
*
|
||||
* @param {Number} [bufferSize=Number.POSITIVE_INFINITY] Maximum element count of the replay buffer.
|
||||
* @param {Number} [windowTime=Number.POSITIVE_INFINITY] Maximum time length of the replay buffer in milliseconds.
|
||||
* @param {Scheduler} [scheduler] Scheduler where connected observers within the selector function
|
||||
* will be invoked on.
|
||||
* @return {Observable} An observable sequence that contains the elements of a sequence produced
|
||||
* by multicasting the source sequence within a selector function.
|
||||
* @method shareReplay
|
||||
* @owner Observable
|
||||
*/
|
||||
export function shareReplay<T>(
|
||||
config: ShareReplayConfig
|
||||
): MonoTypeOperatorFunction<T>;
|
||||
export function shareReplay<T>(
|
||||
bufferSize?: number,
|
||||
windowTime?: number,
|
||||
scheduler?: SchedulerLike
|
||||
): MonoTypeOperatorFunction<T>;
|
||||
export function shareReplay<T>(
|
||||
configOrBufferSize?: ShareReplayConfig | number,
|
||||
windowTime?: number,
|
||||
scheduler?: SchedulerLike
|
||||
): MonoTypeOperatorFunction<T> {
|
||||
let config: ShareReplayConfig;
|
||||
if (configOrBufferSize && typeof configOrBufferSize === 'object') {
|
||||
config = configOrBufferSize as ShareReplayConfig;
|
||||
} else {
|
||||
config = {
|
||||
bufferSize: configOrBufferSize as number | undefined,
|
||||
windowTime,
|
||||
refCount: false,
|
||||
scheduler,
|
||||
};
|
||||
}
|
||||
return (source: Observable<T>) => source.lift(shareReplayOperator(config));
|
||||
}
|
||||
|
||||
function shareReplayOperator<T>({
|
||||
bufferSize = Number.POSITIVE_INFINITY,
|
||||
windowTime = Number.POSITIVE_INFINITY,
|
||||
refCount: useRefCount,
|
||||
scheduler,
|
||||
}: ShareReplayConfig) {
|
||||
let subject: ReplaySubject<T> | undefined;
|
||||
let refCount = 0;
|
||||
let subscription: Subscription | undefined;
|
||||
let hasError = false;
|
||||
let isComplete = false;
|
||||
|
||||
return function shareReplayOperation(
|
||||
this: Subscriber<T>,
|
||||
source: Observable<T>
|
||||
) {
|
||||
refCount++;
|
||||
let innerSub: Subscription;
|
||||
if (!subject || hasError) {
|
||||
hasError = false;
|
||||
subject = new ReplaySubject<T>(bufferSize, windowTime, scheduler);
|
||||
innerSub = subject.subscribe(this);
|
||||
subscription = source.subscribe({
|
||||
next(value) {
|
||||
subject.next(value);
|
||||
},
|
||||
error(err) {
|
||||
hasError = true;
|
||||
subject.error(err);
|
||||
},
|
||||
complete() {
|
||||
isComplete = true;
|
||||
subscription = undefined;
|
||||
subject.complete();
|
||||
},
|
||||
});
|
||||
|
||||
// Here we need to check to see if the source synchronously completed. Although
|
||||
// we're setting `subscription = undefined` in the completion handler, if the source
|
||||
// is synchronous, that will happen *before* subscription is set by the return of
|
||||
// the `subscribe` call.
|
||||
if (isComplete) {
|
||||
subscription = undefined;
|
||||
}
|
||||
} else {
|
||||
innerSub = subject.subscribe(this);
|
||||
}
|
||||
|
||||
this.add(() => {
|
||||
refCount--;
|
||||
innerSub.unsubscribe();
|
||||
innerSub = undefined;
|
||||
if (subscription && !isComplete && useRefCount && refCount === 0) {
|
||||
subscription.unsubscribe();
|
||||
subscription = undefined;
|
||||
subject = undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user