new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,302 @@
|
||||
import { isFunction } from './util/isFunction';
|
||||
import { empty as emptyObserver } from './Observer';
|
||||
import { Observer, PartialObserver, TeardownLogic } from './types';
|
||||
import { Subscription } from './Subscription';
|
||||
import { rxSubscriber as rxSubscriberSymbol } from '../internal/symbol/rxSubscriber';
|
||||
import { config } from './config';
|
||||
import { hostReportError } from './util/hostReportError';
|
||||
|
||||
/**
|
||||
* Implements the {@link Observer} interface and extends the
|
||||
* {@link Subscription} class. While the {@link Observer} is the public API for
|
||||
* consuming the values of an {@link Observable}, all Observers get converted to
|
||||
* a Subscriber, in order to provide Subscription-like capabilities such as
|
||||
* `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
|
||||
* implementing operators, but it is rarely used as a public API.
|
||||
*
|
||||
* @class Subscriber<T>
|
||||
*/
|
||||
export class Subscriber<T> extends Subscription implements Observer<T> {
|
||||
|
||||
[rxSubscriberSymbol]() { return this; }
|
||||
|
||||
/**
|
||||
* A static factory for a Subscriber, given a (potentially partial) definition
|
||||
* of an Observer.
|
||||
* @param {function(x: ?T): void} [next] The `next` callback of an Observer.
|
||||
* @param {function(e: ?any): void} [error] The `error` callback of an
|
||||
* Observer.
|
||||
* @param {function(): void} [complete] The `complete` callback of an
|
||||
* Observer.
|
||||
* @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
|
||||
* Observer represented by the given arguments.
|
||||
* @nocollapse
|
||||
*/
|
||||
static create<T>(next?: (x?: T) => void,
|
||||
error?: (e?: any) => void,
|
||||
complete?: () => void): Subscriber<T> {
|
||||
const subscriber = new Subscriber(next, error, complete);
|
||||
subscriber.syncErrorThrowable = false;
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
/** @internal */ syncErrorValue: any = null;
|
||||
/** @internal */ syncErrorThrown: boolean = false;
|
||||
/** @internal */ syncErrorThrowable: boolean = false;
|
||||
|
||||
protected isStopped: boolean = false;
|
||||
protected destination: PartialObserver<any> | Subscriber<any>; // this `any` is the escape hatch to erase extra type param (e.g. R)
|
||||
|
||||
/**
|
||||
* @param {Observer|function(value: T): void} [destinationOrNext] A partially
|
||||
* defined Observer or a `next` callback function.
|
||||
* @param {function(e: ?any): void} [error] The `error` callback of an
|
||||
* Observer.
|
||||
* @param {function(): void} [complete] The `complete` callback of an
|
||||
* Observer.
|
||||
*/
|
||||
constructor(destinationOrNext?: PartialObserver<any> | ((value: T) => void),
|
||||
error?: (e?: any) => void,
|
||||
complete?: () => void) {
|
||||
super();
|
||||
|
||||
switch (arguments.length) {
|
||||
case 0:
|
||||
this.destination = emptyObserver;
|
||||
break;
|
||||
case 1:
|
||||
if (!destinationOrNext) {
|
||||
this.destination = emptyObserver;
|
||||
break;
|
||||
}
|
||||
if (typeof destinationOrNext === 'object') {
|
||||
if (destinationOrNext instanceof Subscriber) {
|
||||
this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
|
||||
this.destination = destinationOrNext;
|
||||
destinationOrNext.add(this);
|
||||
} else {
|
||||
this.syncErrorThrowable = true;
|
||||
this.destination = new SafeSubscriber<T>(this, <PartialObserver<any>> destinationOrNext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
this.syncErrorThrowable = true;
|
||||
this.destination = new SafeSubscriber<T>(this, <((value: T) => void)> destinationOrNext, error, complete);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Observer} callback to receive notifications of type `next` from
|
||||
* the Observable, with a value. The Observable may call this method 0 or more
|
||||
* times.
|
||||
* @param {T} [value] The `next` value.
|
||||
* @return {void}
|
||||
*/
|
||||
next(value?: T): void {
|
||||
if (!this.isStopped) {
|
||||
this._next(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Observer} callback to receive notifications of type `error` from
|
||||
* the Observable, with an attached `Error`. Notifies the Observer that
|
||||
* the Observable has experienced an error condition.
|
||||
* @param {any} [err] The `error` exception.
|
||||
* @return {void}
|
||||
*/
|
||||
error(err?: any): void {
|
||||
if (!this.isStopped) {
|
||||
this.isStopped = true;
|
||||
this._error(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Observer} callback to receive a valueless notification of type
|
||||
* `complete` from the Observable. Notifies the Observer that the Observable
|
||||
* has finished sending push-based notifications.
|
||||
* @return {void}
|
||||
*/
|
||||
complete(): void {
|
||||
if (!this.isStopped) {
|
||||
this.isStopped = true;
|
||||
this._complete();
|
||||
}
|
||||
}
|
||||
|
||||
unsubscribe(): void {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.isStopped = true;
|
||||
super.unsubscribe();
|
||||
}
|
||||
|
||||
protected _next(value: T): void {
|
||||
this.destination.next(value);
|
||||
}
|
||||
|
||||
protected _error(err: any): void {
|
||||
this.destination.error(err);
|
||||
this.unsubscribe();
|
||||
}
|
||||
|
||||
protected _complete(): void {
|
||||
this.destination.complete();
|
||||
this.unsubscribe();
|
||||
}
|
||||
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_unsubscribeAndRecycle(): Subscriber<T> {
|
||||
const { _parentOrParents } = this;
|
||||
this._parentOrParents = null;
|
||||
this.unsubscribe();
|
||||
this.closed = false;
|
||||
this.isStopped = false;
|
||||
this._parentOrParents = _parentOrParents;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @ignore
|
||||
* @extends {Ignored}
|
||||
*/
|
||||
export class SafeSubscriber<T> extends Subscriber<T> {
|
||||
|
||||
private _context: any;
|
||||
|
||||
constructor(private _parentSubscriber: Subscriber<T>,
|
||||
observerOrNext?: PartialObserver<T> | ((value: T) => void),
|
||||
error?: (e?: any) => void,
|
||||
complete?: () => void) {
|
||||
super();
|
||||
|
||||
let next: ((value: T) => void);
|
||||
let context: any = this;
|
||||
|
||||
if (isFunction(observerOrNext)) {
|
||||
next = (<((value: T) => void)> observerOrNext);
|
||||
} else if (observerOrNext) {
|
||||
next = (<PartialObserver<T>> observerOrNext).next;
|
||||
error = (<PartialObserver<T>> observerOrNext).error;
|
||||
complete = (<PartialObserver<T>> observerOrNext).complete;
|
||||
if (observerOrNext !== emptyObserver) {
|
||||
context = Object.create(observerOrNext);
|
||||
if (isFunction(context.unsubscribe)) {
|
||||
this.add(<() => void> context.unsubscribe.bind(context));
|
||||
}
|
||||
context.unsubscribe = this.unsubscribe.bind(this);
|
||||
}
|
||||
}
|
||||
|
||||
this._context = context;
|
||||
this._next = next;
|
||||
this._error = error;
|
||||
this._complete = complete;
|
||||
}
|
||||
|
||||
next(value?: T): void {
|
||||
if (!this.isStopped && this._next) {
|
||||
const { _parentSubscriber } = this;
|
||||
if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
||||
this.__tryOrUnsub(this._next, value);
|
||||
} else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
|
||||
this.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error(err?: any): void {
|
||||
if (!this.isStopped) {
|
||||
const { _parentSubscriber } = this;
|
||||
const { useDeprecatedSynchronousErrorHandling } = config;
|
||||
if (this._error) {
|
||||
if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
||||
this.__tryOrUnsub(this._error, err);
|
||||
this.unsubscribe();
|
||||
} else {
|
||||
this.__tryOrSetError(_parentSubscriber, this._error, err);
|
||||
this.unsubscribe();
|
||||
}
|
||||
} else if (!_parentSubscriber.syncErrorThrowable) {
|
||||
this.unsubscribe();
|
||||
if (useDeprecatedSynchronousErrorHandling) {
|
||||
throw err;
|
||||
}
|
||||
hostReportError(err);
|
||||
} else {
|
||||
if (useDeprecatedSynchronousErrorHandling) {
|
||||
_parentSubscriber.syncErrorValue = err;
|
||||
_parentSubscriber.syncErrorThrown = true;
|
||||
} else {
|
||||
hostReportError(err);
|
||||
}
|
||||
this.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
complete(): void {
|
||||
if (!this.isStopped) {
|
||||
const { _parentSubscriber } = this;
|
||||
if (this._complete) {
|
||||
const wrappedComplete = () => this._complete.call(this._context);
|
||||
|
||||
if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
||||
this.__tryOrUnsub(wrappedComplete);
|
||||
this.unsubscribe();
|
||||
} else {
|
||||
this.__tryOrSetError(_parentSubscriber, wrappedComplete);
|
||||
this.unsubscribe();
|
||||
}
|
||||
} else {
|
||||
this.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private __tryOrUnsub(fn: Function, value?: any): void {
|
||||
try {
|
||||
fn.call(this._context, value);
|
||||
} catch (err) {
|
||||
this.unsubscribe();
|
||||
if (config.useDeprecatedSynchronousErrorHandling) {
|
||||
throw err;
|
||||
} else {
|
||||
hostReportError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private __tryOrSetError(parent: Subscriber<T>, fn: Function, value?: any): boolean {
|
||||
if (!config.useDeprecatedSynchronousErrorHandling) {
|
||||
throw new Error('bad call');
|
||||
}
|
||||
try {
|
||||
fn.call(this._context, value);
|
||||
} catch (err) {
|
||||
if (config.useDeprecatedSynchronousErrorHandling) {
|
||||
parent.syncErrorValue = err;
|
||||
parent.syncErrorThrown = true;
|
||||
return true;
|
||||
} else {
|
||||
hostReportError(err);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @internal This is an internal implementation detail, do not use. */
|
||||
_unsubscribe(): void {
|
||||
const { _parentSubscriber } = this;
|
||||
this._context = null;
|
||||
this._parentSubscriber = null;
|
||||
_parentSubscriber.unsubscribe();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class BorderImage extends Declaration {
|
||||
/**
|
||||
* Remove fill parameter for prefixed declarations
|
||||
*/
|
||||
set (decl, prefix) {
|
||||
decl.value = decl.value.replace(/\s+fill(\s)/, '$1')
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
BorderImage.names = ['border-image']
|
||||
|
||||
module.exports = BorderImage
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"of.js","sources":["../src/observable/of.ts"],"names":[],"mappings":";;;;;AAAA,+CAA0C"}
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var not_1 = require("../util/not");
|
||||
var subscribeTo_1 = require("../util/subscribeTo");
|
||||
var filter_1 = require("../operators/filter");
|
||||
var Observable_1 = require("../Observable");
|
||||
function partition(source, predicate, thisArg) {
|
||||
return [
|
||||
filter_1.filter(predicate, thisArg)(new Observable_1.Observable(subscribeTo_1.subscribeTo(source))),
|
||||
filter_1.filter(not_1.not(predicate, thisArg))(new Observable_1.Observable(subscribeTo_1.subscribeTo(source)))
|
||||
];
|
||||
}
|
||||
exports.partition = partition;
|
||||
//# sourceMappingURL=partition.js.map
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "p-cancelable",
|
||||
"version": "1.1.0",
|
||||
"description": "Create a promise that can be canceled",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/p-cancelable",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd-check"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"promise",
|
||||
"cancelable",
|
||||
"cancel",
|
||||
"canceled",
|
||||
"canceling",
|
||||
"cancellable",
|
||||
"cancellation",
|
||||
"abort",
|
||||
"abortable",
|
||||
"aborting",
|
||||
"cleanup",
|
||||
"task",
|
||||
"token",
|
||||
"async",
|
||||
"function",
|
||||
"await",
|
||||
"promises",
|
||||
"bluebird"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.3.1",
|
||||
"delay": "^4.1.0",
|
||||
"promise.prototype.finally": "^3.1.0",
|
||||
"tsd-check": "^0.3.0",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../../src/ajax/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAe,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subscribeToIterable.js","sources":["../../src/internal/util/subscribeToIterable.ts"],"names":[],"mappings":";;AACA,+CAAiE;AAEpD,QAAA,mBAAmB,GAAG,UAAI,QAAqB,IAAK,OAAA,UAAC,UAAyB;IACzF,IAAM,QAAQ,GAAI,QAAgB,CAAC,mBAAe,CAAC,EAAE,CAAC;IAEtD,GAAG;QACD,IAAI,IAAI,SAAmB,CAAC;QAC5B,IAAI;YACF,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;SACxB;QAAC,OAAO,GAAG,EAAE;YACZ,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtB,OAAO,UAAU,CAAC;SACnB;QACD,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,UAAU,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM;SACP;QACD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,UAAU,CAAC,MAAM,EAAE;YACrB,MAAM;SACP;KACF,QAAQ,IAAI,EAAE;IAGf,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE;QACzC,UAAU,CAAC,GAAG,CAAC;YACb,IAAI,QAAQ,CAAC,MAAM,EAAE;gBACnB,QAAQ,CAAC,MAAM,EAAE,CAAC;aACnB;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,EA/BgE,CA+BhE,CAAC"}
|
||||
@@ -0,0 +1,5 @@
|
||||
export declare const getLocaleFromHostname: (hostname: RegExp) => string;
|
||||
export declare const getLocaleFromPathname: (pathname: RegExp) => string;
|
||||
export declare const getLocaleFromNavigator: () => string;
|
||||
export declare const getLocaleFromQueryString: (search: string) => string;
|
||||
export declare const getLocaleFromHash: (hash: string) => string;
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
Convert an object with `readonly` keys into a mutable object. Inverse of `Readonly<T>`.
|
||||
|
||||
This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), and [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509).
|
||||
|
||||
@example
|
||||
```
|
||||
import {Mutable} from 'type-fest';
|
||||
|
||||
type Foo = {
|
||||
readonly a: number;
|
||||
readonly b: string;
|
||||
};
|
||||
|
||||
const mutableFoo: Mutable<Foo> = {a: 1, b: '2'};
|
||||
mutableFoo.a = 3;
|
||||
```
|
||||
*/
|
||||
export type Mutable<ObjectType> = {
|
||||
// For each `Key` in the keys of `ObjectType`, make a mapped type by removing the `readonly` modifier from the key.
|
||||
-readonly [KeyType in keyof ObjectType]: ObjectType[KeyType];
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class MaskComposite extends Declaration {
|
||||
/**
|
||||
* Prefix mask-composite for webkit
|
||||
*/
|
||||
insert (decl, prefix, prefixes) {
|
||||
let isCompositeProp = decl.prop === 'mask-composite'
|
||||
|
||||
let compositeValues
|
||||
|
||||
if (isCompositeProp) {
|
||||
compositeValues = decl.value.split(',')
|
||||
} else {
|
||||
compositeValues = decl.value.match(MaskComposite.regexp) || []
|
||||
}
|
||||
|
||||
compositeValues = compositeValues.map(el => el.trim()).filter(el => el)
|
||||
let hasCompositeValues = compositeValues.length
|
||||
|
||||
let compositeDecl
|
||||
|
||||
if (hasCompositeValues) {
|
||||
compositeDecl = this.clone(decl)
|
||||
compositeDecl.value = compositeValues
|
||||
.map(value => MaskComposite.oldValues[value] || value)
|
||||
.join(', ')
|
||||
|
||||
if (compositeValues.includes('intersect')) {
|
||||
compositeDecl.value += ', xor'
|
||||
}
|
||||
|
||||
compositeDecl.prop = prefix + 'mask-composite'
|
||||
}
|
||||
|
||||
if (isCompositeProp) {
|
||||
if (!hasCompositeValues) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (this.needCascade(decl)) {
|
||||
compositeDecl.raws.before = this.calcBefore(prefixes, decl, prefix)
|
||||
}
|
||||
|
||||
return decl.parent.insertBefore(decl, compositeDecl)
|
||||
}
|
||||
|
||||
let cloned = this.clone(decl)
|
||||
cloned.prop = prefix + cloned.prop
|
||||
|
||||
if (hasCompositeValues) {
|
||||
cloned.value = cloned.value.replace(MaskComposite.regexp, '')
|
||||
}
|
||||
|
||||
if (this.needCascade(decl)) {
|
||||
cloned.raws.before = this.calcBefore(prefixes, decl, prefix)
|
||||
}
|
||||
|
||||
decl.parent.insertBefore(decl, cloned)
|
||||
|
||||
if (!hasCompositeValues) {
|
||||
return decl
|
||||
}
|
||||
|
||||
if (this.needCascade(decl)) {
|
||||
compositeDecl.raws.before = this.calcBefore(prefixes, decl, prefix)
|
||||
}
|
||||
return decl.parent.insertBefore(decl, compositeDecl)
|
||||
}
|
||||
}
|
||||
|
||||
MaskComposite.names = ['mask', 'mask-composite']
|
||||
|
||||
MaskComposite.oldValues = {
|
||||
add: 'source-over',
|
||||
subtract: 'source-out',
|
||||
intersect: 'source-in',
|
||||
exclude: 'xor'
|
||||
}
|
||||
|
||||
MaskComposite.regexp = new RegExp(
|
||||
`\\s+(${Object.keys(MaskComposite.oldValues).join(
|
||||
'|'
|
||||
)})\\b(?!\\))\\s*(?=[,])`,
|
||||
'ig'
|
||||
)
|
||||
|
||||
module.exports = MaskComposite
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var UnsubscriptionErrorImpl = (function () {
|
||||
function UnsubscriptionErrorImpl(errors) {
|
||||
Error.call(this);
|
||||
this.message = errors ?
|
||||
errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
|
||||
this.name = 'UnsubscriptionError';
|
||||
this.errors = errors;
|
||||
return this;
|
||||
}
|
||||
UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
|
||||
return UnsubscriptionErrorImpl;
|
||||
})();
|
||||
exports.UnsubscriptionError = UnsubscriptionErrorImpl;
|
||||
//# sourceMappingURL=UnsubscriptionError.js.map
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
||||
* CJS and ESM environments.
|
||||
*
|
||||
* @license
|
||||
* Copyright (c) 2016, Contributors
|
||||
* SPDX-License-Identifier: ISC
|
||||
*/
|
||||
import { format } from 'util';
|
||||
import { readFileSync } from 'fs';
|
||||
import { normalize, resolve } from 'path';
|
||||
import { camelCase, decamelize, looksLikeNumber } from './string-utils.js';
|
||||
import { YargsParser } from './yargs-parser.js';
|
||||
// See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our
|
||||
// version support policy. The YARGS_MIN_NODE_VERSION is used for testing only.
|
||||
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
|
||||
? Number(process.env.YARGS_MIN_NODE_VERSION)
|
||||
: 10;
|
||||
if (process && process.version) {
|
||||
const major = Number(process.version.match(/v([^.]+)/)[1]);
|
||||
if (major < minNodeVersion) {
|
||||
throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
|
||||
}
|
||||
}
|
||||
// Creates a yargs-parser instance using Node.js standard libraries:
|
||||
const env = process ? process.env : {};
|
||||
const parser = new YargsParser({
|
||||
cwd: process.cwd,
|
||||
env: () => {
|
||||
return env;
|
||||
},
|
||||
format,
|
||||
normalize,
|
||||
resolve,
|
||||
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
||||
// we can exercise all the lines below:
|
||||
require: (path) => {
|
||||
if (typeof require !== 'undefined') {
|
||||
return require(path);
|
||||
}
|
||||
else if (path.match(/\.json$/)) {
|
||||
return readFileSync(path, 'utf8');
|
||||
}
|
||||
else {
|
||||
throw Error('only .json config files are supported in ESM');
|
||||
}
|
||||
}
|
||||
});
|
||||
const yargsParser = function Parser(args, opts) {
|
||||
const result = parser.parse(args.slice(), opts);
|
||||
return result.argv;
|
||||
};
|
||||
yargsParser.detailed = function (args, opts) {
|
||||
return parser.parse(args.slice(), opts);
|
||||
};
|
||||
yargsParser.camelCase = camelCase;
|
||||
yargsParser.decamelize = decamelize;
|
||||
yargsParser.looksLikeNumber = looksLikeNumber;
|
||||
export default yargsParser;
|
||||
@@ -0,0 +1,13 @@
|
||||
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
||||
var __window = typeof window !== 'undefined' && window;
|
||||
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
||||
self instanceof WorkerGlobalScope && self;
|
||||
var __global = typeof global !== 'undefined' && global;
|
||||
var _root = __window || __global || __self;
|
||||
/*@__PURE__*/ (function () {
|
||||
if (!_root) {
|
||||
throw /*@__PURE__*/ new Error('RxJS could not find any global context (window, self, global)');
|
||||
}
|
||||
})();
|
||||
export { _root as root };
|
||||
//# sourceMappingURL=root.js.map
|
||||
@@ -0,0 +1,527 @@
|
||||
# query-string
|
||||
|
||||
> Parse and stringify URL [query strings](https://en.wikipedia.org/wiki/Query_string)
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<p>
|
||||
<p>
|
||||
<sup>
|
||||
<a href="https://github.com/sponsors/sindresorhus">My open source work is supported by the community</a>
|
||||
</sup>
|
||||
</p>
|
||||
<sup>Special thanks to:</sup>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://standardresume.co/tech">
|
||||
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="200"/>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install query-string
|
||||
```
|
||||
|
||||
This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, or, if your project is using create-react-app v1, use version 5: `npm install query-string@5`.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
console.log(location.search);
|
||||
//=> '?foo=bar'
|
||||
|
||||
const parsed = queryString.parse(location.search);
|
||||
console.log(parsed);
|
||||
//=> {foo: 'bar'}
|
||||
|
||||
console.log(location.hash);
|
||||
//=> '#token=bada55cafe'
|
||||
|
||||
const parsedHash = queryString.parse(location.hash);
|
||||
console.log(parsedHash);
|
||||
//=> {token: 'bada55cafe'}
|
||||
|
||||
parsed.foo = 'unicorn';
|
||||
parsed.ilike = 'pizza';
|
||||
|
||||
const stringified = queryString.stringify(parsed);
|
||||
//=> 'foo=unicorn&ilike=pizza'
|
||||
|
||||
location.search = stringified;
|
||||
// note that `location.search` automatically prepends a question mark
|
||||
console.log(location.search);
|
||||
//=> '?foo=unicorn&ilike=pizza'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .parse(string, options?)
|
||||
|
||||
Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.
|
||||
|
||||
The returned object is created with [`Object.create(null)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create) and thus does not have a `prototype`.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### decode
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Decode the keys and values. URL components are decoded with [`decode-uri-component`](https://github.com/SamVerschueren/decode-uri-component).
|
||||
|
||||
##### arrayFormat
|
||||
|
||||
Type: `string`\
|
||||
Default: `'none'`
|
||||
|
||||
- `'bracket'`: Parse arrays with bracket representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'index'`: Parse arrays with index representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'comma'`: Parse arrays with elements separated by comma:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'separator'`: Parse arrays with elements separated by a custom character:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1|2|3', {arrayFormat: 'separator', arrayFormatSeparator: '|'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'none'`: Parse arrays with elements using duplicate keys:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1&foo=2&foo=3');
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
##### arrayFormatSeparator
|
||||
|
||||
Type: `string`\
|
||||
Default: `','`
|
||||
|
||||
The character used to separate array elements when using `{arrayFormat: 'separator'}`.
|
||||
|
||||
##### sort
|
||||
|
||||
Type: `Function | boolean`\
|
||||
Default: `true`
|
||||
|
||||
Supports both `Function` as a custom sorting function or `false` to disable sorting.
|
||||
|
||||
##### parseNumbers
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1', {parseNumbers: true});
|
||||
//=> {foo: 1}
|
||||
```
|
||||
|
||||
Parse the value as a number type instead of string type if it's a number.
|
||||
|
||||
##### parseBooleans
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=true', {parseBooleans: true});
|
||||
//=> {foo: true}
|
||||
```
|
||||
|
||||
Parse the value as a boolean type instead of string type if it's a boolean.
|
||||
|
||||
### .stringify(object, options?)
|
||||
|
||||
Stringify an object into a query string and sorting the keys.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### strict
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Strictly encode URI components with [strict-uri-encode](https://github.com/kevva/strict-uri-encode). It uses [encodeURIComponent](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to false. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
|
||||
|
||||
##### encode
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
[URL encode](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) the keys and values.
|
||||
|
||||
##### arrayFormat
|
||||
|
||||
Type: `string`\
|
||||
Default: `'none'`
|
||||
|
||||
- `'bracket'`: Serialize arrays using bracket representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});
|
||||
//=> 'foo[]=1&foo[]=2&foo[]=3'
|
||||
```
|
||||
|
||||
- `'index'`: Serialize arrays using index representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
|
||||
//=> 'foo[0]=1&foo[1]=2&foo[2]=3'
|
||||
```
|
||||
|
||||
- `'comma'`: Serialize arrays by separating elements with comma:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'comma'});
|
||||
//=> 'foo=1,2,3'
|
||||
```
|
||||
|
||||
- `'none'`: Serialize arrays by using duplicate keys:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]});
|
||||
//=> 'foo=1&foo=2&foo=3'
|
||||
```
|
||||
|
||||
##### arrayFormatSeparator
|
||||
|
||||
Type: `string`\
|
||||
Default: `','`
|
||||
|
||||
The character used to separate array elements when using `{arrayFormat: 'separator'}`.
|
||||
|
||||
##### sort
|
||||
|
||||
Type: `Function | boolean`
|
||||
|
||||
Supports both `Function` as a custom sorting function or `false` to disable sorting.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
const order = ['c', 'a', 'b'];
|
||||
|
||||
queryString.stringify({a: 1, b: 2, c: 3}, {
|
||||
sort: (a, b) => order.indexOf(a) - order.indexOf(b)
|
||||
});
|
||||
//=> 'c=3&a=1&b=2'
|
||||
```
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({b: 1, c: 2, a: 3}, {sort: false});
|
||||
//=> 'b=1&c=2&a=3'
|
||||
```
|
||||
|
||||
If omitted, keys are sorted using `Array#sort()`, which means, converting them to strings and comparing strings in Unicode code point order.
|
||||
|
||||
##### skipNull
|
||||
|
||||
Skip keys with `null` as the value.
|
||||
|
||||
Note that keys with `undefined` as the value are always skipped.
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: 1, b: undefined, c: null, d: 4}, {
|
||||
skipNull: true
|
||||
});
|
||||
//=> 'a=1&d=4'
|
||||
```
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: undefined, b: null}, {
|
||||
skipNull: true
|
||||
});
|
||||
//=> ''
|
||||
```
|
||||
|
||||
##### skipEmptyString
|
||||
|
||||
Skip keys with an empty string as the value.
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: 1, b: '', c: '', d: 4}, {
|
||||
skipEmptyString: true
|
||||
});
|
||||
//=> 'a=1&d=4'
|
||||
```
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: '', b: ''}, {
|
||||
skipEmptyString: true
|
||||
});
|
||||
//=> ''
|
||||
```
|
||||
|
||||
### .extract(string)
|
||||
|
||||
Extract a query string from a URL that can be passed into `.parse()`.
|
||||
|
||||
Note: This behaviour can be changed with the `skipNull` option.
|
||||
|
||||
### .parseUrl(string, options?)
|
||||
|
||||
Extract the URL and the query string as an object.
|
||||
|
||||
Returns an object with a `url` and `query` property.
|
||||
|
||||
If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar');
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}}
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
|
||||
```
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
The options are the same as for `.parse()`.
|
||||
|
||||
Extra options are as below.
|
||||
|
||||
##### parseFragmentIdentifier
|
||||
|
||||
Parse the fragment identifier from the URL.
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
|
||||
```
|
||||
|
||||
### .stringifyUrl(object, options?)
|
||||
|
||||
Stringify an object into a URL with a query string and sorting the keys. The inverse of [`.parseUrl()`](https://github.com/sindresorhus/query-string#parseurlstring-options)
|
||||
|
||||
The `options` are the same as for `.stringify()`.
|
||||
|
||||
Returns a string with the URL and a query string.
|
||||
|
||||
Query items in the `query` property overrides queries in the `url` property.
|
||||
|
||||
The `fragmentIdentifier` property overrides the fragment identifier in the `url` property.
|
||||
|
||||
```js
|
||||
queryString.stringifyUrl({url: 'https://foo.bar', query: {foo: 'bar'}});
|
||||
//=> 'https://foo.bar?foo=bar'
|
||||
|
||||
queryString.stringifyUrl({url: 'https://foo.bar?foo=baz', query: {foo: 'bar'}});
|
||||
//=> 'https://foo.bar?foo=bar'
|
||||
|
||||
queryString.stringifyUrl({
|
||||
url: 'https://foo.bar',
|
||||
query: {
|
||||
top: 'foo'
|
||||
},
|
||||
fragmentIdentifier: 'bar'
|
||||
});
|
||||
//=> 'https://foo.bar?top=foo#bar'
|
||||
```
|
||||
|
||||
#### object
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### url
|
||||
|
||||
Type: `string`
|
||||
|
||||
The URL to stringify.
|
||||
|
||||
##### query
|
||||
|
||||
Type: `object`
|
||||
|
||||
Query items to add to the URL.
|
||||
|
||||
### .pick(url, keys, options?)
|
||||
### .pick(url, filter, options?)
|
||||
|
||||
Pick query parameters from a URL.
|
||||
|
||||
Returns a string with the new URL.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.pick('https://foo.bar?foo=1&bar=2#hello', ['foo']);
|
||||
//=> 'https://foo.bar?foo=1#hello'
|
||||
|
||||
queryString.pick('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
|
||||
//=> 'https://foo.bar?bar=2#hello'
|
||||
```
|
||||
|
||||
### .exclude(url, keys, options?)
|
||||
### .exclude(url, filter, options?)
|
||||
|
||||
Exclude query parameters from a URL.
|
||||
|
||||
Returns a string with the new URL.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.exclude('https://foo.bar?foo=1&bar=2#hello', ['foo']);
|
||||
//=> 'https://foo.bar?bar=2#hello'
|
||||
|
||||
queryString.exclude('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
|
||||
//=> 'https://foo.bar?foo=1#hello'
|
||||
```
|
||||
|
||||
#### url
|
||||
|
||||
Type: `string`
|
||||
|
||||
The URL containing the query parameters to filter.
|
||||
|
||||
#### keys
|
||||
|
||||
Type: `string[]`
|
||||
|
||||
The names of the query parameters to filter based on the function used.
|
||||
|
||||
#### filter
|
||||
|
||||
Type: `(key, value) => boolean`
|
||||
|
||||
A filter predicate that will be provided the name of each query parameter and its value. The `parseNumbers` and `parseBooleans` options also affect `value`.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
[Parse options](#options) and [stringify options](#options-1).
|
||||
|
||||
## Nesting
|
||||
|
||||
This module intentionally doesn't support nesting as it's not spec'd and varies between implementations, which causes a lot of [edge cases](https://github.com/visionmedia/node-querystring/issues).
|
||||
|
||||
You're much better off just converting the object to a JSON string:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({
|
||||
foo: 'bar',
|
||||
nested: JSON.stringify({
|
||||
unicorn: 'cake'
|
||||
})
|
||||
});
|
||||
//=> 'foo=bar&nested=%7B%22unicorn%22%3A%22cake%22%7D'
|
||||
```
|
||||
|
||||
However, there is support for multiple instances of the same key:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('likes=cake&name=bob&likes=icecream');
|
||||
//=> {likes: ['cake', 'icecream'], name: 'bob'}
|
||||
|
||||
queryString.stringify({color: ['taupe', 'chartreuse'], id: '515'});
|
||||
//=> 'color=taupe&color=chartreuse&id=515'
|
||||
```
|
||||
|
||||
## Falsy values
|
||||
|
||||
Sometimes you want to unset a key, or maybe just make it present without assigning a value to it. Here is how falsy values are stringified:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: false});
|
||||
//=> 'foo=false'
|
||||
|
||||
queryString.stringify({foo: null});
|
||||
//=> 'foo'
|
||||
|
||||
queryString.stringify({foo: undefined});
|
||||
//=> ''
|
||||
```
|
||||
|
||||
## query-string for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of query-string 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-query-string?utm_source=npm-query-string&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
@@ -0,0 +1,241 @@
|
||||
"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 __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Subject_1 = require("../../Subject");
|
||||
var Subscriber_1 = require("../../Subscriber");
|
||||
var Observable_1 = require("../../Observable");
|
||||
var Subscription_1 = require("../../Subscription");
|
||||
var ReplaySubject_1 = require("../../ReplaySubject");
|
||||
var DEFAULT_WEBSOCKET_CONFIG = {
|
||||
url: '',
|
||||
deserializer: function (e) { return JSON.parse(e.data); },
|
||||
serializer: function (value) { return JSON.stringify(value); },
|
||||
};
|
||||
var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
|
||||
var WebSocketSubject = (function (_super) {
|
||||
__extends(WebSocketSubject, _super);
|
||||
function WebSocketSubject(urlConfigOrSource, destination) {
|
||||
var _this = _super.call(this) || this;
|
||||
if (urlConfigOrSource instanceof Observable_1.Observable) {
|
||||
_this.destination = destination;
|
||||
_this.source = urlConfigOrSource;
|
||||
}
|
||||
else {
|
||||
var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
|
||||
_this._output = new Subject_1.Subject();
|
||||
if (typeof urlConfigOrSource === 'string') {
|
||||
config.url = urlConfigOrSource;
|
||||
}
|
||||
else {
|
||||
for (var key in urlConfigOrSource) {
|
||||
if (urlConfigOrSource.hasOwnProperty(key)) {
|
||||
config[key] = urlConfigOrSource[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!config.WebSocketCtor && WebSocket) {
|
||||
config.WebSocketCtor = WebSocket;
|
||||
}
|
||||
else if (!config.WebSocketCtor) {
|
||||
throw new Error('no WebSocket constructor can be found');
|
||||
}
|
||||
_this.destination = new ReplaySubject_1.ReplaySubject();
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
WebSocketSubject.prototype.lift = function (operator) {
|
||||
var sock = new WebSocketSubject(this._config, this.destination);
|
||||
sock.operator = operator;
|
||||
sock.source = this;
|
||||
return sock;
|
||||
};
|
||||
WebSocketSubject.prototype._resetState = function () {
|
||||
this._socket = null;
|
||||
if (!this.source) {
|
||||
this.destination = new ReplaySubject_1.ReplaySubject();
|
||||
}
|
||||
this._output = new Subject_1.Subject();
|
||||
};
|
||||
WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
|
||||
var self = this;
|
||||
return new Observable_1.Observable(function (observer) {
|
||||
try {
|
||||
self.next(subMsg());
|
||||
}
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
var subscription = self.subscribe(function (x) {
|
||||
try {
|
||||
if (messageFilter(x)) {
|
||||
observer.next(x);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
}, function (err) { return observer.error(err); }, function () { return observer.complete(); });
|
||||
return function () {
|
||||
try {
|
||||
self.next(unsubMsg());
|
||||
}
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
subscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
};
|
||||
WebSocketSubject.prototype._connectSocket = function () {
|
||||
var _this = this;
|
||||
var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
|
||||
var observer = this._output;
|
||||
var socket = null;
|
||||
try {
|
||||
socket = protocol ?
|
||||
new WebSocketCtor(url, protocol) :
|
||||
new WebSocketCtor(url);
|
||||
this._socket = socket;
|
||||
if (binaryType) {
|
||||
this._socket.binaryType = binaryType;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
observer.error(e);
|
||||
return;
|
||||
}
|
||||
var subscription = new Subscription_1.Subscription(function () {
|
||||
_this._socket = null;
|
||||
if (socket && socket.readyState === 1) {
|
||||
socket.close();
|
||||
}
|
||||
});
|
||||
socket.onopen = function (e) {
|
||||
var _socket = _this._socket;
|
||||
if (!_socket) {
|
||||
socket.close();
|
||||
_this._resetState();
|
||||
return;
|
||||
}
|
||||
var openObserver = _this._config.openObserver;
|
||||
if (openObserver) {
|
||||
openObserver.next(e);
|
||||
}
|
||||
var queue = _this.destination;
|
||||
_this.destination = Subscriber_1.Subscriber.create(function (x) {
|
||||
if (socket.readyState === 1) {
|
||||
try {
|
||||
var serializer = _this._config.serializer;
|
||||
socket.send(serializer(x));
|
||||
}
|
||||
catch (e) {
|
||||
_this.destination.error(e);
|
||||
}
|
||||
}
|
||||
}, function (e) {
|
||||
var closingObserver = _this._config.closingObserver;
|
||||
if (closingObserver) {
|
||||
closingObserver.next(undefined);
|
||||
}
|
||||
if (e && e.code) {
|
||||
socket.close(e.code, e.reason);
|
||||
}
|
||||
else {
|
||||
observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
|
||||
}
|
||||
_this._resetState();
|
||||
}, function () {
|
||||
var closingObserver = _this._config.closingObserver;
|
||||
if (closingObserver) {
|
||||
closingObserver.next(undefined);
|
||||
}
|
||||
socket.close();
|
||||
_this._resetState();
|
||||
});
|
||||
if (queue && queue instanceof ReplaySubject_1.ReplaySubject) {
|
||||
subscription.add(queue.subscribe(_this.destination));
|
||||
}
|
||||
};
|
||||
socket.onerror = function (e) {
|
||||
_this._resetState();
|
||||
observer.error(e);
|
||||
};
|
||||
socket.onclose = function (e) {
|
||||
_this._resetState();
|
||||
var closeObserver = _this._config.closeObserver;
|
||||
if (closeObserver) {
|
||||
closeObserver.next(e);
|
||||
}
|
||||
if (e.wasClean) {
|
||||
observer.complete();
|
||||
}
|
||||
else {
|
||||
observer.error(e);
|
||||
}
|
||||
};
|
||||
socket.onmessage = function (e) {
|
||||
try {
|
||||
var deserializer = _this._config.deserializer;
|
||||
observer.next(deserializer(e));
|
||||
}
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
};
|
||||
};
|
||||
WebSocketSubject.prototype._subscribe = function (subscriber) {
|
||||
var _this = this;
|
||||
var source = this.source;
|
||||
if (source) {
|
||||
return source.subscribe(subscriber);
|
||||
}
|
||||
if (!this._socket) {
|
||||
this._connectSocket();
|
||||
}
|
||||
this._output.subscribe(subscriber);
|
||||
subscriber.add(function () {
|
||||
var _socket = _this._socket;
|
||||
if (_this._output.observers.length === 0) {
|
||||
if (_socket && _socket.readyState === 1) {
|
||||
_socket.close();
|
||||
}
|
||||
_this._resetState();
|
||||
}
|
||||
});
|
||||
return subscriber;
|
||||
};
|
||||
WebSocketSubject.prototype.unsubscribe = function () {
|
||||
var _socket = this._socket;
|
||||
if (_socket && _socket.readyState === 1) {
|
||||
_socket.close();
|
||||
}
|
||||
this._resetState();
|
||||
_super.prototype.unsubscribe.call(this);
|
||||
};
|
||||
return WebSocketSubject;
|
||||
}(Subject_1.AnonymousSubject));
|
||||
exports.WebSocketSubject = WebSocketSubject;
|
||||
//# sourceMappingURL=WebSocketSubject.js.map
|
||||
@@ -0,0 +1,27 @@
|
||||
/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
|
||||
import * as tslib_1 from "tslib";
|
||||
import { Subscriber } from '../Subscriber';
|
||||
export function dematerialize() {
|
||||
return function dematerializeOperatorFunction(source) {
|
||||
return source.lift(new DeMaterializeOperator());
|
||||
};
|
||||
}
|
||||
var DeMaterializeOperator = /*@__PURE__*/ (function () {
|
||||
function DeMaterializeOperator() {
|
||||
}
|
||||
DeMaterializeOperator.prototype.call = function (subscriber, source) {
|
||||
return source.subscribe(new DeMaterializeSubscriber(subscriber));
|
||||
};
|
||||
return DeMaterializeOperator;
|
||||
}());
|
||||
var DeMaterializeSubscriber = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(DeMaterializeSubscriber, _super);
|
||||
function DeMaterializeSubscriber(destination) {
|
||||
return _super.call(this, destination) || this;
|
||||
}
|
||||
DeMaterializeSubscriber.prototype._next = function (value) {
|
||||
value.observe(this.destination);
|
||||
};
|
||||
return DeMaterializeSubscriber;
|
||||
}(Subscriber));
|
||||
//# sourceMappingURL=dematerialize.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"let.js","sources":["../src/operator/let.ts"],"names":[],"mappings":";;;;;AAAA,8CAAyC"}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { async } from '../scheduler/async';
|
||||
import { isNumeric } from '../util/isNumeric';
|
||||
export function interval(period = 0, scheduler = async) {
|
||||
if (!isNumeric(period) || period < 0) {
|
||||
period = 0;
|
||||
}
|
||||
if (!scheduler || typeof scheduler.schedule !== 'function') {
|
||||
scheduler = async;
|
||||
}
|
||||
return new Observable(subscriber => {
|
||||
subscriber.add(scheduler.schedule(dispatch, period, { subscriber, counter: 0, period }));
|
||||
return subscriber;
|
||||
});
|
||||
}
|
||||
function dispatch(state) {
|
||||
const { subscriber, counter, period } = state;
|
||||
subscriber.next(counter);
|
||||
this.schedule({ subscriber, counter: counter + 1, period }, period);
|
||||
}
|
||||
//# sourceMappingURL=interval.js.map
|
||||
@@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidValidate=t()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return function(t){return"string"==typeof t&&e.test(t)}}));
|
||||
@@ -0,0 +1,7 @@
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import SlotTemplate from '../../nodes/SlotTemplate';
|
||||
import InlineComponent from '../../nodes/InlineComponent';
|
||||
import Element from '../../nodes/Element';
|
||||
export default function (node: SlotTemplate | Element | InlineComponent, renderer: Renderer, options: RenderOptions & {
|
||||
slot_scopes: Map<any, any>;
|
||||
}): void;
|
||||
Reference in New Issue
Block a user