new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/** PURE_IMPORTS_START _ReplaySubject PURE_IMPORTS_END */
|
||||
import { ReplaySubject } from '../ReplaySubject';
|
||||
export function shareReplay(configOrBufferSize, windowTime, scheduler) {
|
||||
var config;
|
||||
if (configOrBufferSize && typeof configOrBufferSize === 'object') {
|
||||
config = configOrBufferSize;
|
||||
}
|
||||
else {
|
||||
config = {
|
||||
bufferSize: configOrBufferSize,
|
||||
windowTime: windowTime,
|
||||
refCount: false,
|
||||
scheduler: scheduler,
|
||||
};
|
||||
}
|
||||
return function (source) { return source.lift(shareReplayOperator(config)); };
|
||||
}
|
||||
function shareReplayOperator(_a) {
|
||||
var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
|
||||
var subject;
|
||||
var refCount = 0;
|
||||
var subscription;
|
||||
var hasError = false;
|
||||
var isComplete = false;
|
||||
return function shareReplayOperation(source) {
|
||||
refCount++;
|
||||
var innerSub;
|
||||
if (!subject || hasError) {
|
||||
hasError = false;
|
||||
subject = new ReplaySubject(bufferSize, windowTime, scheduler);
|
||||
innerSub = subject.subscribe(this);
|
||||
subscription = source.subscribe({
|
||||
next: function (value) {
|
||||
subject.next(value);
|
||||
},
|
||||
error: function (err) {
|
||||
hasError = true;
|
||||
subject.error(err);
|
||||
},
|
||||
complete: function () {
|
||||
isComplete = true;
|
||||
subscription = undefined;
|
||||
subject.complete();
|
||||
},
|
||||
});
|
||||
if (isComplete) {
|
||||
subscription = undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
innerSub = subject.subscribe(this);
|
||||
}
|
||||
this.add(function () {
|
||||
refCount--;
|
||||
innerSub.unsubscribe();
|
||||
innerSub = undefined;
|
||||
if (subscription && !isComplete && useRefCount && refCount === 0) {
|
||||
subscription.unsubscribe();
|
||||
subscription = undefined;
|
||||
subject = undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=shareReplay.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},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 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","16":"CC"},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":"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:{"1":"0 1 2 3 4 5 6 7 8 9 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","16":"G"},G:{"1":"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:{"1":"nC"},I:{"1":"tB I D oC pC qC rC AC sC tC"},J:{"1":"E A"},K:{"1":"A B C e 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:7,C:"document.evaluate & XPath"};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"8":"J E F BC","129":"G A B"},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 DC EC","2":"CC tB"},D:{"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 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","129":"0 1 I u J E F G A B C K L H M N O v w x y z"},E:{"1":"E F G A B C K L H IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","129":"I u J HC","388":"GC zB"},F:{"1":"0 1 2 3 4 5 6 7 8 9 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","2":"G"},G:{"1":"F 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","129":"zB TC AC UC VC"},H:{"1":"nC"},I:{"1":"D sC tC","129":"tB I oC pC qC rC AC"},J:{"1":"E A"},K:{"1":"A B C e qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"129":"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:2,C:"CSS3 Media Queries"};
|
||||
File diff suppressed because one or more lines are too long
@@ -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/observable/bindNodeCallback"));
|
||||
//# sourceMappingURL=bindNodeCallback.js.map
|
||||
@@ -0,0 +1,74 @@
|
||||
"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 Subscriber_1 = require("../Subscriber");
|
||||
function distinctUntilChanged(compare, keySelector) {
|
||||
return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
|
||||
}
|
||||
exports.distinctUntilChanged = distinctUntilChanged;
|
||||
var DistinctUntilChangedOperator = (function () {
|
||||
function DistinctUntilChangedOperator(compare, keySelector) {
|
||||
this.compare = compare;
|
||||
this.keySelector = keySelector;
|
||||
}
|
||||
DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
|
||||
return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
|
||||
};
|
||||
return DistinctUntilChangedOperator;
|
||||
}());
|
||||
var DistinctUntilChangedSubscriber = (function (_super) {
|
||||
__extends(DistinctUntilChangedSubscriber, _super);
|
||||
function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
|
||||
var _this = _super.call(this, destination) || this;
|
||||
_this.keySelector = keySelector;
|
||||
_this.hasKey = false;
|
||||
if (typeof compare === 'function') {
|
||||
_this.compare = compare;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
|
||||
return x === y;
|
||||
};
|
||||
DistinctUntilChangedSubscriber.prototype._next = function (value) {
|
||||
var key;
|
||||
try {
|
||||
var keySelector = this.keySelector;
|
||||
key = keySelector ? keySelector(value) : value;
|
||||
}
|
||||
catch (err) {
|
||||
return this.destination.error(err);
|
||||
}
|
||||
var result = false;
|
||||
if (this.hasKey) {
|
||||
try {
|
||||
var compare = this.compare;
|
||||
result = compare(this.key, key);
|
||||
}
|
||||
catch (err) {
|
||||
return this.destination.error(err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.hasKey = true;
|
||||
}
|
||||
if (!result) {
|
||||
this.key = key;
|
||||
this.destination.next(value);
|
||||
}
|
||||
};
|
||||
return DistinctUntilChangedSubscriber;
|
||||
}(Subscriber_1.Subscriber));
|
||||
//# sourceMappingURL=distinctUntilChanged.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "responselike",
|
||||
"version": "1.0.2",
|
||||
"description": "A response-like object for mocking a Node.js HTTP response stream",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"xo": {
|
||||
"extends": "xo-lukechilds"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
"response",
|
||||
"mock",
|
||||
"request",
|
||||
"responselike"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lukechilds/responselike.git"
|
||||
},
|
||||
"author": "lukechilds",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"ava": "^0.22.0",
|
||||
"coveralls": "^2.13.1",
|
||||
"eslint-config-xo-lukechilds": "^1.0.0",
|
||||
"get-stream": "^3.0.0",
|
||||
"nyc": "^11.1.0",
|
||||
"xo": "^0.19.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"lowercase-keys": "^1.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
||||
|
||||
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
|
||||
|
||||
@example
|
||||
```
|
||||
// data.json
|
||||
{
|
||||
'foo': 1,
|
||||
'bar': 2,
|
||||
'biz': 3
|
||||
}
|
||||
|
||||
// main.ts
|
||||
import {ValueOf} from 'type-fest';
|
||||
import data = require('./data.json');
|
||||
|
||||
export function getData(name: string): ValueOf<typeof data> {
|
||||
return data[name];
|
||||
}
|
||||
|
||||
export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
|
||||
return data[name];
|
||||
}
|
||||
|
||||
// file.ts
|
||||
import {getData, onlyBar} from './main';
|
||||
|
||||
getData('foo');
|
||||
//=> 1
|
||||
|
||||
onlyBar('foo');
|
||||
//=> TypeError ...
|
||||
|
||||
onlyBar('bar');
|
||||
//=> 2
|
||||
```
|
||||
*/
|
||||
export type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
||||
@@ -0,0 +1,91 @@
|
||||
import { Observable } from './Observable';
|
||||
import { Subscription } from './Subscription';
|
||||
/**
|
||||
* Note: This will add Symbol.observable globally for all TypeScript users,
|
||||
* however, we are no longer polyfilling Symbol.observable
|
||||
*/
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol;
|
||||
}
|
||||
}
|
||||
/** OPERATOR INTERFACES */
|
||||
export interface UnaryFunction<T, R> {
|
||||
(source: T): R;
|
||||
}
|
||||
export interface OperatorFunction<T, R> extends UnaryFunction<Observable<T>, Observable<R>> {
|
||||
}
|
||||
export declare type FactoryOrValue<T> = T | (() => T);
|
||||
export interface MonoTypeOperatorFunction<T> extends OperatorFunction<T, T> {
|
||||
}
|
||||
export interface Timestamp<T> {
|
||||
value: T;
|
||||
timestamp: number;
|
||||
}
|
||||
export interface TimeInterval<T> {
|
||||
value: T;
|
||||
interval: number;
|
||||
}
|
||||
/** SUBSCRIPTION INTERFACES */
|
||||
export interface Unsubscribable {
|
||||
unsubscribe(): void;
|
||||
}
|
||||
export declare type TeardownLogic = Unsubscribable | Function | void;
|
||||
export interface SubscriptionLike extends Unsubscribable {
|
||||
unsubscribe(): void;
|
||||
readonly closed: boolean;
|
||||
}
|
||||
export declare type SubscribableOrPromise<T> = Subscribable<T> | Subscribable<never> | PromiseLike<T> | InteropObservable<T>;
|
||||
/** OBSERVABLE INTERFACES */
|
||||
export interface Subscribable<T> {
|
||||
subscribe(observer?: PartialObserver<T>): Unsubscribable;
|
||||
/** @deprecated Use an observer instead of a complete callback */
|
||||
subscribe(next: null | undefined, error: null | undefined, complete: () => void): Unsubscribable;
|
||||
/** @deprecated Use an observer instead of an error callback */
|
||||
subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Unsubscribable;
|
||||
/** @deprecated Use an observer instead of a complete callback */
|
||||
subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Unsubscribable;
|
||||
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Unsubscribable;
|
||||
}
|
||||
export declare type ObservableInput<T> = SubscribableOrPromise<T> | ArrayLike<T> | Iterable<T>;
|
||||
/** @deprecated use {@link InteropObservable } */
|
||||
export declare type ObservableLike<T> = InteropObservable<T>;
|
||||
export declare type InteropObservable<T> = {
|
||||
[Symbol.observable]: () => Subscribable<T>;
|
||||
};
|
||||
/** OBSERVER INTERFACES */
|
||||
export interface NextObserver<T> {
|
||||
closed?: boolean;
|
||||
next: (value: T) => void;
|
||||
error?: (err: any) => void;
|
||||
complete?: () => void;
|
||||
}
|
||||
export interface ErrorObserver<T> {
|
||||
closed?: boolean;
|
||||
next?: (value: T) => void;
|
||||
error: (err: any) => void;
|
||||
complete?: () => void;
|
||||
}
|
||||
export interface CompletionObserver<T> {
|
||||
closed?: boolean;
|
||||
next?: (value: T) => void;
|
||||
error?: (err: any) => void;
|
||||
complete: () => void;
|
||||
}
|
||||
export declare type PartialObserver<T> = NextObserver<T> | ErrorObserver<T> | CompletionObserver<T>;
|
||||
export interface Observer<T> {
|
||||
closed?: boolean;
|
||||
next: (value: T) => void;
|
||||
error: (err: any) => void;
|
||||
complete: () => void;
|
||||
}
|
||||
/** SCHEDULER INTERFACES */
|
||||
export interface SchedulerLike {
|
||||
now(): number;
|
||||
schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay?: number, state?: T): Subscription;
|
||||
}
|
||||
export interface SchedulerAction<T> extends Subscription {
|
||||
schedule(state?: T, delay?: number): Subscription;
|
||||
}
|
||||
export declare type ObservedValueOf<O> = O extends ObservableInput<infer T> ? T : never;
|
||||
export declare type ObservedValuesFromArray<X> = X extends Array<ObservableInput<infer T>> ? T : never;
|
||||
@@ -0,0 +1,407 @@
|
||||
'use strict';
|
||||
const readline = require('readline');
|
||||
const chalk = require('chalk');
|
||||
const cliCursor = require('cli-cursor');
|
||||
const cliSpinners = require('cli-spinners');
|
||||
const logSymbols = require('log-symbols');
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const wcwidth = require('wcwidth');
|
||||
const isInteractive = require('is-interactive');
|
||||
const isUnicodeSupported = require('is-unicode-supported');
|
||||
const {BufferListStream} = require('bl');
|
||||
|
||||
const TEXT = Symbol('text');
|
||||
const PREFIX_TEXT = Symbol('prefixText');
|
||||
const ASCII_ETX_CODE = 0x03; // Ctrl+C emits this code
|
||||
|
||||
class StdinDiscarder {
|
||||
constructor() {
|
||||
this.requests = 0;
|
||||
|
||||
this.mutedStream = new BufferListStream();
|
||||
this.mutedStream.pipe(process.stdout);
|
||||
|
||||
const self = this; // eslint-disable-line unicorn/no-this-assignment
|
||||
this.ourEmit = function (event, data, ...args) {
|
||||
const {stdin} = process;
|
||||
if (self.requests > 0 || stdin.emit === self.ourEmit) {
|
||||
if (event === 'keypress') { // Fixes readline behavior
|
||||
return;
|
||||
}
|
||||
|
||||
if (event === 'data' && data.includes(ASCII_ETX_CODE)) {
|
||||
process.emit('SIGINT');
|
||||
}
|
||||
|
||||
Reflect.apply(self.oldEmit, this, [event, data, ...args]);
|
||||
} else {
|
||||
Reflect.apply(process.stdin.emit, this, [event, data, ...args]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
start() {
|
||||
this.requests++;
|
||||
|
||||
if (this.requests === 1) {
|
||||
this.realStart();
|
||||
}
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.requests <= 0) {
|
||||
throw new Error('`stop` called more times than `start`');
|
||||
}
|
||||
|
||||
this.requests--;
|
||||
|
||||
if (this.requests === 0) {
|
||||
this.realStop();
|
||||
}
|
||||
}
|
||||
|
||||
realStart() {
|
||||
// No known way to make it work reliably on Windows
|
||||
if (process.platform === 'win32') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: this.mutedStream
|
||||
});
|
||||
|
||||
this.rl.on('SIGINT', () => {
|
||||
if (process.listenerCount('SIGINT') === 0) {
|
||||
process.emit('SIGINT');
|
||||
} else {
|
||||
this.rl.close();
|
||||
process.kill(process.pid, 'SIGINT');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
realStop() {
|
||||
if (process.platform === 'win32') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.rl.close();
|
||||
this.rl = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let stdinDiscarder;
|
||||
|
||||
class Ora {
|
||||
constructor(options) {
|
||||
if (!stdinDiscarder) {
|
||||
stdinDiscarder = new StdinDiscarder();
|
||||
}
|
||||
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
text: options
|
||||
};
|
||||
}
|
||||
|
||||
this.options = {
|
||||
text: '',
|
||||
color: 'cyan',
|
||||
stream: process.stderr,
|
||||
discardStdin: true,
|
||||
...options
|
||||
};
|
||||
|
||||
this.spinner = this.options.spinner;
|
||||
|
||||
this.color = this.options.color;
|
||||
this.hideCursor = this.options.hideCursor !== false;
|
||||
this.interval = this.options.interval || this.spinner.interval || 100;
|
||||
this.stream = this.options.stream;
|
||||
this.id = undefined;
|
||||
this.isEnabled = typeof this.options.isEnabled === 'boolean' ? this.options.isEnabled : isInteractive({stream: this.stream});
|
||||
this.isSilent = typeof this.options.isSilent === 'boolean' ? this.options.isSilent : false;
|
||||
|
||||
// Set *after* `this.stream`
|
||||
this.text = this.options.text;
|
||||
this.prefixText = this.options.prefixText;
|
||||
this.linesToClear = 0;
|
||||
this.indent = this.options.indent;
|
||||
this.discardStdin = this.options.discardStdin;
|
||||
this.isDiscardingStdin = false;
|
||||
}
|
||||
|
||||
get indent() {
|
||||
return this._indent;
|
||||
}
|
||||
|
||||
set indent(indent = 0) {
|
||||
if (!(indent >= 0 && Number.isInteger(indent))) {
|
||||
throw new Error('The `indent` option must be an integer from 0 and up');
|
||||
}
|
||||
|
||||
this._indent = indent;
|
||||
}
|
||||
|
||||
_updateInterval(interval) {
|
||||
if (interval !== undefined) {
|
||||
this.interval = interval;
|
||||
}
|
||||
}
|
||||
|
||||
get spinner() {
|
||||
return this._spinner;
|
||||
}
|
||||
|
||||
set spinner(spinner) {
|
||||
this.frameIndex = 0;
|
||||
|
||||
if (typeof spinner === 'object') {
|
||||
if (spinner.frames === undefined) {
|
||||
throw new Error('The given spinner must have a `frames` property');
|
||||
}
|
||||
|
||||
this._spinner = spinner;
|
||||
} else if (!isUnicodeSupported()) {
|
||||
this._spinner = cliSpinners.line;
|
||||
} else if (spinner === undefined) {
|
||||
// Set default spinner
|
||||
this._spinner = cliSpinners.dots;
|
||||
} else if (cliSpinners[spinner]) {
|
||||
this._spinner = cliSpinners[spinner];
|
||||
} else {
|
||||
throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);
|
||||
}
|
||||
|
||||
this._updateInterval(this._spinner.interval);
|
||||
}
|
||||
|
||||
get text() {
|
||||
return this[TEXT];
|
||||
}
|
||||
|
||||
set text(value) {
|
||||
this[TEXT] = value;
|
||||
this.updateLineCount();
|
||||
}
|
||||
|
||||
get prefixText() {
|
||||
return this[PREFIX_TEXT];
|
||||
}
|
||||
|
||||
set prefixText(value) {
|
||||
this[PREFIX_TEXT] = value;
|
||||
this.updateLineCount();
|
||||
}
|
||||
|
||||
get isSpinning() {
|
||||
return this.id !== undefined;
|
||||
}
|
||||
|
||||
getFullPrefixText(prefixText = this[PREFIX_TEXT], postfix = ' ') {
|
||||
if (typeof prefixText === 'string') {
|
||||
return prefixText + postfix;
|
||||
}
|
||||
|
||||
if (typeof prefixText === 'function') {
|
||||
return prefixText() + postfix;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
updateLineCount() {
|
||||
const columns = this.stream.columns || 80;
|
||||
const fullPrefixText = this.getFullPrefixText(this.prefixText, '-');
|
||||
this.lineCount = 0;
|
||||
for (const line of stripAnsi(fullPrefixText + '--' + this[TEXT]).split('\n')) {
|
||||
this.lineCount += Math.max(1, Math.ceil(wcwidth(line) / columns));
|
||||
}
|
||||
}
|
||||
|
||||
get isEnabled() {
|
||||
return this._isEnabled && !this.isSilent;
|
||||
}
|
||||
|
||||
set isEnabled(value) {
|
||||
if (typeof value !== 'boolean') {
|
||||
throw new TypeError('The `isEnabled` option must be a boolean');
|
||||
}
|
||||
|
||||
this._isEnabled = value;
|
||||
}
|
||||
|
||||
get isSilent() {
|
||||
return this._isSilent;
|
||||
}
|
||||
|
||||
set isSilent(value) {
|
||||
if (typeof value !== 'boolean') {
|
||||
throw new TypeError('The `isSilent` option must be a boolean');
|
||||
}
|
||||
|
||||
this._isSilent = value;
|
||||
}
|
||||
|
||||
frame() {
|
||||
const {frames} = this.spinner;
|
||||
let frame = frames[this.frameIndex];
|
||||
|
||||
if (this.color) {
|
||||
frame = chalk[this.color](frame);
|
||||
}
|
||||
|
||||
this.frameIndex = ++this.frameIndex % frames.length;
|
||||
const fullPrefixText = (typeof this.prefixText === 'string' && this.prefixText !== '') ? this.prefixText + ' ' : '';
|
||||
const fullText = typeof this.text === 'string' ? ' ' + this.text : '';
|
||||
|
||||
return fullPrefixText + frame + fullText;
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (!this.isEnabled || !this.stream.isTTY) {
|
||||
return this;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.linesToClear; i++) {
|
||||
if (i > 0) {
|
||||
this.stream.moveCursor(0, -1);
|
||||
}
|
||||
|
||||
this.stream.clearLine();
|
||||
this.stream.cursorTo(this.indent);
|
||||
}
|
||||
|
||||
this.linesToClear = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.isSilent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.clear();
|
||||
this.stream.write(this.frame());
|
||||
this.linesToClear = this.lineCount;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
start(text) {
|
||||
if (text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
if (this.isSilent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!this.isEnabled) {
|
||||
if (this.text) {
|
||||
this.stream.write(`- ${this.text}\n`);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.isSpinning) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.hideCursor) {
|
||||
cliCursor.hide(this.stream);
|
||||
}
|
||||
|
||||
if (this.discardStdin && process.stdin.isTTY) {
|
||||
this.isDiscardingStdin = true;
|
||||
stdinDiscarder.start();
|
||||
}
|
||||
|
||||
this.render();
|
||||
this.id = setInterval(this.render.bind(this), this.interval);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (!this.isEnabled) {
|
||||
return this;
|
||||
}
|
||||
|
||||
clearInterval(this.id);
|
||||
this.id = undefined;
|
||||
this.frameIndex = 0;
|
||||
this.clear();
|
||||
if (this.hideCursor) {
|
||||
cliCursor.show(this.stream);
|
||||
}
|
||||
|
||||
if (this.discardStdin && process.stdin.isTTY && this.isDiscardingStdin) {
|
||||
stdinDiscarder.stop();
|
||||
this.isDiscardingStdin = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
succeed(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.success, text});
|
||||
}
|
||||
|
||||
fail(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.error, text});
|
||||
}
|
||||
|
||||
warn(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.warning, text});
|
||||
}
|
||||
|
||||
info(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.info, text});
|
||||
}
|
||||
|
||||
stopAndPersist(options = {}) {
|
||||
if (this.isSilent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const prefixText = options.prefixText || this.prefixText;
|
||||
const text = options.text || this.text;
|
||||
const fullText = (typeof text === 'string') ? ' ' + text : '';
|
||||
|
||||
this.stop();
|
||||
this.stream.write(`${this.getFullPrefixText(prefixText, ' ')}${options.symbol || ' '}${fullText}\n`);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
const oraFactory = function (options) {
|
||||
return new Ora(options);
|
||||
};
|
||||
|
||||
module.exports = oraFactory;
|
||||
|
||||
module.exports.promise = (action, options) => {
|
||||
// eslint-disable-next-line promise/prefer-await-to-then
|
||||
if (typeof action.then !== 'function') {
|
||||
throw new TypeError('Parameter `action` must be a Promise');
|
||||
}
|
||||
|
||||
const spinner = new Ora(options);
|
||||
spinner.start();
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await action;
|
||||
spinner.succeed();
|
||||
} catch {
|
||||
spinner.fail();
|
||||
}
|
||||
})();
|
||||
|
||||
return spinner;
|
||||
};
|
||||
@@ -0,0 +1,101 @@
|
||||
declare const dotProp: {
|
||||
/**
|
||||
@param object - Object to get the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
@param defaultValue - Default value.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
|
||||
//=> 'unicorn'
|
||||
|
||||
dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
|
||||
//=> undefined
|
||||
|
||||
dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
|
||||
//=> 'default value'
|
||||
|
||||
dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
|
||||
//=> 'unicorn'
|
||||
```
|
||||
*/
|
||||
get<T>(
|
||||
object: {[key: string]: any} | undefined,
|
||||
path: string
|
||||
): T | undefined;
|
||||
get<T>(
|
||||
object: {[key: string]: any} | undefined,
|
||||
path: string,
|
||||
defaultValue: T
|
||||
): T;
|
||||
|
||||
/**
|
||||
@param object - Object to set the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
@param value - Value to set at `path`.
|
||||
@returns The object.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
const object = {foo: {bar: 'a'}};
|
||||
dotProp.set(object, 'foo.bar', 'b');
|
||||
console.log(object);
|
||||
//=> {foo: {bar: 'b'}}
|
||||
|
||||
const foo = dotProp.set({}, 'foo.bar', 'c');
|
||||
console.log(foo);
|
||||
//=> {foo: {bar: 'c'}}
|
||||
|
||||
dotProp.set(object, 'foo.baz', 'x');
|
||||
console.log(object);
|
||||
//=> {foo: {bar: 'b', baz: 'x'}}
|
||||
```
|
||||
*/
|
||||
set<T extends {[key: string]: any}>(
|
||||
object: T,
|
||||
path: string,
|
||||
value: unknown
|
||||
): T;
|
||||
|
||||
/**
|
||||
@param object - Object to test the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
has(object: {[key: string]: any} | undefined, path: string): boolean;
|
||||
|
||||
/**
|
||||
@param object - Object to delete the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
@returns A boolean of whether the property existed before being deleted.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
const object = {foo: {bar: 'a'}};
|
||||
dotProp.delete(object, 'foo.bar');
|
||||
console.log(object);
|
||||
//=> {foo: {}}
|
||||
|
||||
object.foo.bar = {x: 'y', y: 'x'};
|
||||
dotProp.delete(object, 'foo.bar.x');
|
||||
console.log(object);
|
||||
//=> {foo: {bar: {y: 'x'}}}
|
||||
```
|
||||
*/
|
||||
delete(object: {[key: string]: any}, path: string): boolean;
|
||||
};
|
||||
|
||||
export = dotProp;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"publishReplay.js","sources":["../../../src/internal/operators/publishReplay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AASxC,MAAM,UAAU,aAAa,CAAO,UAAmB,EACnB,UAAmB,EACnB,mBAA4D,EAC5D,SAAyB;IAE3D,IAAI,mBAAmB,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;QACpE,SAAS,GAAG,mBAAmB,CAAC;KACjC;IAED,MAAM,QAAQ,GAAG,OAAO,mBAAmB,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7F,MAAM,OAAO,GAAG,IAAI,aAAa,CAAI,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IAExE,OAAO,CAAC,MAAqB,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,CAA6B,CAAC;AAC3G,CAAC"}
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/operator/takeUntil");
|
||||
//# sourceMappingURL=takeUntil.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,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0.14939,"73":0,"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.00506,"89":0.00506,"90":0.01266,"91":0,"92":0,"93":0,"94":0.00506,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.02532,"101":0,"102":0,"103":0.09622,"104":0,"105":0,"106":0.02026,"107":0.01266,"108":0.46082,"109":0.3722,"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,"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.00506,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0.00506,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0.15698,"80":0,"81":0.0076,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.0076,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0.03798,"104":0.09622,"105":0.02026,"106":0.00506,"107":0.01772,"108":1.58756,"109":0.47602,"110":0,"111":0,"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,"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,"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,"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.01266,"94":0.03798,"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.04558,"79":0,"80":0,"81":0,"83":0,"84":0.00506,"85":0.01772,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.02785,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0.00506,"106":0,"107":0.01772,"108":1.07357,"109":0.87607},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.1823,"14":0,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0.00506,"14.1":0.0076,"15.1":0.0076,"15.2-15.3":0,"15.4":0.0076,"15.5":0.05317,"15.6":0.39752,"16.0":0.02785,"16.1":0.02785,"16.2":0.06583,"16.3":0.00506},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,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.0202,"10.0-10.2":0,"10.3":0,"11.0-11.2":0,"11.3-11.4":0,"12.0-12.1":0,"12.2-12.5":0.14143,"13.0-13.1":0,"13.2":0,"13.3":0,"13.4-13.7":0,"14.0-14.4":0.0202,"14.5-14.8":0.36368,"15.0-15.1":0.91257,"15.2-15.3":0.12123,"15.4":0.0202,"15.5":0.10102,"15.6":23.96244,"16.0":1.11461,"16.1":2.1282,"16.2":3.12158,"16.3":0.48491},P:{"4":0,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0,"8.2":0,"9.2":0,"10.1":0.10113,"11.1-11.2":0,"12.0":0,"13.0":0,"14.0":4.6518,"15.0":0,"16.0":0,"17.0":0.02023,"18.0":0.10113,"19.0":15.715},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},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.03798,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},R:{_:"0"},M:{"0":0.3958},Q:{"13.1":0},O:{"0":0},H:{"0":0},L:{"0":34.53304},S:{"2.5":0}};
|
||||
@@ -0,0 +1,153 @@
|
||||
# p-cancelable
|
||||
|
||||
> Create a promise that can be canceled
|
||||
|
||||
Useful for animation, loading resources, long-running async computations, async iteration, etc.
|
||||
|
||||
*If you target [Node.js 15](https://medium.com/@nodejs/node-js-v15-0-0-is-here-deb00750f278) or later, this package is [less useful](https://github.com/sindresorhus/p-cancelable/issues/27) and you should probably use [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) instead.*
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install p-cancelable
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const PCancelable = require('p-cancelable');
|
||||
|
||||
const cancelablePromise = new PCancelable((resolve, reject, onCancel) => {
|
||||
const worker = new SomeLongRunningOperation();
|
||||
|
||||
onCancel(() => {
|
||||
worker.close();
|
||||
});
|
||||
|
||||
worker.on('finish', resolve);
|
||||
worker.on('error', reject);
|
||||
});
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Operation finished successfully:', await cancelablePromise);
|
||||
} catch (error) {
|
||||
if (cancelablePromise.isCanceled) {
|
||||
// Handle the cancelation here
|
||||
console.log('Operation was canceled');
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
})();
|
||||
|
||||
// Cancel the operation after 10 seconds
|
||||
setTimeout(() => {
|
||||
cancelablePromise.cancel('Unicorn has changed its color');
|
||||
}, 10000);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### new PCancelable(executor)
|
||||
|
||||
Same as the [`Promise` constructor](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), but with an appended `onCancel` parameter in `executor`.<br>
|
||||
Cancelling will reject the promise with `PCancelable.CancelError`. To avoid that, set `onCancel.shouldReject` to `false`.
|
||||
|
||||
```js
|
||||
const PCancelable = require('p-cancelable');
|
||||
|
||||
const cancelablePromise = new PCancelable((resolve, reject, onCancel) => {
|
||||
const job = new Job();
|
||||
|
||||
onCancel.shouldReject = false;
|
||||
onCancel(() => {
|
||||
job.stop();
|
||||
});
|
||||
|
||||
job.on('finish', resolve);
|
||||
});
|
||||
|
||||
cancelablePromise.cancel(); // Doesn't throw an error
|
||||
```
|
||||
|
||||
`PCancelable` is a subclass of `Promise`.
|
||||
|
||||
#### onCanceled(fn)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Accepts a function that is called when the promise is canceled.
|
||||
|
||||
You're not required to call this function. You can call this function multiple times to add multiple cancel handlers.
|
||||
|
||||
### PCancelable#cancel(reason?)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Cancel the promise and optionally provide a reason.
|
||||
|
||||
The cancellation is synchronous. Calling it after the promise has settled or multiple times does nothing.
|
||||
|
||||
### PCancelable#isCanceled
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the promise is canceled.
|
||||
|
||||
### PCancelable.CancelError
|
||||
|
||||
Type: `Error`
|
||||
|
||||
Rejection reason when `.cancel()` is called.
|
||||
|
||||
It includes a `.isCanceled` property for convenience.
|
||||
|
||||
### PCancelable.fn(fn)
|
||||
|
||||
Convenience method to make your promise-returning or async function cancelable.
|
||||
|
||||
The function you specify will have `onCancel` appended to its parameters.
|
||||
|
||||
```js
|
||||
const PCancelable = require('p-cancelable');
|
||||
|
||||
const fn = PCancelable.fn((input, onCancel) => {
|
||||
const job = new Job();
|
||||
|
||||
onCancel(() => {
|
||||
job.cleanup();
|
||||
});
|
||||
|
||||
return job.start(); //=> Promise
|
||||
});
|
||||
|
||||
const cancelablePromise = fn('input'); //=> PCancelable
|
||||
|
||||
// …
|
||||
|
||||
cancelablePromise.cancel();
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### Cancelable vs. Cancellable
|
||||
|
||||
[In American English, the verb cancel is usually inflected canceled and canceling—with one l.](http://grammarist.com/spelling/cancel/)<br>Both a [browser API](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable) and the [Cancelable Promises proposal](https://github.com/tc39/proposal-cancelable-promises) use this spelling.
|
||||
|
||||
### What about the official [Cancelable Promises proposal](https://github.com/tc39/proposal-cancelable-promises)?
|
||||
|
||||
~~It's still an early draft and I don't really like its current direction. It complicates everything and will require deep changes in the ecosystem to adapt to it. And the way you have to use cancel tokens is verbose and convoluted. I much prefer the more pragmatic and less invasive approach in this module.~~ The proposal was withdrawn.
|
||||
|
||||
## p-cancelable for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of p-cancelable and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-p-cancelable?utm_source=npm-p-cancelable&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Related
|
||||
|
||||
- [p-progress](https://github.com/sindresorhus/p-progress) - Create a promise that reports progress
|
||||
- [p-lazy](https://github.com/sindresorhus/p-lazy) - Create a lazy promise that defers execution until `.then()` or `.catch()` is called
|
||||
- [More…](https://github.com/sindresorhus/promise-fun)
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Subject } from './Subject';
|
||||
import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
|
||||
export class BehaviorSubject extends Subject {
|
||||
constructor(_value) {
|
||||
super();
|
||||
this._value = _value;
|
||||
}
|
||||
get value() {
|
||||
return this.getValue();
|
||||
}
|
||||
_subscribe(subscriber) {
|
||||
const subscription = super._subscribe(subscriber);
|
||||
if (subscription && !subscription.closed) {
|
||||
subscriber.next(this._value);
|
||||
}
|
||||
return subscription;
|
||||
}
|
||||
getValue() {
|
||||
if (this.hasError) {
|
||||
throw this.thrownError;
|
||||
}
|
||||
else if (this.closed) {
|
||||
throw new ObjectUnsubscribedError();
|
||||
}
|
||||
else {
|
||||
return this._value;
|
||||
}
|
||||
}
|
||||
next(value) {
|
||||
super.next(this._value = value);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=BehaviorSubject.js.map
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/operator/bufferCount");
|
||||
//# sourceMappingURL=bufferCount.js.map
|
||||
@@ -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":"0 1 2 3 4 5 6 7 8 9 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","2":"CC tB DC EC","33":"I"},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":"I 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":"GC zB"},F:{"1":"0 1 2 3 4 5 6 7 8 9 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","2":"G B C OC PC QC RC qB 9B SC","132":"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:{"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":"vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C","2":"I"},Q:{"1":"1B"},R:{"1":"8C"},S:{"2":"9C"}},B:2,C:"CSS resize property"};
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "clone-response",
|
||||
"version": "1.0.3",
|
||||
"description": "Clone a Node.js HTTP response stream",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"xo": {
|
||||
"extends": "xo-lukechilds"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/clone-response.git"
|
||||
},
|
||||
"keywords": [
|
||||
"clone",
|
||||
"duplicate",
|
||||
"copy",
|
||||
"response",
|
||||
"HTTP",
|
||||
"stream"
|
||||
],
|
||||
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mimic-response": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.22.0",
|
||||
"coveralls": "^2.13.1",
|
||||
"create-test-server": "^2.0.1",
|
||||
"eslint-config-xo-lukechilds": "^1.0.0",
|
||||
"get-stream": "^3.0.0",
|
||||
"nyc": "^11.0.2",
|
||||
"pify": "^3.0.0",
|
||||
"xo": "^0.19.0"
|
||||
}
|
||||
}
|
||||
@@ -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/util/ObjectUnsubscribedError"));
|
||||
//# sourceMappingURL=ObjectUnsubscribedError.js.map
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { OperatorFunction } from '../types';
|
||||
/**
|
||||
* Emits only the index of the first value emitted by the source Observable that
|
||||
* meets some condition.
|
||||
*
|
||||
* <span class="informal">It's like {@link find}, but emits the index of the
|
||||
* found value, not the value itself.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `findIndex` searches for the first item in the source Observable that matches
|
||||
* the specified condition embodied by the `predicate`, and returns the
|
||||
* (zero-based) index of the first occurrence in the source. Unlike
|
||||
* {@link first}, the `predicate` is required in `findIndex`, and does not emit
|
||||
* an error if a valid value is not found.
|
||||
*
|
||||
* ## Example
|
||||
* Emit the index of first click that happens on a DIV element
|
||||
* ```ts
|
||||
* import { fromEvent } from 'rxjs';
|
||||
* import { findIndex } from 'rxjs/operators';
|
||||
*
|
||||
* const clicks = fromEvent(document, 'click');
|
||||
* const result = clicks.pipe(findIndex(ev => ev.target.tagName === 'DIV'));
|
||||
* result.subscribe(x => console.log(x));
|
||||
* ```
|
||||
*
|
||||
* @see {@link filter}
|
||||
* @see {@link find}
|
||||
* @see {@link first}
|
||||
* @see {@link take}
|
||||
*
|
||||
* @param {function(value: T, index: number, source: Observable<T>): boolean} predicate
|
||||
* A function called with each item to test for condition matching.
|
||||
* @param {any} [thisArg] An optional argument to determine the value of `this`
|
||||
* in the `predicate` function.
|
||||
* @return {Observable} An Observable of the index of the first item that
|
||||
* matches the condition.
|
||||
* @method find
|
||||
* @owner Observable
|
||||
*/
|
||||
export declare function findIndex<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): OperatorFunction<T, number>;
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/operator/exhaust");
|
||||
//# sourceMappingURL=exhaust.js.map
|
||||
@@ -0,0 +1,28 @@
|
||||
export interface TimeoutError extends Error {
|
||||
}
|
||||
|
||||
export interface TimeoutErrorCtor {
|
||||
new(): TimeoutError;
|
||||
}
|
||||
|
||||
const TimeoutErrorImpl = (() => {
|
||||
function TimeoutErrorImpl(this: any) {
|
||||
Error.call(this);
|
||||
this.message = 'Timeout has occurred';
|
||||
this.name = 'TimeoutError';
|
||||
return this;
|
||||
}
|
||||
|
||||
TimeoutErrorImpl.prototype = Object.create(Error.prototype);
|
||||
|
||||
return TimeoutErrorImpl;
|
||||
})();
|
||||
|
||||
/**
|
||||
* An error thrown when duetime elapses.
|
||||
*
|
||||
* @see {@link operators/timeout}
|
||||
*
|
||||
* @class TimeoutError
|
||||
*/
|
||||
export const TimeoutError: TimeoutErrorCtor = TimeoutErrorImpl as any;
|
||||
Reference in New Issue
Block a user