new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g 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 h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB EC FC"},D:{"1":"fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g 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","194":"YB uB ZB vB aB bB cB dB eB"},E:{"2":"I v J D E F A B C K L G HC zB IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"1":"UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB PC QC RC SC qB AC TC rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"2":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"2":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"2":"AD BD"}},B:4,C:"Accelerometer"};
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"array-bracket-newline": 0,
|
||||
"id-length": 0,
|
||||
"new-cap": [2, {
|
||||
"capIsNewExceptions": [
|
||||
"ArraySpeciesCreate",
|
||||
"Call",
|
||||
"CreateDataPropertyOrThrow",
|
||||
"Get",
|
||||
"HasProperty",
|
||||
"IsCallable",
|
||||
"RequireObjectCoercible",
|
||||
"ToObject",
|
||||
"ToString",
|
||||
"ToUint32",
|
||||
]
|
||||
}],
|
||||
"no-magic-numbers": 0,
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**",
|
||||
"rules": {
|
||||
"max-lines-per-function": 0,
|
||||
"no-invalid-this": 1,
|
||||
"strict": 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { ObservableInput, ObservedValueOf, OperatorFunction } from '../types';
|
||||
import { switchMap } from './switchMap';
|
||||
import { operate } from '../util/lift';
|
||||
|
||||
// TODO: Generate a marble diagram for these docs.
|
||||
|
||||
/**
|
||||
* Applies an accumulator function over the source Observable where the
|
||||
* accumulator function itself returns an Observable, emitting values
|
||||
* only from the most recently returned Observable.
|
||||
*
|
||||
* <span class="informal">It's like {@link mergeScan}, but only the most recent
|
||||
* Observable returned by the accumulator is merged into the outer Observable.</span>
|
||||
*
|
||||
* @see {@link scan}
|
||||
* @see {@link mergeScan}
|
||||
* @see {@link switchMap}
|
||||
*
|
||||
* @param accumulator
|
||||
* The accumulator function called on each source value.
|
||||
* @param seed The initial accumulation value.
|
||||
* @return A function that returns an observable of the accumulated values.
|
||||
*/
|
||||
export function switchScan<T, R, O extends ObservableInput<any>>(
|
||||
accumulator: (acc: R, value: T, index: number) => O,
|
||||
seed: R
|
||||
): OperatorFunction<T, ObservedValueOf<O>> {
|
||||
return operate((source, subscriber) => {
|
||||
// The state we will keep up to date to pass into our
|
||||
// accumulator function at each new value from the source.
|
||||
let state = seed;
|
||||
|
||||
// Use `switchMap` on our `source` to do the work of creating
|
||||
// this operator. Note the backwards order here of `switchMap()(source)`
|
||||
// to avoid needing to use `pipe` unnecessarily
|
||||
switchMap(
|
||||
// On each value from the source, call the accumulator with
|
||||
// our previous state, the value and the index.
|
||||
(value: T, index) => accumulator(state, value, index),
|
||||
// Using the deprecated result selector here as a dirty trick
|
||||
// to update our state with the flattened value.
|
||||
(_, innerValue) => ((state = innerValue), innerValue)
|
||||
)(source).subscribe(subscriber);
|
||||
|
||||
return () => {
|
||||
// Release state on finalization
|
||||
state = null!;
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
'use strict';
|
||||
const tls = require('tls');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const JSStreamSocket = require('../utils/js-stream-socket.js');
|
||||
const {globalAgent} = require('../agent.js');
|
||||
const UnexpectedStatusCodeError = require('./unexpected-status-code-error.js');
|
||||
const initialize = require('./initialize.js');
|
||||
const getAuthorizationHeaders = require('./get-auth-headers.js');
|
||||
|
||||
const createConnection = (self, options, callback) => {
|
||||
(async () => {
|
||||
try {
|
||||
const {proxyOptions} = self;
|
||||
const {url, headers, raw} = proxyOptions;
|
||||
|
||||
const stream = await globalAgent.request(url, proxyOptions, {
|
||||
...getAuthorizationHeaders(self),
|
||||
...headers,
|
||||
':method': 'CONNECT',
|
||||
':authority': `${options.host}:${options.port}`
|
||||
});
|
||||
|
||||
stream.once('error', callback);
|
||||
stream.once('response', headers => {
|
||||
const statusCode = headers[':status'];
|
||||
|
||||
if (statusCode !== 200) {
|
||||
callback(new UnexpectedStatusCodeError(statusCode, ''));
|
||||
return;
|
||||
}
|
||||
|
||||
const encrypted = self instanceof https.Agent;
|
||||
|
||||
if (raw && encrypted) {
|
||||
options.socket = stream;
|
||||
const secureStream = tls.connect(options);
|
||||
|
||||
secureStream.once('close', () => {
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
callback(null, secureStream);
|
||||
return;
|
||||
}
|
||||
|
||||
const socket = new JSStreamSocket(stream);
|
||||
socket.encrypted = false;
|
||||
socket._handle.getpeername = out => {
|
||||
out.family = undefined;
|
||||
out.address = undefined;
|
||||
out.port = undefined;
|
||||
};
|
||||
|
||||
callback(null, socket);
|
||||
});
|
||||
} catch (error) {
|
||||
callback(error);
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
class HttpOverHttp2 extends http.Agent {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
initialize(this, options.proxyOptions);
|
||||
}
|
||||
|
||||
createConnection(options, callback) {
|
||||
createConnection(this, options, callback);
|
||||
}
|
||||
}
|
||||
|
||||
class HttpsOverHttp2 extends https.Agent {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
initialize(this, options.proxyOptions);
|
||||
}
|
||||
|
||||
createConnection(options, callback) {
|
||||
createConnection(this, options, callback);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
HttpOverHttp2,
|
||||
HttpsOverHttp2
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"1":"0 1 2 3 4 5 6 7 8 9 v J D E F A B C K L G M N O w g 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 h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB EC FC","33":"I"},D:{"1":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g 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 h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},E:{"1":"I v J D E F A B C K L G IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"HC zB"},F:{"1":"0 1 2 3 4 5 6 7 8 9 G M N O w g 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 h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C PC QC RC SC qB AC TC","132":"rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","2":"AD"}},B:2,C:"CSS resize property"};
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"es-to-primitive","version":"1.2.1","files":{"LICENSE":{"checkedAt":1678883671601,"integrity":"sha512-CWRd82wre8E2D9wfNTwrOCxhLsdU7obtQTc4poEGt1uTk93MEI2QW01sXILetqMRgoYp4EIKQZNHNCQrALOFjw==","mode":420,"size":1082},".eslintrc":{"checkedAt":1678883671616,"integrity":"sha512-FEcqG7QTdfwJ+pvAg1QUZCxnTecRw2vg0wz642JzjVD5+icd8OMkaE1ams7TkXtwxWJm6De0haUPlOvUcD0qdg==","mode":420,"size":389},"es2015.js":{"checkedAt":1678883671616,"integrity":"sha512-GMoMlpzmEBTqJFNFnOorgDbLGuS9fvBjSj4wr36LIGQMb/i1DzLFtv+GuC4kF7ZUpooGOwIFRtqtfM7gAEoUUA==","mode":420,"size":2139},"Makefile":{"checkedAt":1678883671616,"integrity":"sha512-Ujo0RlJipiGk9yepO75OgkTcyUCDdSuCLjDtfeSZh89xVwuTI+g1J4dNE9kICVhiot/CFWIbZSKqe8+tzPcrGw==","mode":420,"size":3834},"es5.js":{"checkedAt":1678883671619,"integrity":"sha512-G0GNSY3Rotmzsci5UuUdK1TCB3cGyu3veMDXNtbwLc44drTcIiAVxBJQbFdELNAA+wUHxJP9OYhFn4+lBxgkzA==","mode":420,"size":1199},"es6.js":{"checkedAt":1678883671619,"integrity":"sha512-tukCMVZqyUCWiWTjbzpu5vrCmsExl6xxN5Lv4yTksBNzUn3R3onlRQj5LMBi6y0GJWqj8srf+6/3xDtxNtkdaQ==","mode":420,"size":53},"test/es5.js":{"checkedAt":1678883671619,"integrity":"sha512-uBH2rqgzCMfD4WIpFPMHM6iV/uzhEqhXulJoKPO1tTVhtryCB7qGLv4/2aOWEion0fRGT8BgfZmmPdnoYwPkRQ==","mode":420,"size":6483},"test/es2015.js":{"checkedAt":1678883671619,"integrity":"sha512-QeNm9j+GxNnMKFCm0UzNpUOUgjAM7vW+zDki3UhFbirxKq6+vQnxUeyURmTYOa/kUSDzMyHz7Eho9Zo2V76hKg==","mode":420,"size":8732},"helpers/isPrimitive.js":{"checkedAt":1678883671623,"integrity":"sha512-UHm33K0kjCW8bdvigdgNd7MCuzXJ5RTTeGhf/+wglzzKGIASsJuWqkgFq8wz44hMcHUVc/szx5fEAVOMWAS+Ng==","mode":420,"size":151},"test/index.js":{"checkedAt":1678883671623,"integrity":"sha512-/R1OICKfbcB1OgIajE2OWNcGlE89vVqD8/GP8K+Bh0AYiwMvimgavAqbu/lcjNfL9gQGT2T4n0kWQ6EHTtg12g==","mode":420,"size":542},"index.js":{"checkedAt":1678883671623,"integrity":"sha512-jyxJ8bYHj1YfvfJkLT49WBSuRa2hwOs2/zH4ZDXUI5UolAabL0IrydBH94xsiz5qHZUaftAMENoa7WqjU3IUdQ==","mode":420,"size":454},"CHANGELOG.md":{"checkedAt":1678883671623,"integrity":"sha512-LpP7ND9qQPfLERiblFTXeJhUABKPIcu2KIPyfEaL1ggq5PnBHz0FpisMvko4Cn3YYpF5RJNxPi3zQRYLDpX3iA==","mode":420,"size":2112},"package.json":{"checkedAt":1678883671623,"integrity":"sha512-o+OfyUTtry2B/DBe2APjTioPVvJNlJl1W78jipsw/eQ1IdsAGSX1j3xyS/UTtvHSprbHN3IvNk2K+bvA9QyjVg==","mode":420,"size":1699},"test/es6.js":{"checkedAt":1678883671623,"integrity":"sha512-g6ji7Omjbve47/6g4B8KXHYa3vk0x+YMIInHzXKkrNyU+5HYinPgDssT5Fj2YrsQmKYf0H7ajiddNzu7ZHA+Kw==","mode":420,"size":8686},"README.md":{"checkedAt":1678883671626,"integrity":"sha512-0Bfj4pkGzolyKt86nNlgkwHpZc59DAVRZ49WQIy9ryYDHvfJvtkDl4Cm7VZWneeAzuMUOf9NgA/urapcLQIwiA==","mode":420,"size":1994},".travis.yml":{"checkedAt":1678883671626,"integrity":"sha512-U8jujXpsDxKHmUhAOqu+hp610jYU4h7FlxPKMP+GTlSzsulbSDflBaJ0L+LKALzBIxtun8kLYxe+PL5Ml61edg==","mode":420,"size":299},".github/FUNDING.yml":{"checkedAt":1678883671626,"integrity":"sha512-PJxclngRVSzUXs2Af5aHoLL5+wNitvpqwbX+WTYJqdWR82wdo2GYR3//+f1aXriSWRoOgPmtNQQHV9K3RnLOLA==","mode":420,"size":586}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"_assert.js","sourceRoot":"","sources":["src/_assert.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM,CAAC,CAAS;IAC9B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC;AACzF,CAAC;AAFD,wBAEC;AAED,SAAgB,IAAI,CAAC,CAAU;IAC7B,IAAI,OAAO,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAFD,oBAEC;AAED,SAAgB,KAAK,CAAC,CAAyB,EAAE,GAAG,OAAiB;IACnE,IAAI,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAC3E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;QACnD,MAAM,IAAI,SAAS,CAAC,iCAAiC,OAAO,mBAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAC/F,CAAC;AAJD,sBAIC;AAQD,SAAgB,IAAI,CAAC,IAAU;IAC7B,IAAI,OAAO,IAAI,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU;QACjE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC;AALD,oBAKC;AAED,SAAgB,MAAM,CAAC,QAAa,EAAE,aAAa,GAAG,IAAI;IACxD,IAAI,QAAQ,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC5E,IAAI,aAAa,IAAI,QAAQ,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AACnG,CAAC;AAHD,wBAGC;AACD,SAAgB,MAAM,CAAC,GAAQ,EAAE,QAAa;IAC5C,KAAK,CAAC,GAAG,CAAC,CAAC;IACX,MAAM,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC;IAC/B,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,yDAAyD,GAAG,EAAE,CAAC,CAAC;KACjF;AACH,CAAC;AAND,wBAMC;AAED,MAAM,MAAM,GAAG;IACb,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,MAAM;CACP,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* https://tc39.es/ecma402/#sec-getnumberoption
|
||||
* @param options
|
||||
* @param property
|
||||
* @param min
|
||||
* @param max
|
||||
* @param fallback
|
||||
*/
|
||||
export declare function GetNumberOption<T extends object, K extends keyof T>(options: T, property: K, minimum: number, maximum: number, fallback: number): number;
|
||||
//# sourceMappingURL=GetNumberOption.d.ts.map
|
||||
@@ -0,0 +1,26 @@
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function refCount() {
|
||||
return operate((source, subscriber) => {
|
||||
let connection = null;
|
||||
source._refCount++;
|
||||
const refCounter = createOperatorSubscriber(subscriber, undefined, undefined, undefined, () => {
|
||||
if (!source || source._refCount <= 0 || 0 < --source._refCount) {
|
||||
connection = null;
|
||||
return;
|
||||
}
|
||||
const sharedConnection = source._connection;
|
||||
const conn = connection;
|
||||
connection = null;
|
||||
if (sharedConnection && (!conn || sharedConnection === conn)) {
|
||||
sharedConnection.unsubscribe();
|
||||
}
|
||||
subscriber.unsubscribe();
|
||||
});
|
||||
source.subscribe(refCounter);
|
||||
if (!refCounter.closed) {
|
||||
connection = source.connect();
|
||||
}
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=refCount.js.map
|
||||
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
|
||||
var compact = require("../array/#/compact")
|
||||
, isObject = require("../object/is-object")
|
||||
, toArray = require("../object/to-array")
|
||||
, isArray = Array.isArray
|
||||
, stringify = JSON.stringify;
|
||||
|
||||
module.exports = function self(value /*, replacer, space*/) {
|
||||
var replacer = arguments[1], space = arguments[2];
|
||||
try {
|
||||
return stringify(value, replacer, space);
|
||||
} catch (e) {
|
||||
if (!isObject(value)) return null;
|
||||
if (typeof value.toJSON === "function") return null;
|
||||
if (isArray(value)) {
|
||||
return (
|
||||
"[" +
|
||||
compact.call(value.map(function (item) { return self(item, replacer, space); })) +
|
||||
"]"
|
||||
);
|
||||
}
|
||||
return (
|
||||
"{" +
|
||||
compact
|
||||
.call(
|
||||
toArray(value, function (item, key) {
|
||||
item = self(item, replacer, space);
|
||||
if (!item) return null;
|
||||
return stringify(key) + ":" + item;
|
||||
})
|
||||
)
|
||||
.join(",") +
|
||||
"}"
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ResolveLocale.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-localematcher/abstract/ResolveLocale.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS;KAAE,CAAC,IAAI,CAAC,GAAG,GAAG;CAAC,EACvE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,EAAE;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,EACrD,qBAAqB,EAAE,CAAC,EAAE,EAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,EACzC,gBAAgB,EAAE,MAAM,MAAM,GAC7B,mBAAmB,CA6ErB"}
|
||||
@@ -0,0 +1,26 @@
|
||||
var baseIteratee = require('./_baseIteratee'),
|
||||
baseSortedUniq = require('./_baseSortedUniq');
|
||||
|
||||
/**
|
||||
* This method is like `_.uniqBy` except that it's designed and optimized
|
||||
* for sorted arrays.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
* @example
|
||||
*
|
||||
* _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
|
||||
* // => [1.1, 2.3]
|
||||
*/
|
||||
function sortedUniqBy(array, iteratee) {
|
||||
return (array && array.length)
|
||||
? baseSortedUniq(array, baseIteratee(iteratee, 2))
|
||||
: [];
|
||||
}
|
||||
|
||||
module.exports = sortedUniqBy;
|
||||
@@ -0,0 +1,79 @@
|
||||
import assert from './_assert.js';
|
||||
import { CHash, Input, toBytes } from './utils.js';
|
||||
import { hmac } from './hmac.js';
|
||||
|
||||
// HKDF (RFC 5869)
|
||||
// https://soatok.blog/2021/11/17/understanding-hkdf/
|
||||
|
||||
/**
|
||||
* HKDF-Extract(IKM, salt) -> PRK
|
||||
* Arguments position differs from spec (IKM is first one, since it is not optional)
|
||||
* @param hash
|
||||
* @param ikm
|
||||
* @param salt
|
||||
* @returns
|
||||
*/
|
||||
export function extract(hash: CHash, ikm: Input, salt?: Input) {
|
||||
assert.hash(hash);
|
||||
// NOTE: some libraries treat zero-length array as 'not provided';
|
||||
// we don't, since we have undefined as 'not provided'
|
||||
// https://github.com/RustCrypto/KDFs/issues/15
|
||||
if (salt === undefined) salt = new Uint8Array(hash.outputLen); // if not provided, it is set to a string of HashLen zeros
|
||||
return hmac(hash, toBytes(salt), toBytes(ikm));
|
||||
}
|
||||
|
||||
// HKDF-Expand(PRK, info, L) -> OKM
|
||||
const HKDF_COUNTER = new Uint8Array([0]);
|
||||
const EMPTY_BUFFER = new Uint8Array();
|
||||
|
||||
/**
|
||||
* HKDF-expand from the spec.
|
||||
* @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step)
|
||||
* @param info - optional context and application specific information (can be a zero-length string)
|
||||
* @param length - length of output keying material in octets
|
||||
*/
|
||||
export function expand(hash: CHash, prk: Input, info?: Input, length: number = 32) {
|
||||
assert.hash(hash);
|
||||
assert.number(length);
|
||||
if (length > 255 * hash.outputLen) throw new Error('Length should be <= 255*HashLen');
|
||||
const blocks = Math.ceil(length / hash.outputLen);
|
||||
if (info === undefined) info = EMPTY_BUFFER;
|
||||
// first L(ength) octets of T
|
||||
const okm = new Uint8Array(blocks * hash.outputLen);
|
||||
// Re-use HMAC instance between blocks
|
||||
const HMAC = hmac.create(hash, prk);
|
||||
const HMACTmp = HMAC._cloneInto();
|
||||
const T = new Uint8Array(HMAC.outputLen);
|
||||
for (let counter = 0; counter < blocks; counter++) {
|
||||
HKDF_COUNTER[0] = counter + 1;
|
||||
// T(0) = empty string (zero length)
|
||||
// T(N) = HMAC-Hash(PRK, T(N-1) | info | N)
|
||||
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T)
|
||||
.update(info)
|
||||
.update(HKDF_COUNTER)
|
||||
.digestInto(T);
|
||||
okm.set(T, hash.outputLen * counter);
|
||||
HMAC._cloneInto(HMACTmp);
|
||||
}
|
||||
HMAC.destroy();
|
||||
HMACTmp.destroy();
|
||||
T.fill(0);
|
||||
HKDF_COUNTER.fill(0);
|
||||
return okm.slice(0, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* HKDF (RFC 5869): extract + expand in one step.
|
||||
* @param hash - hash function that would be used (e.g. sha256)
|
||||
* @param ikm - input keying material, the initial key
|
||||
* @param salt - optional salt value (a non-secret random value)
|
||||
* @param info - optional context and application specific information
|
||||
* @param length - length of output keying material in octets
|
||||
*/
|
||||
export const hkdf = (
|
||||
hash: CHash,
|
||||
ikm: Input,
|
||||
salt: Input | undefined,
|
||||
info: Input | undefined,
|
||||
length: number
|
||||
) => expand(hash, extract(hash, ikm, salt), info, length);
|
||||
@@ -0,0 +1,114 @@
|
||||
<script>export let handler;
|
||||
export let small = false;
|
||||
const pageNumber = handler.getPageNumber();
|
||||
const pageCount = handler.getPageCount();
|
||||
const pages = handler.getPages({ ellipsis: true });
|
||||
</script>
|
||||
|
||||
|
||||
{#if small}
|
||||
<section>
|
||||
<button type="button"
|
||||
class="small"
|
||||
class:disabled={$pageNumber === 1}
|
||||
on:click={() => handler.setPage(1)}
|
||||
>
|
||||
❬❬
|
||||
</button>
|
||||
<button type="button"
|
||||
class:disabled={$pageNumber === 1}
|
||||
on:click={() => handler.setPage('previous')}
|
||||
>
|
||||
❮
|
||||
</button>
|
||||
<button
|
||||
class:disabled={$pageNumber === $pageCount}
|
||||
on:click={() => handler.setPage('next')}
|
||||
>
|
||||
❯
|
||||
</button>
|
||||
<button
|
||||
class="small"
|
||||
class:disabled={$pageNumber === $pageCount}
|
||||
on:click={() => handler.setPage($pageCount)}
|
||||
>
|
||||
❭❭
|
||||
</button>
|
||||
</section>
|
||||
{:else}
|
||||
<section>
|
||||
<button type="button"
|
||||
class:disabled={$pageNumber === 1}
|
||||
on:click={() => handler.setPage('previous')}
|
||||
>
|
||||
{@html handler.i18n.previous}
|
||||
</button>
|
||||
{#each $pages as page}
|
||||
<button type="button"
|
||||
class:active={$pageNumber === page}
|
||||
class:ellipse={page === null}
|
||||
on:click={() => handler.setPage(page)}
|
||||
>
|
||||
{page ?? '...'}
|
||||
</button>
|
||||
{/each}
|
||||
<button type="button"
|
||||
class:disabled={$pageNumber === $pageCount}
|
||||
on:click={() => handler.setPage('next')}
|
||||
>
|
||||
{@html handler.i18n.next}
|
||||
</button>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
|
||||
<style>
|
||||
section {
|
||||
display:flex;
|
||||
}
|
||||
button {
|
||||
background:inherit;
|
||||
height:32px;
|
||||
width:32px;
|
||||
color:#616161;
|
||||
cursor:pointer;
|
||||
font-size:13px;
|
||||
margin:0;
|
||||
padding:0;
|
||||
transition:all, 0.2s;
|
||||
line-height:32px;
|
||||
border:1px solid #e0e0e0;
|
||||
border-right:none;
|
||||
border-radius:0;
|
||||
outline:none;
|
||||
}
|
||||
button:first-child {
|
||||
border-radius: 4px 0 0 4px;
|
||||
}
|
||||
button:last-child {
|
||||
border-right: 1px solid #e0e0e0;
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
|
||||
button:first-child:not(.small),
|
||||
button:last-child:not(.small) {
|
||||
min-width: 72px;
|
||||
}
|
||||
|
||||
button:not(.active):hover {
|
||||
background: #eee;
|
||||
}
|
||||
button.ellipse:hover {
|
||||
background: inherit;
|
||||
cursor: default;
|
||||
}
|
||||
button.active {
|
||||
background: #eee;
|
||||
font-weight: bold;
|
||||
cursor: default;
|
||||
}
|
||||
button.disabled:hover {
|
||||
background: inherit;
|
||||
cursor: default;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,133 @@
|
||||
import test from 'ava';
|
||||
import isCI from 'is-ci';
|
||||
import Config from '../lib/config.js';
|
||||
import { readJSON } from '../lib/util.js';
|
||||
|
||||
const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
|
||||
const projectConfig = readJSON(new URL('../.release-it.json', import.meta.url));
|
||||
|
||||
const localConfig = { github: { release: true } };
|
||||
|
||||
test("should read this project's own configuration", t => {
|
||||
const config = new Config();
|
||||
t.deepEqual(config.constructorConfig, {});
|
||||
t.deepEqual(config.localConfig, projectConfig);
|
||||
t.deepEqual(config.defaultConfig, defaultConfig);
|
||||
});
|
||||
|
||||
test('should contain default values', t => {
|
||||
const config = new Config({ configDir: './test/stub/config/default' });
|
||||
t.deepEqual(config.constructorConfig, { configDir: './test/stub/config/default' });
|
||||
t.deepEqual(config.localConfig, localConfig);
|
||||
t.deepEqual(config.defaultConfig, defaultConfig);
|
||||
});
|
||||
|
||||
test('should merge provided options', t => {
|
||||
const config = new Config({
|
||||
configDir: './test/stub/config/merge',
|
||||
increment: '1.0.0',
|
||||
verbose: true,
|
||||
github: {
|
||||
release: true
|
||||
}
|
||||
});
|
||||
const { options } = config;
|
||||
t.is(config.isVerbose, true);
|
||||
t.is(config.isDryRun, false);
|
||||
t.is(options.increment, '1.0.0');
|
||||
t.is(options.git.push, false);
|
||||
t.is(options.github.release, true);
|
||||
});
|
||||
|
||||
test('should set CI mode', t => {
|
||||
const config = new Config({ ci: true });
|
||||
t.is(config.isCI, true);
|
||||
});
|
||||
|
||||
test('should detect CI mode', t => {
|
||||
const config = new Config();
|
||||
t.is(config.options.ci, isCI);
|
||||
t.is(config.isCI, isCI);
|
||||
});
|
||||
|
||||
test('should override --no-npm.publish', t => {
|
||||
const config = new Config({ npm: { publish: false } });
|
||||
t.is(config.options.npm.publish, false);
|
||||
});
|
||||
|
||||
test('should read YAML config', t => {
|
||||
const config = new Config({ configDir: './test/stub/config/yaml' });
|
||||
t.deepEqual(config.options.foo, { bar: 1 });
|
||||
});
|
||||
|
||||
test('should read YML config', t => {
|
||||
const config = new Config({ configDir: './test/stub/config/yml' });
|
||||
t.deepEqual(config.options.foo, { bar: 1 });
|
||||
});
|
||||
|
||||
test('should read TOML config', t => {
|
||||
const config = new Config({ configDir: './test/stub/config/toml' });
|
||||
t.deepEqual(config.options.foo, { bar: 1 });
|
||||
});
|
||||
|
||||
test('should throw if provided config file is not found', t => {
|
||||
t.throws(() => new Config({ config: 'nofile' }), { message: /no such file.+nofile/ });
|
||||
});
|
||||
|
||||
test('should throw if provided config file is invalid (cosmiconfig exception)', t => {
|
||||
t.throws(() => new Config({ config: './test/stub/config/invalid-config-txt' }), {
|
||||
message: /Invalid configuration file at/
|
||||
});
|
||||
});
|
||||
|
||||
test('should throw if provided config file is invalid (no object)', t => {
|
||||
t.throws(() => new Config({ config: './test/stub/config/invalid-config-rc' }), {
|
||||
message: /Invalid configuration file at/
|
||||
});
|
||||
});
|
||||
|
||||
test('should not set default increment (for CI mode)', t => {
|
||||
const config = new Config({ ci: true });
|
||||
t.is(config.options.version.increment, undefined);
|
||||
});
|
||||
|
||||
test('should not set default increment (for interactive mode)', t => {
|
||||
const config = new Config({ ci: false });
|
||||
t.is(config.options.version.increment, undefined);
|
||||
});
|
||||
|
||||
test('should expand pre-release shortcut', t => {
|
||||
const config = new Config({ increment: 'major', preRelease: 'beta' });
|
||||
t.deepEqual(config.options.version, {
|
||||
increment: 'major',
|
||||
isPreRelease: true,
|
||||
preReleaseId: 'beta'
|
||||
});
|
||||
});
|
||||
|
||||
test('should expand pre-release shortcut (preRelease boolean)', t => {
|
||||
const config = new Config({ ci: true, preRelease: true });
|
||||
t.deepEqual(config.options.version, {
|
||||
increment: undefined,
|
||||
isPreRelease: true,
|
||||
preReleaseId: undefined
|
||||
});
|
||||
});
|
||||
|
||||
test('should expand pre-release shortcut (without increment)', t => {
|
||||
const config = new Config({ ci: false, preRelease: 'alpha' });
|
||||
t.deepEqual(config.options.version, {
|
||||
increment: undefined,
|
||||
isPreRelease: true,
|
||||
preReleaseId: 'alpha'
|
||||
});
|
||||
});
|
||||
|
||||
test('should expand pre-release shortcut (including increment and npm.tag)', t => {
|
||||
const config = new Config({ increment: 'minor', preRelease: 'rc' });
|
||||
t.deepEqual(config.options.version, {
|
||||
increment: 'minor',
|
||||
isPreRelease: true,
|
||||
preReleaseId: 'rc'
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.window = void 0;
|
||||
var Subject_1 = require("../Subject");
|
||||
var lift_1 = require("../util/lift");
|
||||
var OperatorSubscriber_1 = require("./OperatorSubscriber");
|
||||
var noop_1 = require("../util/noop");
|
||||
var innerFrom_1 = require("../observable/innerFrom");
|
||||
function window(windowBoundaries) {
|
||||
return lift_1.operate(function (source, subscriber) {
|
||||
var windowSubject = new Subject_1.Subject();
|
||||
subscriber.next(windowSubject.asObservable());
|
||||
var errorHandler = function (err) {
|
||||
windowSubject.error(err);
|
||||
subscriber.error(err);
|
||||
};
|
||||
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) { return windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value); }, function () {
|
||||
windowSubject.complete();
|
||||
subscriber.complete();
|
||||
}, errorHandler));
|
||||
innerFrom_1.innerFrom(windowBoundaries).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
|
||||
windowSubject.complete();
|
||||
subscriber.next((windowSubject = new Subject_1.Subject()));
|
||||
}, noop_1.noop, errorHandler));
|
||||
return function () {
|
||||
windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe();
|
||||
windowSubject = null;
|
||||
};
|
||||
});
|
||||
}
|
||||
exports.window = window;
|
||||
//# sourceMappingURL=window.js.map
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "./tsconfig.esm.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "es2015",
|
||||
"target": "esnext",
|
||||
"removeComments": false,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"declarationDir": "../dist/types",
|
||||
"emitDeclarationOnly": true
|
||||
},
|
||||
"exclude": ["./internal/umd.ts"]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
range-set ::= range ( logical-or range ) *
|
||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
hyphen ::= partial ' - ' partial
|
||||
simple ::= primitive | partial | tilde | caret
|
||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
||||
xr ::= 'x' | 'X' | '*' | nr
|
||||
nr ::= '0' | [1-9] ( [0-9] ) *
|
||||
tilde ::= '~' partial
|
||||
caret ::= '^' partial
|
||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
||||
pre ::= parts
|
||||
build ::= parts
|
||||
parts ::= part ( '.' part ) *
|
||||
part ::= nr | [-0-9A-Za-z]+
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = escape;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function escape(str) {
|
||||
(0, _assertString.default)(str);
|
||||
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/\//g, '/').replace(/\\/g, '\').replace(/`/g, '`');
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var has = require('has');
|
||||
var channel = require('side-channel')();
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var SLOT = {
|
||||
assert: function (O, slot) {
|
||||
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
|
||||
throw new $TypeError('`O` is not an object');
|
||||
}
|
||||
if (typeof slot !== 'string') {
|
||||
throw new $TypeError('`slot` must be a string');
|
||||
}
|
||||
channel.assert(O);
|
||||
if (!SLOT.has(O, slot)) {
|
||||
throw new $TypeError('`' + slot + '` is not present on `O`');
|
||||
}
|
||||
},
|
||||
get: function (O, slot) {
|
||||
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
|
||||
throw new $TypeError('`O` is not an object');
|
||||
}
|
||||
if (typeof slot !== 'string') {
|
||||
throw new $TypeError('`slot` must be a string');
|
||||
}
|
||||
var slots = channel.get(O);
|
||||
return slots && slots['$' + slot];
|
||||
},
|
||||
has: function (O, slot) {
|
||||
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
|
||||
throw new $TypeError('`O` is not an object');
|
||||
}
|
||||
if (typeof slot !== 'string') {
|
||||
throw new $TypeError('`slot` must be a string');
|
||||
}
|
||||
var slots = channel.get(O);
|
||||
return !!slots && has(slots, '$' + slot);
|
||||
},
|
||||
set: function (O, slot, V) {
|
||||
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
|
||||
throw new $TypeError('`O` is not an object');
|
||||
}
|
||||
if (typeof slot !== 'string') {
|
||||
throw new $TypeError('`slot` must be a string');
|
||||
}
|
||||
var slots = channel.get(O);
|
||||
if (!slots) {
|
||||
slots = {};
|
||||
channel.set(O, slots);
|
||||
}
|
||||
slots['$' + slot] = V;
|
||||
}
|
||||
};
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(SLOT);
|
||||
}
|
||||
|
||||
module.exports = SLOT;
|
||||
@@ -0,0 +1,11 @@
|
||||
import { __read, __spreadArray } from "tslib";
|
||||
import { concat } from '../observable/concat';
|
||||
import { of } from '../observable/of';
|
||||
export function endWith() {
|
||||
var values = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
values[_i] = arguments[_i];
|
||||
}
|
||||
return function (source) { return concat(source, of.apply(void 0, __spreadArray([], __read(values)))); };
|
||||
}
|
||||
//# sourceMappingURL=endWith.js.map
|
||||
@@ -0,0 +1,23 @@
|
||||
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
||||
|
||||
if (!globalThis.DOMException) {
|
||||
const { MessageChannel } = require('worker_threads'),
|
||||
port = new MessageChannel().port1,
|
||||
ab = new ArrayBuffer()
|
||||
try { port.postMessage(ab, [ab, ab]) }
|
||||
catch (err) {
|
||||
err.constructor.name === 'DOMException' && (
|
||||
globalThis.DOMException = err.constructor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = globalThis.DOMException
|
||||
|
||||
const e1 = new DOMException("Something went wrong", "BadThingsError");
|
||||
console.assert(e1.name === "BadThingsError");
|
||||
console.assert(e1.code === 0);
|
||||
|
||||
const e2 = new DOMException("Another exciting error message", "NoModificationAllowedError");
|
||||
console.assert(e2.name === "NoModificationAllowedError");
|
||||
console.assert(e2.code === 7);
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"throttleTime.js","sourceRoot":"","sources":["../../../../src/internal/operators/throttleTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAmD5C,MAAM,UAAU,YAAY,CAC1B,QAAgB,EAChB,SAAyC,EACzC,MAA8B;IAD9B,0BAAA,EAAA,0BAAyC;IACzC,uBAAA,EAAA,8BAA8B;IAE9B,IAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC7C,OAAO,QAAQ,CAAC,cAAM,OAAA,SAAS,EAAT,CAAS,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC"}
|
||||
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
require('../auto');
|
||||
|
||||
var test = require('tape');
|
||||
var defineProperties = require('define-properties');
|
||||
var callBind = require('call-bind');
|
||||
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
var functionsHaveNames = require('functions-have-names')();
|
||||
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('shimmed', function (t) {
|
||||
t.equal(String.prototype.trim.length, 0, 'String#trim has a length of 0');
|
||||
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
||||
st.equal(String.prototype.trim.name, 'trim', 'String#trim has name "trim"');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
||||
et.equal(false, isEnumerable.call(String.prototype, 'trim'), 'String#trim is not enumerable');
|
||||
et.end();
|
||||
});
|
||||
|
||||
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
||||
|
||||
t.test('bad string/this value', { skip: !supportsStrictMode }, function (st) {
|
||||
st['throws'](function () { return String.prototype.trim.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
||||
st['throws'](function () { return String.prototype.trim.call(null, 'a'); }, TypeError, 'null is not an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
runTests(callBind(String.prototype.trim), t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
export function defaults(target, ...sources) {
|
||||
for (let source of sources) {
|
||||
for (let k in source) {
|
||||
if (!target?.hasOwnProperty?.(k)) {
|
||||
target[k] = source[k]
|
||||
}
|
||||
}
|
||||
|
||||
for (let k of Object.getOwnPropertySymbols(source)) {
|
||||
if (!target?.hasOwnProperty?.(k)) {
|
||||
target[k] = source[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { OperatorFunction, ObservedValueOf, ObservableInput } from '../types';
|
||||
import { mergeMap } from './mergeMap';
|
||||
import { isFunction } from '../util/isFunction';
|
||||
|
||||
/** @deprecated Will be removed in v9. Use {@link mergeMap} instead: `mergeMap(() => result)` */
|
||||
export function mergeMapTo<O extends ObservableInput<unknown>>(
|
||||
innerObservable: O,
|
||||
concurrent?: number
|
||||
): OperatorFunction<unknown, ObservedValueOf<O>>;
|
||||
/**
|
||||
* @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead.
|
||||
* Details: https://rxjs.dev/deprecations/resultSelector
|
||||
*/
|
||||
export function mergeMapTo<T, R, O extends ObservableInput<unknown>>(
|
||||
innerObservable: O,
|
||||
resultSelector: (outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R,
|
||||
concurrent?: number
|
||||
): OperatorFunction<T, R>;
|
||||
/* tslint:enable:max-line-length */
|
||||
|
||||
/**
|
||||
* Projects each source value to the same Observable which is merged multiple
|
||||
* times in the output Observable.
|
||||
*
|
||||
* <span class="informal">It's like {@link mergeMap}, but maps each value always
|
||||
* to the same inner Observable.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Maps each source value to the given Observable `innerObservable` regardless
|
||||
* of the source value, and then merges those resulting Observables into one
|
||||
* single Observable, which is the output Observable.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* For each click event, start an interval Observable ticking every 1 second
|
||||
*
|
||||
* ```ts
|
||||
* import { fromEvent, mergeMapTo, interval } from 'rxjs';
|
||||
*
|
||||
* const clicks = fromEvent(document, 'click');
|
||||
* const result = clicks.pipe(mergeMapTo(interval(1000)));
|
||||
*
|
||||
* result.subscribe(x => console.log(x));
|
||||
* ```
|
||||
*
|
||||
* @see {@link concatMapTo}
|
||||
* @see {@link merge}
|
||||
* @see {@link mergeAll}
|
||||
* @see {@link mergeMap}
|
||||
* @see {@link mergeScan}
|
||||
* @see {@link switchMapTo}
|
||||
*
|
||||
* @param {ObservableInput} innerObservable An Observable to replace each value from
|
||||
* the source Observable.
|
||||
* @param {number} [concurrent=Infinity] Maximum number of input
|
||||
* Observables being subscribed to concurrently.
|
||||
* @return A function that returns an Observable that emits items from the
|
||||
* given `innerObservable`.
|
||||
* @deprecated Will be removed in v9. Use {@link mergeMap} instead: `mergeMap(() => result)`
|
||||
*/
|
||||
export function mergeMapTo<T, R, O extends ObservableInput<unknown>>(
|
||||
innerObservable: O,
|
||||
resultSelector?: ((outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R) | number,
|
||||
concurrent: number = Infinity
|
||||
): OperatorFunction<T, ObservedValueOf<O> | R> {
|
||||
if (isFunction(resultSelector)) {
|
||||
return mergeMap(() => innerObservable, resultSelector, concurrent);
|
||||
}
|
||||
if (typeof resultSelector === 'number') {
|
||||
concurrent = resultSelector;
|
||||
}
|
||||
return mergeMap(() => innerObservable, concurrent);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
Create a type from an object type without certain keys.
|
||||
|
||||
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
||||
|
||||
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
||||
|
||||
@example
|
||||
```
|
||||
import {Except} from 'type-fest';
|
||||
|
||||
type Foo = {
|
||||
a: number;
|
||||
b: string;
|
||||
c: boolean;
|
||||
};
|
||||
|
||||
type FooWithoutA = Except<Foo, 'a' | 'c'>;
|
||||
//=> {b: string};
|
||||
```
|
||||
|
||||
@category Utilities
|
||||
*/
|
||||
export type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>;
|
||||
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var CompletionRecord = require('./CompletionRecord');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-normalcompletion
|
||||
|
||||
module.exports = function NormalCompletion(value) {
|
||||
return new CompletionRecord('normal', value);
|
||||
};
|
||||
@@ -0,0 +1,664 @@
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="media/logo_dark.svg">
|
||||
<img alt="execa logo" src="media/logo.svg" width="400">
|
||||
</picture>
|
||||
<br>
|
||||
|
||||
[](https://codecov.io/gh/sindresorhus/execa)
|
||||
|
||||
> Process execution for humans
|
||||
|
||||
## Why
|
||||
|
||||
This package improves [`child_process`](https://nodejs.org/api/child_process.html) methods with:
|
||||
|
||||
- Promise interface.
|
||||
- [Strips the final newline](#stripfinalnewline) from the output so you don't have to do `stdout.trim()`.
|
||||
- Supports [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries cross-platform.
|
||||
- [Improved Windows support.](https://github.com/IndigoUnited/node-cross-spawn#why)
|
||||
- Higher max buffer. 100 MB instead of 200 KB.
|
||||
- [Executes locally installed binaries by name.](#preferlocal)
|
||||
- [Cleans up spawned processes when the parent process dies.](#cleanup)
|
||||
- [Get interleaved output](#all) from `stdout` and `stderr` similar to what is printed on the terminal. [*(Async only)*](#execasyncfile-arguments-options)
|
||||
- [Can specify file and arguments as a single string without a shell](#execacommandcommand-options)
|
||||
- More descriptive errors.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install execa
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
const {stdout} = await execa('echo', ['unicorns']);
|
||||
console.log(stdout);
|
||||
//=> 'unicorns'
|
||||
```
|
||||
|
||||
### Pipe the child process stdout to the parent
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
|
||||
```
|
||||
|
||||
### Handling Errors
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
// Catching an error
|
||||
try {
|
||||
await execa('unknown', ['command']);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
/*
|
||||
{
|
||||
message: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
|
||||
errno: -2,
|
||||
code: 'ENOENT',
|
||||
syscall: 'spawn unknown',
|
||||
path: 'unknown',
|
||||
spawnargs: ['command'],
|
||||
originalMessage: 'spawn unknown ENOENT',
|
||||
shortMessage: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
|
||||
command: 'unknown command',
|
||||
escapedCommand: 'unknown command',
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
all: '',
|
||||
failed: true,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
}
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
### Cancelling a spawned process
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
const abortController = new AbortController();
|
||||
const subprocess = execa('node', [], {signal: abortController.signal});
|
||||
|
||||
setTimeout(() => {
|
||||
abortController.abort();
|
||||
}, 1000);
|
||||
|
||||
try {
|
||||
await subprocess;
|
||||
} catch (error) {
|
||||
console.log(subprocess.killed); // true
|
||||
console.log(error.isCanceled); // true
|
||||
}
|
||||
```
|
||||
|
||||
### Catching an error with the sync method
|
||||
|
||||
```js
|
||||
import {execaSync} from 'execa';
|
||||
|
||||
try {
|
||||
execaSync('unknown', ['command']);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
/*
|
||||
{
|
||||
message: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT',
|
||||
errno: -2,
|
||||
code: 'ENOENT',
|
||||
syscall: 'spawnSync unknown',
|
||||
path: 'unknown',
|
||||
spawnargs: ['command'],
|
||||
originalMessage: 'spawnSync unknown ENOENT',
|
||||
shortMessage: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT',
|
||||
command: 'unknown command',
|
||||
escapedCommand: 'unknown command',
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
all: '',
|
||||
failed: true,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
}
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
### Kill a process
|
||||
|
||||
Using SIGTERM, and after 2 seconds, kill it with SIGKILL.
|
||||
|
||||
```js
|
||||
const subprocess = execa('node');
|
||||
|
||||
setTimeout(() => {
|
||||
subprocess.kill('SIGTERM', {
|
||||
forceKillAfterTimeout: 2000
|
||||
});
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### execa(file, arguments, options?)
|
||||
|
||||
Execute a file. Think of this as a mix of [`child_process.execFile()`](https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback) and [`child_process.spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
|
||||
|
||||
No escaping/quoting is needed.
|
||||
|
||||
Unless the [`shell`](#shell) option is used, no shell interpreter (Bash, `cmd.exe`, etc.) is used, so shell features such as variables substitution (`echo $PATH`) are not allowed.
|
||||
|
||||
Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) which:
|
||||
- is also a `Promise` resolving or rejecting with a [`childProcessResult`](#childProcessResult).
|
||||
- exposes the following additional methods and properties.
|
||||
|
||||
#### kill(signal?, options?)
|
||||
|
||||
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal) except: if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`.
|
||||
|
||||
##### options.forceKillAfterTimeout
|
||||
|
||||
Type: `number | false`\
|
||||
Default: `5000`
|
||||
|
||||
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
|
||||
|
||||
Can be disabled with `false`.
|
||||
|
||||
#### all
|
||||
|
||||
Type: `ReadableStream | undefined`
|
||||
|
||||
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
|
||||
|
||||
This is `undefined` if either:
|
||||
- the [`all` option](#all-2) is `false` (the default value)
|
||||
- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
|
||||
|
||||
### execaSync(file, arguments?, options?)
|
||||
|
||||
Execute a file synchronously.
|
||||
|
||||
Returns or throws a [`childProcessResult`](#childProcessResult).
|
||||
|
||||
### execaCommand(command, options?)
|
||||
|
||||
Same as [`execa()`](#execafile-arguments-options) except both file and arguments are specified in a single `command` string. For example, `execa('echo', ['unicorns'])` is the same as `execaCommand('echo unicorns')`.
|
||||
|
||||
If the file or an argument contains spaces, they must be escaped with backslashes. This matters especially if `command` is not a constant but a variable, for example with `__dirname` or `process.cwd()`. Except for spaces, no escaping/quoting is needed.
|
||||
|
||||
The [`shell` option](#shell) must be used if the `command` uses shell-specific features (for example, `&&` or `||`), as opposed to being a simple `file` followed by its `arguments`.
|
||||
|
||||
### execaCommandSync(command, options?)
|
||||
|
||||
Same as [`execaCommand()`](#execacommand-command-options) but synchronous.
|
||||
|
||||
Returns or throws a [`childProcessResult`](#childProcessResult).
|
||||
|
||||
### execaNode(scriptPath, arguments?, options?)
|
||||
|
||||
Execute a Node.js script as a child process.
|
||||
|
||||
Same as `execa('node', [scriptPath, ...arguments], options)` except (like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)):
|
||||
- the current Node version and options are used. This can be overridden using the [`nodePath`](#nodepath-for-node-only) and [`nodeOptions`](#nodeoptions-for-node-only) options.
|
||||
- the [`shell`](#shell) option cannot be used
|
||||
- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to [`stdio`](#stdio)
|
||||
|
||||
### childProcessResult
|
||||
|
||||
Type: `object`
|
||||
|
||||
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
|
||||
|
||||
The child process [fails](#failed) when:
|
||||
- its [exit code](#exitcode) is not `0`
|
||||
- it was [killed](#killed) with a [signal](#signal)
|
||||
- [timing out](#timedout)
|
||||
- [being canceled](#iscanceled)
|
||||
- there's not enough memory or there are already too many child processes
|
||||
|
||||
#### command
|
||||
|
||||
Type: `string`
|
||||
|
||||
The file and arguments that were run, for logging purposes.
|
||||
|
||||
This is not escaped and should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).
|
||||
|
||||
#### escapedCommand
|
||||
|
||||
Type: `string`
|
||||
|
||||
Same as [`command`](#command) but escaped.
|
||||
|
||||
This is meant to be copy and pasted into a shell, for debugging purposes.
|
||||
Since the escaping is fairly basic, this should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).
|
||||
|
||||
#### exitCode
|
||||
|
||||
Type: `number`
|
||||
|
||||
The numeric exit code of the process that was run.
|
||||
|
||||
#### stdout
|
||||
|
||||
Type: `string | Buffer`
|
||||
|
||||
The output of the process on stdout.
|
||||
|
||||
#### stderr
|
||||
|
||||
Type: `string | Buffer`
|
||||
|
||||
The output of the process on stderr.
|
||||
|
||||
#### all
|
||||
|
||||
Type: `string | Buffer | undefined`
|
||||
|
||||
The output of the process with `stdout` and `stderr` interleaved.
|
||||
|
||||
This is `undefined` if either:
|
||||
- the [`all` option](#all-2) is `false` (the default value)
|
||||
- `execaSync()` was used
|
||||
|
||||
#### failed
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process failed to run.
|
||||
|
||||
#### timedOut
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process timed out.
|
||||
|
||||
#### isCanceled
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process was canceled.
|
||||
|
||||
You can cancel the spawned process using the [`signal`](#signal-1) option.
|
||||
|
||||
#### killed
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process was killed.
|
||||
|
||||
#### signal
|
||||
|
||||
Type: `string | undefined`
|
||||
|
||||
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
||||
|
||||
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
||||
|
||||
#### signalDescription
|
||||
|
||||
Type: `string | undefined`
|
||||
|
||||
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
||||
|
||||
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.
|
||||
|
||||
#### message
|
||||
|
||||
Type: `string`
|
||||
|
||||
Error message when the child process failed to run. In addition to the [underlying error message](#originalMessage), it also contains some information related to why the child process errored.
|
||||
|
||||
The child process [stderr](#stderr) then [stdout](#stdout) are appended to the end, separated with newlines and not interleaved.
|
||||
|
||||
#### shortMessage
|
||||
|
||||
Type: `string`
|
||||
|
||||
This is the same as the [`message` property](#message) except it does not include the child process stdout/stderr.
|
||||
|
||||
#### originalMessage
|
||||
|
||||
Type: `string | undefined`
|
||||
|
||||
Original error message. This is the same as the `message` property except it includes neither the child process stdout/stderr nor some additional information added by Execa.
|
||||
|
||||
This is `undefined` unless the child process exited due to an `error` event or a timeout.
|
||||
|
||||
### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
#### cleanup
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Kill the spawned process when the parent process exits unless either:
|
||||
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
|
||||
- the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
|
||||
|
||||
#### preferLocal
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Prefer locally installed binaries when looking for a binary to execute.\
|
||||
If you `$ npm install foo`, you can then `execa('foo')`.
|
||||
|
||||
#### localDir
|
||||
|
||||
Type: `string | URL`\
|
||||
Default: `process.cwd()`
|
||||
|
||||
Preferred path to find locally installed binaries in (use with `preferLocal`).
|
||||
|
||||
#### execPath
|
||||
|
||||
Type: `string`\
|
||||
Default: `process.execPath` (Current Node.js executable)
|
||||
|
||||
Path to the Node.js executable to use in child processes.
|
||||
|
||||
This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
|
||||
|
||||
Requires [`preferLocal`](#preferlocal) to be `true`.
|
||||
|
||||
For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Buffer the output from the spawned process. When set to `false`, you must read the output of [`stdout`](#stdout-1) and [`stderr`](#stderr-1) (or [`all`](#all) if the [`all`](#all-2) option is `true`). Otherwise the returned promise will not be resolved/rejected.
|
||||
|
||||
If the spawned process fails, [`error.stdout`](#stdout), [`error.stderr`](#stderr), and [`error.all`](#all) will contain the buffered data.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string | Buffer | stream.Readable`
|
||||
|
||||
Write some input to the `stdin` of your binary.\
|
||||
Streams are not allowed when using the synchronous methods.
|
||||
|
||||
#### stdin
|
||||
|
||||
Type: `string | number | Stream | undefined`\
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### stdout
|
||||
|
||||
Type: `string | number | Stream | undefined`\
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### stderr
|
||||
|
||||
Type: `string | number | Stream | undefined`\
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### all
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Add an `.all` property on the [promise](#all) and the [resolved value](#all-1). The property contains the output of the process with `stdout` and `stderr` interleaved.
|
||||
|
||||
#### reject
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Setting this to `false` resolves the promise with the error instead of rejecting it.
|
||||
|
||||
#### stripFinalNewline
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
|
||||
|
||||
#### extendEnv
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
||||
|
||||
---
|
||||
|
||||
Execa also accepts the below options which are the same as the options for [`child_process#spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)/[`child_process#exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `string | URL`\
|
||||
Default: `process.cwd()`
|
||||
|
||||
Current working directory of the child process.
|
||||
|
||||
#### env
|
||||
|
||||
Type: `object`\
|
||||
Default: `process.env`
|
||||
|
||||
Environment key-value pairs. Extends automatically from `process.env`. Set [`extendEnv`](#extendenv) to `false` if you don't want this.
|
||||
|
||||
#### argv0
|
||||
|
||||
Type: `string`
|
||||
|
||||
Explicitly set the value of `argv[0]` sent to the child process. This will be set to `file` if not specified.
|
||||
|
||||
#### stdio
|
||||
|
||||
Type: `string | string[]`\
|
||||
Default: `pipe`
|
||||
|
||||
Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
|
||||
|
||||
#### serialization
|
||||
|
||||
Type: `string`\
|
||||
Default: `'json'`
|
||||
|
||||
Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio) option or [`execaNode()`](#execanodescriptpath-arguments-options):
|
||||
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
|
||||
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
|
||||
|
||||
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
|
||||
|
||||
#### detached
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
|
||||
|
||||
#### uid
|
||||
|
||||
Type: `number`
|
||||
|
||||
Sets the user identity of the process.
|
||||
|
||||
#### gid
|
||||
|
||||
Type: `number`
|
||||
|
||||
Sets the group identity of the process.
|
||||
|
||||
#### shell
|
||||
|
||||
Type: `boolean | string`\
|
||||
Default: `false`
|
||||
|
||||
If `true`, runs `file` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
||||
|
||||
We recommend against using this option since it is:
|
||||
- not cross-platform, encouraging shell-specific syntax.
|
||||
- slower, because of the additional shell interpretation.
|
||||
- unsafe, potentially allowing command injection.
|
||||
|
||||
#### encoding
|
||||
|
||||
Type: `string | null`\
|
||||
Default: `utf8`
|
||||
|
||||
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
|
||||
|
||||
#### timeout
|
||||
|
||||
Type: `number`\
|
||||
Default: `0`
|
||||
|
||||
If timeout is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than timeout milliseconds.
|
||||
|
||||
#### maxBuffer
|
||||
|
||||
Type: `number`\
|
||||
Default: `100_000_000` (100 MB)
|
||||
|
||||
Largest amount of data in bytes allowed on `stdout` or `stderr`.
|
||||
|
||||
#### killSignal
|
||||
|
||||
Type: `string | number`\
|
||||
Default: `SIGTERM`
|
||||
|
||||
Signal value to be used when the spawned process will be killed.
|
||||
|
||||
#### signal
|
||||
|
||||
Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
||||
|
||||
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
||||
|
||||
When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `false`.
|
||||
|
||||
*Requires Node.js 16 or later.*
|
||||
|
||||
#### windowsVerbatimArguments
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
||||
|
||||
#### windowsHide
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.
|
||||
|
||||
#### nodePath *(For `.node()` only)*
|
||||
|
||||
Type: `string`\
|
||||
Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath)
|
||||
|
||||
Node.js executable used to create the child process.
|
||||
|
||||
#### nodeOptions *(For `.node()` only)*
|
||||
|
||||
Type: `string[]`\
|
||||
Default: [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv)
|
||||
|
||||
List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.
|
||||
|
||||
## Tips
|
||||
|
||||
### Retry on error
|
||||
|
||||
Gracefully handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package:
|
||||
|
||||
```js
|
||||
import pRetry from 'p-retry';
|
||||
|
||||
const run = async () => {
|
||||
const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']);
|
||||
return results;
|
||||
};
|
||||
|
||||
console.log(await pRetry(run, {retries: 5}));
|
||||
```
|
||||
|
||||
### Save and pipe output from a child process
|
||||
|
||||
Let's say you want to show the output of a child process in real-time while also saving it to a variable.
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
const subprocess = execa('echo', ['foo']);
|
||||
subprocess.stdout.pipe(process.stdout);
|
||||
|
||||
const {stdout} = await subprocess;
|
||||
console.log('child output:', stdout);
|
||||
```
|
||||
|
||||
### Redirect output to a file
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
const subprocess = execa('echo', ['foo'])
|
||||
subprocess.stdout.pipe(fs.createWriteStream('stdout.txt'))
|
||||
```
|
||||
|
||||
### Redirect input from a file
|
||||
|
||||
```js
|
||||
import {execa} from 'execa';
|
||||
|
||||
const subprocess = execa('cat')
|
||||
fs.createReadStream('stdin.txt').pipe(subprocess.stdin)
|
||||
```
|
||||
|
||||
### Execute the current package's binary
|
||||
|
||||
```js
|
||||
import {getBinPathSync} from 'get-bin-path';
|
||||
|
||||
const binPath = getBinPathSync();
|
||||
const subprocess = execa(binPath);
|
||||
```
|
||||
|
||||
`execa` can be combined with [`get-bin-path`](https://github.com/ehmicky/get-bin-path) to test the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` `bin` field is correctly set up.
|
||||
|
||||
## Related
|
||||
|
||||
- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for `execa`
|
||||
- [nvexeca](https://github.com/ehmicky/nvexeca) - Run `execa` using any Node.js version
|
||||
- [sudo-prompt](https://github.com/jorangreef/sudo-prompt) - Run commands with elevated privileges.
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [@ehmicky](https://github.com/ehmicky)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-execa?utm_source=npm-execa&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
import hash from 'object-hash'
|
||||
|
||||
export default function hashConfig(config) {
|
||||
return hash(config, { ignoreUnknown: true })
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scheduleArray.d.ts","sourceRoot":"","sources":["../../../../src/internal/scheduled/scheduleArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,iBAuB7E"}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
import { noop } from '../util/noop';
|
||||
export function takeUntil(notifier) {
|
||||
return operate((source, subscriber) => {
|
||||
innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
|
||||
!subscriber.closed && source.subscribe(subscriber);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=takeUntil.js.map
|
||||
@@ -0,0 +1,2 @@
|
||||
if(typeof cptable === 'undefined') cptable = {};
|
||||
cptable[28599] = (function(){ var d = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖרÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ", D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d.charAt(i)] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })();
|
||||
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: ()=>transformThemeValue
|
||||
});
|
||||
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
||||
const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("./isPlainObject"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function transformThemeValue(themeSection) {
|
||||
if ([
|
||||
"fontSize",
|
||||
"outline"
|
||||
].includes(themeSection)) {
|
||||
return (value)=>{
|
||||
if (typeof value === "function") value = value({});
|
||||
if (Array.isArray(value)) value = value[0];
|
||||
return value;
|
||||
};
|
||||
}
|
||||
if (themeSection === "fontFamily") {
|
||||
return (value)=>{
|
||||
if (typeof value === "function") value = value({});
|
||||
let families = Array.isArray(value) && (0, _isPlainObject.default)(value[1]) ? value[0] : value;
|
||||
return Array.isArray(families) ? families.join(", ") : families;
|
||||
};
|
||||
}
|
||||
if ([
|
||||
"boxShadow",
|
||||
"transitionProperty",
|
||||
"transitionDuration",
|
||||
"transitionDelay",
|
||||
"transitionTimingFunction",
|
||||
"backgroundImage",
|
||||
"backgroundSize",
|
||||
"backgroundColor",
|
||||
"cursor",
|
||||
"animation"
|
||||
].includes(themeSection)) {
|
||||
return (value)=>{
|
||||
if (typeof value === "function") value = value({});
|
||||
if (Array.isArray(value)) value = value.join(", ");
|
||||
return value;
|
||||
};
|
||||
}
|
||||
// For backwards compatibility reasons, before we switched to underscores
|
||||
// instead of commas for arbitrary values.
|
||||
if ([
|
||||
"gridTemplateColumns",
|
||||
"gridTemplateRows",
|
||||
"objectPosition"
|
||||
].includes(themeSection)) {
|
||||
return (value)=>{
|
||||
if (typeof value === "function") value = value({});
|
||||
if (typeof value === "string") value = _postcss.default.list.comma(value).join(" ");
|
||||
return value;
|
||||
};
|
||||
}
|
||||
return (value, opts = {})=>{
|
||||
if (typeof value === "function") {
|
||||
value = value(opts);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const path = require('path')
|
||||
const mkdir = require('../mkdirs')
|
||||
const jsonFile = require('./jsonfile')
|
||||
|
||||
function outputJsonSync (file, data, options) {
|
||||
const dir = path.dirname(file)
|
||||
|
||||
if (!fs.existsSync(dir)) {
|
||||
mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
jsonFile.writeJsonSync(file, data, options)
|
||||
}
|
||||
|
||||
module.exports = outputJsonSync
|
||||
@@ -0,0 +1,9 @@
|
||||
import { reduce } from './reduce';
|
||||
import { operate } from '../util/lift';
|
||||
var arrReducer = function (arr, value) { return (arr.push(value), arr); };
|
||||
export function toArray() {
|
||||
return operate(function (source, subscriber) {
|
||||
reduce(arrReducer, [])(source).subscribe(subscriber);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=toArray.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"CC","8":"J D E","129":"A B","161":"F"},B:{"1":"N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","129":"C K L G M"},C:{"1":"0 1 2 3 4 5 6 7 8 9 M N O w g 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 h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB","33":"I v J D E F A B C K L G EC FC"},D:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","33":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB"},E:{"1":"F A B C K L G LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","33":"I v J D E HC zB IC JC KC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 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 h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e rB","2":"F PC QC","33":"B C G M N O w g x y RC SC qB AC TC"},G:{"1":"ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","33":"E zB UC BC VC WC XC YC"},H:{"2":"oC"},I:{"1":"f","33":"tB I pC qC rC sC BC tC uC"},J:{"33":"D A"},K:{"1":"B C h qB AC rB","2":"A"},L:{"1":"H"},M:{"1":"H"},N:{"1":"A B"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:4,C:"CSS3 2D Transforms"};
|
||||
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const VERSION = "1.0.4";
|
||||
|
||||
/**
|
||||
* @param octokit Octokit instance
|
||||
* @param options Options passed to Octokit constructor
|
||||
*/
|
||||
|
||||
function requestLog(octokit) {
|
||||
octokit.hook.wrap("request", (request, options) => {
|
||||
octokit.log.debug("request", options);
|
||||
const start = Date.now();
|
||||
const requestOptions = octokit.request.endpoint.parse(options);
|
||||
const path = requestOptions.url.replace(options.baseUrl, "");
|
||||
return request(options).then(response => {
|
||||
octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`);
|
||||
return response;
|
||||
}).catch(error => {
|
||||
octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`);
|
||||
throw error;
|
||||
});
|
||||
});
|
||||
}
|
||||
requestLog.VERSION = VERSION;
|
||||
|
||||
exports.requestLog = requestLog;
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "is-unicode-supported",
|
||||
"version": "1.3.0",
|
||||
"description": "Detect whether the terminal supports Unicode",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-unicode-supported",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"terminal",
|
||||
"unicode",
|
||||
"detect",
|
||||
"utf8",
|
||||
"console",
|
||||
"shell",
|
||||
"support",
|
||||
"supports",
|
||||
"supported",
|
||||
"check",
|
||||
"detection"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^4.0.1",
|
||||
"tsd": "^0.19.1",
|
||||
"xo": "^0.47.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fromEventPattern.js","sourceRoot":"","sources":["../../../../src/internal/observable/fromEventPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAyI5D,MAAM,UAAU,gBAAgB,CAC9B,UAA8C,EAC9C,aAAiE,EACjE,cAAsC;IAEtC,IAAI,cAAc,EAAE;QAClB,OAAO,gBAAgB,CAAI,UAAU,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;KAC9F;IAED,OAAO,IAAI,UAAU,CAAU,CAAC,UAAU,EAAE,EAAE;QAC5C,MAAM,OAAO,GAAG,CAAC,GAAG,CAAM,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,141 @@
|
||||
import { Observable } from '../Observable';
|
||||
|
||||
import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
import { operate } from '../util/lift';
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
export function catchError<T, O extends ObservableInput<any>>(
|
||||
selector: (err: any, caught: Observable<T>) => O
|
||||
): OperatorFunction<T, T | ObservedValueOf<O>>;
|
||||
/* tslint:enable:max-line-length */
|
||||
|
||||
/**
|
||||
* Catches errors on the observable to be handled by returning a new observable or throwing an error.
|
||||
*
|
||||
* <span class="informal">
|
||||
* It only listens to the error channel and ignores notifications.
|
||||
* Handles errors from the source observable, and maps them to a new observable.
|
||||
* The error may also be rethrown, or a new error can be thrown to emit an error from the result.
|
||||
* </span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* This operator handles errors, but forwards along all other events to the resulting observable.
|
||||
* If the source observable terminates with an error, it will map that error to a new observable,
|
||||
* subscribe to it, and forward all of its events to the resulting observable.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Continue with a different Observable when there's an error
|
||||
*
|
||||
* ```ts
|
||||
* import { of, map, catchError } from 'rxjs';
|
||||
*
|
||||
* of(1, 2, 3, 4, 5)
|
||||
* .pipe(
|
||||
* map(n => {
|
||||
* if (n === 4) {
|
||||
* throw 'four!';
|
||||
* }
|
||||
* return n;
|
||||
* }),
|
||||
* catchError(err => of('I', 'II', 'III', 'IV', 'V'))
|
||||
* )
|
||||
* .subscribe(x => console.log(x));
|
||||
* // 1, 2, 3, I, II, III, IV, V
|
||||
* ```
|
||||
*
|
||||
* Retry the caught source Observable again in case of error, similar to `retry()` operator
|
||||
*
|
||||
* ```ts
|
||||
* import { of, map, catchError, take } from 'rxjs';
|
||||
*
|
||||
* of(1, 2, 3, 4, 5)
|
||||
* .pipe(
|
||||
* map(n => {
|
||||
* if (n === 4) {
|
||||
* throw 'four!';
|
||||
* }
|
||||
* return n;
|
||||
* }),
|
||||
* catchError((err, caught) => caught),
|
||||
* take(30)
|
||||
* )
|
||||
* .subscribe(x => console.log(x));
|
||||
* // 1, 2, 3, 1, 2, 3, ...
|
||||
* ```
|
||||
*
|
||||
* Throw a new error when the source Observable throws an error
|
||||
*
|
||||
* ```ts
|
||||
* import { of, map, catchError } from 'rxjs';
|
||||
*
|
||||
* of(1, 2, 3, 4, 5)
|
||||
* .pipe(
|
||||
* map(n => {
|
||||
* if (n === 4) {
|
||||
* throw 'four!';
|
||||
* }
|
||||
* return n;
|
||||
* }),
|
||||
* catchError(err => {
|
||||
* throw 'error in source. Details: ' + err;
|
||||
* })
|
||||
* )
|
||||
* .subscribe({
|
||||
* next: x => console.log(x),
|
||||
* error: err => console.log(err)
|
||||
* });
|
||||
* // 1, 2, 3, error in source. Details: four!
|
||||
* ```
|
||||
*
|
||||
* @see {@link onErrorResumeNext}
|
||||
* @see {@link repeat}
|
||||
* @see {@link repeatWhen}
|
||||
* @see {@link retry }
|
||||
* @see {@link retryWhen}
|
||||
*
|
||||
* @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
|
||||
* is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
|
||||
* is returned by the `selector` will be used to continue the observable chain.
|
||||
* @return A function that returns an Observable that originates from either
|
||||
* the source or the Observable returned by the `selector` function.
|
||||
*/
|
||||
export function catchError<T, O extends ObservableInput<any>>(
|
||||
selector: (err: any, caught: Observable<T>) => O
|
||||
): OperatorFunction<T, T | ObservedValueOf<O>> {
|
||||
return operate((source, subscriber) => {
|
||||
let innerSub: Subscription | null = null;
|
||||
let syncUnsub = false;
|
||||
let handledResult: Observable<ObservedValueOf<O>>;
|
||||
|
||||
innerSub = source.subscribe(
|
||||
createOperatorSubscriber(subscriber, undefined, undefined, (err) => {
|
||||
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
||||
if (innerSub) {
|
||||
innerSub.unsubscribe();
|
||||
innerSub = null;
|
||||
handledResult.subscribe(subscriber);
|
||||
} else {
|
||||
// We don't have an innerSub yet, that means the error was synchronous
|
||||
// because the subscribe call hasn't returned yet.
|
||||
syncUnsub = true;
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
if (syncUnsub) {
|
||||
// We have a synchronous error, we need to make sure to
|
||||
// finalize right away. This ensures that callbacks in the `finalize` operator are called
|
||||
// at the right time, and that finalization occurs at the expected
|
||||
// time between the source error and the subscription to the
|
||||
// next observable.
|
||||
innerSub.unsubscribe();
|
||||
innerSub = null;
|
||||
handledResult!.subscribe(subscriber);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import TemplateScope from './shared/TemplateScope';
|
||||
import AbstractBlock from './shared/AbstractBlock';
|
||||
import AwaitBlock from './AwaitBlock';
|
||||
import Component from '../Component';
|
||||
import { TemplateNode } from '../../interfaces';
|
||||
import ConstTag from './ConstTag';
|
||||
export default class CatchBlock extends AbstractBlock {
|
||||
type: 'CatchBlock';
|
||||
scope: TemplateScope;
|
||||
const_tags: ConstTag[];
|
||||
constructor(component: Component, parent: AwaitBlock, scope: TemplateScope, info: TemplateNode);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef {{
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
}} WalkerContext */
|
||||
export class WalkerBase {
|
||||
/** @type {boolean} */
|
||||
should_skip: boolean;
|
||||
/** @type {boolean} */
|
||||
should_remove: boolean;
|
||||
/** @type {BaseNode | null} */
|
||||
replacement: BaseNode | null;
|
||||
/** @type {WalkerContext} */
|
||||
context: WalkerContext;
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
* @param {BaseNode} node
|
||||
*/
|
||||
replace(parent: any, prop: string, index: number, node: import("estree").BaseNode): void;
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
*/
|
||||
remove(parent: any, prop: string, index: number): void;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CASvD;AAED,wBAAgB,eAAe,CAC7B,QAAQ,SAAS,MAAM,EACvB,QAAQ,SAAS,MAAM,EACvB,KAAK,SAAS,MAAM,QAAQ,EAE5B,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAOpC;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,SAAS,MAAM,EACvB,QAAQ,SAAS,MAAM,EACvB,CAAC,SAAS,MAAM,QAAQ,EAExB,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAKtC;AAED,wBAAgB,eAAe,CAC7B,QAAQ,SAAS,MAAM,EACvB,QAAQ,SAAS,MAAM,EACvB,KAAK,SAAS,MAAM,QAAQ,EAE5B,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,KAAK,GACX,QAAQ,CAAC,KAAK,CAAC,CAEjB;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,SAAS,MAAM,EACvB,QAAQ,SAAS,MAAM,EACvB,KAAK,SAAS,MAAM,QAAQ,EAE5B,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,EAAE,EAAE,QAAQ,EACZ,GAAG,MAAM,EAAE,KAAK,EAAE,GACjB,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CASvB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,GACxD,WAAW,IAAI,WAAW,CAE5B;AAYD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAC,KAAK,EAAC,EAAE;IAAC,KAAK,EAAE,GAAG,CAAA;CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,QAQtC;AAED,eAAO,MAAM,gCAAgC,QAA4B,CAAA;AAEzE,wBAAgB,SAAS,CACvB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,GAAW,GACf,OAAO,CAAC,SAAS,CAInB"}
|
||||
@@ -0,0 +1,39 @@
|
||||
var os = require('os');
|
||||
var common = require('./common');
|
||||
|
||||
common.register('cd', _cd, {});
|
||||
|
||||
//@
|
||||
//@ ### cd([dir])
|
||||
//@
|
||||
//@ Changes to directory `dir` for the duration of the script. Changes to home
|
||||
//@ directory if no argument is supplied.
|
||||
function _cd(options, dir) {
|
||||
if (!dir) dir = os.homedir();
|
||||
|
||||
if (dir === '-') {
|
||||
if (!process.env.OLDPWD) {
|
||||
common.error('could not find previous directory');
|
||||
} else {
|
||||
dir = process.env.OLDPWD;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var curDir = process.cwd();
|
||||
process.chdir(dir);
|
||||
process.env.OLDPWD = curDir;
|
||||
} catch (e) {
|
||||
// something went wrong, let's figure out the error
|
||||
var err;
|
||||
try {
|
||||
common.statFollowLinks(dir); // if this succeeds, it must be some sort of file
|
||||
err = 'not a directory: ' + dir;
|
||||
} catch (e2) {
|
||||
err = 'no such file or directory: ' + dir;
|
||||
}
|
||||
if (err) common.error(err);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
module.exports = _cd;
|
||||
@@ -0,0 +1,91 @@
|
||||
# wrap-ansi
|
||||
|
||||
> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install wrap-ansi
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
import wrapAnsi from 'wrap-ansi';
|
||||
|
||||
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
|
||||
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
||||
|
||||
console.log(wrapAnsi(input, 20));
|
||||
```
|
||||
|
||||
<img width="331" src="screenshot.png">
|
||||
|
||||
## API
|
||||
|
||||
### wrapAnsi(string, columns, options?)
|
||||
|
||||
Wrap words to the specified column width.
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk). Newline characters will be normalized to `\n`.
|
||||
|
||||
#### columns
|
||||
|
||||
Type: `number`
|
||||
|
||||
Number of columns to wrap the text to.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### hard
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
|
||||
|
||||
##### wordWrap
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
|
||||
|
||||
##### trim
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
|
||||
|
||||
## Related
|
||||
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
- [Benjamin Coe](https://github.com/bcoe)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-wrap_ansi?utm_source=npm-wrap-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Subscription } from '../Subscription';
|
||||
|
||||
interface AnimationFrameProvider {
|
||||
schedule(callback: FrameRequestCallback): Subscription;
|
||||
requestAnimationFrame: typeof requestAnimationFrame;
|
||||
cancelAnimationFrame: typeof cancelAnimationFrame;
|
||||
delegate:
|
||||
| {
|
||||
requestAnimationFrame: typeof requestAnimationFrame;
|
||||
cancelAnimationFrame: typeof cancelAnimationFrame;
|
||||
}
|
||||
| undefined;
|
||||
}
|
||||
|
||||
export const animationFrameProvider: AnimationFrameProvider = {
|
||||
// When accessing the delegate, use the variable rather than `this` so that
|
||||
// the functions can be called without being bound to the provider.
|
||||
schedule(callback) {
|
||||
let request = requestAnimationFrame;
|
||||
let cancel: typeof cancelAnimationFrame | undefined = cancelAnimationFrame;
|
||||
const { delegate } = animationFrameProvider;
|
||||
if (delegate) {
|
||||
request = delegate.requestAnimationFrame;
|
||||
cancel = delegate.cancelAnimationFrame;
|
||||
}
|
||||
const handle = request((timestamp) => {
|
||||
// Clear the cancel function. The request has been fulfilled, so
|
||||
// attempting to cancel the request upon unsubscription would be
|
||||
// pointless.
|
||||
cancel = undefined;
|
||||
callback(timestamp);
|
||||
});
|
||||
return new Subscription(() => cancel?.(handle));
|
||||
},
|
||||
requestAnimationFrame(...args) {
|
||||
const { delegate } = animationFrameProvider;
|
||||
return (delegate?.requestAnimationFrame || requestAnimationFrame)(...args);
|
||||
},
|
||||
cancelAnimationFrame(...args) {
|
||||
const { delegate } = animationFrameProvider;
|
||||
return (delegate?.cancelAnimationFrame || cancelAnimationFrame)(...args);
|
||||
},
|
||||
delegate: undefined,
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("chai").assert
|
||||
, ensureInteger = require("../../integer/ensure");
|
||||
|
||||
describe("integer/ensure", function () {
|
||||
it("Should return coerced value", function () { assert.equal(ensureInteger("12.23"), 12); });
|
||||
it("Should crash on no value", function () {
|
||||
try {
|
||||
ensureInteger(null);
|
||||
throw new Error("Unexpected");
|
||||
} catch (error) {
|
||||
assert.equal(error.name, "TypeError");
|
||||
assert.equal(error.message, "null is not an integer");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"camelcase-css","version":"2.0.1","files":{"license":{"checkedAt":1678883670354,"integrity":"sha512-HMDVUVCfHxEiArXcZhHn0Xzu98yD+WIhEPUiuszu26RYskhY8mQHn/Ht9RgDohKsKOZlVlmTuOhPLTp5yo57xw==","mode":420,"size":1111},"index-es5.js":{"checkedAt":1678883673219,"integrity":"sha512-Ea90SIFp9DSf5iXTrVMQ56Cvf9LVuDhdCmsNRuk/DuMnbHCiKandMGjDWkVKtHl1y6FiH4U5MD2MGBuZmWUXvw==","mode":420,"size":674},"package.json":{"checkedAt":1678883673219,"integrity":"sha512-MREmi17rp8NEGQFARjJXSZeCveOJagLKaXGhHPI0tZrGsP/15Ds8rY4gwaUV6EVZN/BmI23wLTK2cmTVa6yeuQ==","mode":420,"size":860},"index.js":{"checkedAt":1678883673219,"integrity":"sha512-v2+7AMNrvZDx9Oj8khcM457suh7ZEwWZnhmj1Ik5WD/oyiZDNXLdZXxQoI0d2X6lfbg7DtYt1PYpVc1+q0xW1A==","mode":420,"size":536},"README.md":{"checkedAt":1678883673222,"integrity":"sha512-bkwt7jF2oE50zoaY0noAQEPZOeA5fvmmL/JMPn/TLBjGQvIikHUhx0NWyW8PBGM6HJMAmylyy/X2BFx3B5ZeOA==","mode":420,"size":870}}}
|
||||
@@ -0,0 +1,2 @@
|
||||
if(typeof cptable === 'undefined') cptable = {};
|
||||
cptable[28591] = (function(){ var d = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d.charAt(i)] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })();
|
||||
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _container = _interopRequireDefault(require("./container"));
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
var Pseudo = /*#__PURE__*/function (_Container) {
|
||||
_inheritsLoose(Pseudo, _Container);
|
||||
|
||||
function Pseudo(opts) {
|
||||
var _this;
|
||||
|
||||
_this = _Container.call(this, opts) || this;
|
||||
_this.type = _types.PSEUDO;
|
||||
return _this;
|
||||
}
|
||||
|
||||
var _proto = Pseudo.prototype;
|
||||
|
||||
_proto.toString = function toString() {
|
||||
var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
|
||||
return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
|
||||
};
|
||||
|
||||
return Pseudo;
|
||||
}(_container["default"]);
|
||||
|
||||
exports["default"] = Pseudo;
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,819 @@
|
||||
"use strict";
|
||||
module.exports = function() {
|
||||
var makeSelfResolutionError = function () {
|
||||
return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
};
|
||||
var reflectHandler = function() {
|
||||
return new Promise.PromiseInspection(this._target());
|
||||
};
|
||||
var apiRejection = function(msg) {
|
||||
return Promise.reject(new TypeError(msg));
|
||||
};
|
||||
function Proxyable() {}
|
||||
var UNDEFINED_BINDING = {};
|
||||
var util = require("./util");
|
||||
util.setReflectHandler(reflectHandler);
|
||||
|
||||
var getDomain = function() {
|
||||
var domain = process.domain;
|
||||
if (domain === undefined) {
|
||||
return null;
|
||||
}
|
||||
return domain;
|
||||
};
|
||||
var getContextDefault = function() {
|
||||
return null;
|
||||
};
|
||||
var getContextDomain = function() {
|
||||
return {
|
||||
domain: getDomain(),
|
||||
async: null
|
||||
};
|
||||
};
|
||||
var AsyncResource = util.isNode && util.nodeSupportsAsyncResource ?
|
||||
require("async_hooks").AsyncResource : null;
|
||||
var getContextAsyncHooks = function() {
|
||||
return {
|
||||
domain: getDomain(),
|
||||
async: new AsyncResource("Bluebird::Promise")
|
||||
};
|
||||
};
|
||||
var getContext = util.isNode ? getContextDomain : getContextDefault;
|
||||
util.notEnumerableProp(Promise, "_getContext", getContext);
|
||||
var enableAsyncHooks = function() {
|
||||
getContext = getContextAsyncHooks;
|
||||
util.notEnumerableProp(Promise, "_getContext", getContextAsyncHooks);
|
||||
};
|
||||
var disableAsyncHooks = function() {
|
||||
getContext = getContextDomain;
|
||||
util.notEnumerableProp(Promise, "_getContext", getContextDomain);
|
||||
};
|
||||
|
||||
var es5 = require("./es5");
|
||||
var Async = require("./async");
|
||||
var async = new Async();
|
||||
es5.defineProperty(Promise, "_async", {value: async});
|
||||
var errors = require("./errors");
|
||||
var TypeError = Promise.TypeError = errors.TypeError;
|
||||
Promise.RangeError = errors.RangeError;
|
||||
var CancellationError = Promise.CancellationError = errors.CancellationError;
|
||||
Promise.TimeoutError = errors.TimeoutError;
|
||||
Promise.OperationalError = errors.OperationalError;
|
||||
Promise.RejectionError = errors.OperationalError;
|
||||
Promise.AggregateError = errors.AggregateError;
|
||||
var INTERNAL = function(){};
|
||||
var APPLY = {};
|
||||
var NEXT_FILTER = {};
|
||||
var tryConvertToPromise = require("./thenables")(Promise, INTERNAL);
|
||||
var PromiseArray =
|
||||
require("./promise_array")(Promise, INTERNAL,
|
||||
tryConvertToPromise, apiRejection, Proxyable);
|
||||
var Context = require("./context")(Promise);
|
||||
/*jshint unused:false*/
|
||||
var createContext = Context.create;
|
||||
|
||||
var debug = require("./debuggability")(Promise, Context,
|
||||
enableAsyncHooks, disableAsyncHooks);
|
||||
var CapturedTrace = debug.CapturedTrace;
|
||||
var PassThroughHandlerContext =
|
||||
require("./finally")(Promise, tryConvertToPromise, NEXT_FILTER);
|
||||
var catchFilter = require("./catch_filter")(NEXT_FILTER);
|
||||
var nodebackForPromise = require("./nodeback");
|
||||
var errorObj = util.errorObj;
|
||||
var tryCatch = util.tryCatch;
|
||||
function check(self, executor) {
|
||||
if (self == null || self.constructor !== Promise) {
|
||||
throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
if (typeof executor !== "function") {
|
||||
throw new TypeError("expecting a function but got " + util.classString(executor));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Promise(executor) {
|
||||
if (executor !== INTERNAL) {
|
||||
check(this, executor);
|
||||
}
|
||||
this._bitField = 0;
|
||||
this._fulfillmentHandler0 = undefined;
|
||||
this._rejectionHandler0 = undefined;
|
||||
this._promise0 = undefined;
|
||||
this._receiver0 = undefined;
|
||||
this._resolveFromExecutor(executor);
|
||||
this._promiseCreated();
|
||||
this._fireEvent("promiseCreated", this);
|
||||
}
|
||||
|
||||
Promise.prototype.toString = function () {
|
||||
return "[object Promise]";
|
||||
};
|
||||
|
||||
Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
|
||||
var len = arguments.length;
|
||||
if (len > 1) {
|
||||
var catchInstances = new Array(len - 1),
|
||||
j = 0, i;
|
||||
for (i = 0; i < len - 1; ++i) {
|
||||
var item = arguments[i];
|
||||
if (util.isObject(item)) {
|
||||
catchInstances[j++] = item;
|
||||
} else {
|
||||
return apiRejection("Catch statement predicate: " +
|
||||
"expecting an object but got " + util.classString(item));
|
||||
}
|
||||
}
|
||||
catchInstances.length = j;
|
||||
fn = arguments[i];
|
||||
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError("The last argument to .catch() " +
|
||||
"must be a function, got " + util.toString(fn));
|
||||
}
|
||||
return this.then(undefined, catchFilter(catchInstances, fn, this));
|
||||
}
|
||||
return this.then(undefined, fn);
|
||||
};
|
||||
|
||||
Promise.prototype.reflect = function () {
|
||||
return this._then(reflectHandler,
|
||||
reflectHandler, undefined, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.then = function (didFulfill, didReject) {
|
||||
if (debug.warnings() && arguments.length > 0 &&
|
||||
typeof didFulfill !== "function" &&
|
||||
typeof didReject !== "function") {
|
||||
var msg = ".then() only accepts functions but was passed: " +
|
||||
util.classString(didFulfill);
|
||||
if (arguments.length > 1) {
|
||||
msg += ", " + util.classString(didReject);
|
||||
}
|
||||
this._warn(msg);
|
||||
}
|
||||
return this._then(didFulfill, didReject, undefined, undefined, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.done = function (didFulfill, didReject) {
|
||||
var promise =
|
||||
this._then(didFulfill, didReject, undefined, undefined, undefined);
|
||||
promise._setIsFinal();
|
||||
};
|
||||
|
||||
Promise.prototype.spread = function (fn) {
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
return this.all()._then(fn, undefined, undefined, APPLY, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.toJSON = function () {
|
||||
var ret = {
|
||||
isFulfilled: false,
|
||||
isRejected: false,
|
||||
fulfillmentValue: undefined,
|
||||
rejectionReason: undefined
|
||||
};
|
||||
if (this.isFulfilled()) {
|
||||
ret.fulfillmentValue = this.value();
|
||||
ret.isFulfilled = true;
|
||||
} else if (this.isRejected()) {
|
||||
ret.rejectionReason = this.reason();
|
||||
ret.isRejected = true;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype.all = function () {
|
||||
if (arguments.length > 0) {
|
||||
this._warn(".all() was passed arguments but it does not take any");
|
||||
}
|
||||
return new PromiseArray(this).promise();
|
||||
};
|
||||
|
||||
Promise.prototype.error = function (fn) {
|
||||
return this.caught(util.originatesFromRejection, fn);
|
||||
};
|
||||
|
||||
Promise.getNewLibraryCopy = module.exports;
|
||||
|
||||
Promise.is = function (val) {
|
||||
return val instanceof Promise;
|
||||
};
|
||||
|
||||
Promise.fromNode = Promise.fromCallback = function(fn) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
|
||||
: false;
|
||||
var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
|
||||
if (result === errorObj) {
|
||||
ret._rejectCallback(result.e, true);
|
||||
}
|
||||
if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.all = function (promises) {
|
||||
return new PromiseArray(promises).promise();
|
||||
};
|
||||
|
||||
Promise.cast = function (obj) {
|
||||
var ret = tryConvertToPromise(obj);
|
||||
if (!(ret instanceof Promise)) {
|
||||
ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._setFulfilled();
|
||||
ret._rejectionHandler0 = obj;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.resolve = Promise.fulfilled = Promise.cast;
|
||||
|
||||
Promise.reject = Promise.rejected = function (reason) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._rejectCallback(reason, true);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.setScheduler = function(fn) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
return async.setScheduler(fn);
|
||||
};
|
||||
|
||||
Promise.prototype._then = function (
|
||||
didFulfill,
|
||||
didReject,
|
||||
_, receiver,
|
||||
internalData
|
||||
) {
|
||||
var haveInternalData = internalData !== undefined;
|
||||
var promise = haveInternalData ? internalData : new Promise(INTERNAL);
|
||||
var target = this._target();
|
||||
var bitField = target._bitField;
|
||||
|
||||
if (!haveInternalData) {
|
||||
promise._propagateFrom(this, 3);
|
||||
promise._captureStackTrace();
|
||||
if (receiver === undefined &&
|
||||
((this._bitField & 2097152) !== 0)) {
|
||||
if (!((bitField & 50397184) === 0)) {
|
||||
receiver = this._boundValue();
|
||||
} else {
|
||||
receiver = target === this ? undefined : this._boundTo;
|
||||
}
|
||||
}
|
||||
this._fireEvent("promiseChained", this, promise);
|
||||
}
|
||||
|
||||
var context = getContext();
|
||||
if (!((bitField & 50397184) === 0)) {
|
||||
var handler, value, settler = target._settlePromiseCtx;
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
value = target._rejectionHandler0;
|
||||
handler = didFulfill;
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
value = target._fulfillmentHandler0;
|
||||
handler = didReject;
|
||||
target._unsetRejectionIsUnhandled();
|
||||
} else {
|
||||
settler = target._settlePromiseLateCancellationObserver;
|
||||
value = new CancellationError("late cancellation observer");
|
||||
target._attachExtraTrace(value);
|
||||
handler = didReject;
|
||||
}
|
||||
|
||||
async.invoke(settler, target, {
|
||||
handler: util.contextBind(context, handler),
|
||||
promise: promise,
|
||||
receiver: receiver,
|
||||
value: value
|
||||
});
|
||||
} else {
|
||||
target._addCallbacks(didFulfill, didReject, promise,
|
||||
receiver, context);
|
||||
}
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
Promise.prototype._length = function () {
|
||||
return this._bitField & 65535;
|
||||
};
|
||||
|
||||
Promise.prototype._isFateSealed = function () {
|
||||
return (this._bitField & 117506048) !== 0;
|
||||
};
|
||||
|
||||
Promise.prototype._isFollowing = function () {
|
||||
return (this._bitField & 67108864) === 67108864;
|
||||
};
|
||||
|
||||
Promise.prototype._setLength = function (len) {
|
||||
this._bitField = (this._bitField & -65536) |
|
||||
(len & 65535);
|
||||
};
|
||||
|
||||
Promise.prototype._setFulfilled = function () {
|
||||
this._bitField = this._bitField | 33554432;
|
||||
this._fireEvent("promiseFulfilled", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setRejected = function () {
|
||||
this._bitField = this._bitField | 16777216;
|
||||
this._fireEvent("promiseRejected", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setFollowing = function () {
|
||||
this._bitField = this._bitField | 67108864;
|
||||
this._fireEvent("promiseResolved", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setIsFinal = function () {
|
||||
this._bitField = this._bitField | 4194304;
|
||||
};
|
||||
|
||||
Promise.prototype._isFinal = function () {
|
||||
return (this._bitField & 4194304) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetCancelled = function() {
|
||||
this._bitField = this._bitField & (~65536);
|
||||
};
|
||||
|
||||
Promise.prototype._setCancelled = function() {
|
||||
this._bitField = this._bitField | 65536;
|
||||
this._fireEvent("promiseCancelled", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setWillBeCancelled = function() {
|
||||
this._bitField = this._bitField | 8388608;
|
||||
};
|
||||
|
||||
Promise.prototype._setAsyncGuaranteed = function() {
|
||||
if (async.hasCustomScheduler()) return;
|
||||
var bitField = this._bitField;
|
||||
this._bitField = bitField |
|
||||
(((bitField & 536870912) >> 2) ^
|
||||
134217728);
|
||||
};
|
||||
|
||||
Promise.prototype._setNoAsyncGuarantee = function() {
|
||||
this._bitField = (this._bitField | 536870912) &
|
||||
(~134217728);
|
||||
};
|
||||
|
||||
Promise.prototype._receiverAt = function (index) {
|
||||
var ret = index === 0 ? this._receiver0 : this[
|
||||
index * 4 - 4 + 3];
|
||||
if (ret === UNDEFINED_BINDING) {
|
||||
return undefined;
|
||||
} else if (ret === undefined && this._isBound()) {
|
||||
return this._boundValue();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._promiseAt = function (index) {
|
||||
return this[
|
||||
index * 4 - 4 + 2];
|
||||
};
|
||||
|
||||
Promise.prototype._fulfillmentHandlerAt = function (index) {
|
||||
return this[
|
||||
index * 4 - 4 + 0];
|
||||
};
|
||||
|
||||
Promise.prototype._rejectionHandlerAt = function (index) {
|
||||
return this[
|
||||
index * 4 - 4 + 1];
|
||||
};
|
||||
|
||||
Promise.prototype._boundValue = function() {};
|
||||
|
||||
Promise.prototype._migrateCallback0 = function (follower) {
|
||||
var bitField = follower._bitField;
|
||||
var fulfill = follower._fulfillmentHandler0;
|
||||
var reject = follower._rejectionHandler0;
|
||||
var promise = follower._promise0;
|
||||
var receiver = follower._receiverAt(0);
|
||||
if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
||||
this._addCallbacks(fulfill, reject, promise, receiver, null);
|
||||
};
|
||||
|
||||
Promise.prototype._migrateCallbackAt = function (follower, index) {
|
||||
var fulfill = follower._fulfillmentHandlerAt(index);
|
||||
var reject = follower._rejectionHandlerAt(index);
|
||||
var promise = follower._promiseAt(index);
|
||||
var receiver = follower._receiverAt(index);
|
||||
if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
||||
this._addCallbacks(fulfill, reject, promise, receiver, null);
|
||||
};
|
||||
|
||||
Promise.prototype._addCallbacks = function (
|
||||
fulfill,
|
||||
reject,
|
||||
promise,
|
||||
receiver,
|
||||
context
|
||||
) {
|
||||
var index = this._length();
|
||||
|
||||
if (index >= 65535 - 4) {
|
||||
index = 0;
|
||||
this._setLength(0);
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
this._promise0 = promise;
|
||||
this._receiver0 = receiver;
|
||||
if (typeof fulfill === "function") {
|
||||
this._fulfillmentHandler0 = util.contextBind(context, fulfill);
|
||||
}
|
||||
if (typeof reject === "function") {
|
||||
this._rejectionHandler0 = util.contextBind(context, reject);
|
||||
}
|
||||
} else {
|
||||
var base = index * 4 - 4;
|
||||
this[base + 2] = promise;
|
||||
this[base + 3] = receiver;
|
||||
if (typeof fulfill === "function") {
|
||||
this[base + 0] =
|
||||
util.contextBind(context, fulfill);
|
||||
}
|
||||
if (typeof reject === "function") {
|
||||
this[base + 1] =
|
||||
util.contextBind(context, reject);
|
||||
}
|
||||
}
|
||||
this._setLength(index + 1);
|
||||
return index;
|
||||
};
|
||||
|
||||
Promise.prototype._proxy = function (proxyable, arg) {
|
||||
this._addCallbacks(undefined, undefined, arg, proxyable, null);
|
||||
};
|
||||
|
||||
Promise.prototype._resolveCallback = function(value, shouldBind) {
|
||||
if (((this._bitField & 117506048) !== 0)) return;
|
||||
if (value === this)
|
||||
return this._rejectCallback(makeSelfResolutionError(), false);
|
||||
var maybePromise = tryConvertToPromise(value, this);
|
||||
if (!(maybePromise instanceof Promise)) return this._fulfill(value);
|
||||
|
||||
if (shouldBind) this._propagateFrom(maybePromise, 2);
|
||||
|
||||
|
||||
var promise = maybePromise._target();
|
||||
|
||||
if (promise === this) {
|
||||
this._reject(makeSelfResolutionError());
|
||||
return;
|
||||
}
|
||||
|
||||
var bitField = promise._bitField;
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
var len = this._length();
|
||||
if (len > 0) promise._migrateCallback0(this);
|
||||
for (var i = 1; i < len; ++i) {
|
||||
promise._migrateCallbackAt(this, i);
|
||||
}
|
||||
this._setFollowing();
|
||||
this._setLength(0);
|
||||
this._setFollowee(maybePromise);
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
this._fulfill(promise._value());
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
this._reject(promise._reason());
|
||||
} else {
|
||||
var reason = new CancellationError("late cancellation observer");
|
||||
promise._attachExtraTrace(reason);
|
||||
this._reject(reason);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._rejectCallback =
|
||||
function(reason, synchronous, ignoreNonErrorWarnings) {
|
||||
var trace = util.ensureErrorObject(reason);
|
||||
var hasStack = trace === reason;
|
||||
if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
|
||||
var message = "a promise was rejected with a non-error: " +
|
||||
util.classString(reason);
|
||||
this._warn(message, true);
|
||||
}
|
||||
this._attachExtraTrace(trace, synchronous ? hasStack : false);
|
||||
this._reject(reason);
|
||||
};
|
||||
|
||||
Promise.prototype._resolveFromExecutor = function (executor) {
|
||||
if (executor === INTERNAL) return;
|
||||
var promise = this;
|
||||
this._captureStackTrace();
|
||||
this._pushContext();
|
||||
var synchronous = true;
|
||||
var r = this._execute(executor, function(value) {
|
||||
promise._resolveCallback(value);
|
||||
}, function (reason) {
|
||||
promise._rejectCallback(reason, synchronous);
|
||||
});
|
||||
synchronous = false;
|
||||
this._popContext();
|
||||
|
||||
if (r !== undefined) {
|
||||
promise._rejectCallback(r, true);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseFromHandler = function (
|
||||
handler, receiver, value, promise
|
||||
) {
|
||||
var bitField = promise._bitField;
|
||||
if (((bitField & 65536) !== 0)) return;
|
||||
promise._pushContext();
|
||||
var x;
|
||||
if (receiver === APPLY) {
|
||||
if (!value || typeof value.length !== "number") {
|
||||
x = errorObj;
|
||||
x.e = new TypeError("cannot .spread() a non-array: " +
|
||||
util.classString(value));
|
||||
} else {
|
||||
x = tryCatch(handler).apply(this._boundValue(), value);
|
||||
}
|
||||
} else {
|
||||
x = tryCatch(handler).call(receiver, value);
|
||||
}
|
||||
var promiseCreated = promise._popContext();
|
||||
bitField = promise._bitField;
|
||||
if (((bitField & 65536) !== 0)) return;
|
||||
|
||||
if (x === NEXT_FILTER) {
|
||||
promise._reject(value);
|
||||
} else if (x === errorObj) {
|
||||
promise._rejectCallback(x.e, false);
|
||||
} else {
|
||||
debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
|
||||
promise._resolveCallback(x);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._target = function() {
|
||||
var ret = this;
|
||||
while (ret._isFollowing()) ret = ret._followee();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._followee = function() {
|
||||
return this._rejectionHandler0;
|
||||
};
|
||||
|
||||
Promise.prototype._setFollowee = function(promise) {
|
||||
this._rejectionHandler0 = promise;
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
|
||||
var isPromise = promise instanceof Promise;
|
||||
var bitField = this._bitField;
|
||||
var asyncGuaranteed = ((bitField & 134217728) !== 0);
|
||||
if (((bitField & 65536) !== 0)) {
|
||||
if (isPromise) promise._invokeInternalOnCancel();
|
||||
|
||||
if (receiver instanceof PassThroughHandlerContext &&
|
||||
receiver.isFinallyHandler()) {
|
||||
receiver.cancelPromise = promise;
|
||||
if (tryCatch(handler).call(receiver, value) === errorObj) {
|
||||
promise._reject(errorObj.e);
|
||||
}
|
||||
} else if (handler === reflectHandler) {
|
||||
promise._fulfill(reflectHandler.call(receiver));
|
||||
} else if (receiver instanceof Proxyable) {
|
||||
receiver._promiseCancelled(promise);
|
||||
} else if (isPromise || promise instanceof PromiseArray) {
|
||||
promise._cancel();
|
||||
} else {
|
||||
receiver.cancel();
|
||||
}
|
||||
} else if (typeof handler === "function") {
|
||||
if (!isPromise) {
|
||||
handler.call(receiver, value, promise);
|
||||
} else {
|
||||
if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
||||
}
|
||||
} else if (receiver instanceof Proxyable) {
|
||||
if (!receiver._isResolved()) {
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
receiver._promiseFulfilled(value, promise);
|
||||
} else {
|
||||
receiver._promiseRejected(value, promise);
|
||||
}
|
||||
}
|
||||
} else if (isPromise) {
|
||||
if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
promise._fulfill(value);
|
||||
} else {
|
||||
promise._reject(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
|
||||
var handler = ctx.handler;
|
||||
var promise = ctx.promise;
|
||||
var receiver = ctx.receiver;
|
||||
var value = ctx.value;
|
||||
if (typeof handler === "function") {
|
||||
if (!(promise instanceof Promise)) {
|
||||
handler.call(receiver, value, promise);
|
||||
} else {
|
||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
||||
}
|
||||
} else if (promise instanceof Promise) {
|
||||
promise._reject(value);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseCtx = function(ctx) {
|
||||
this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromise0 = function(handler, value, bitField) {
|
||||
var promise = this._promise0;
|
||||
var receiver = this._receiverAt(0);
|
||||
this._promise0 = undefined;
|
||||
this._receiver0 = undefined;
|
||||
this._settlePromise(promise, handler, receiver, value);
|
||||
};
|
||||
|
||||
Promise.prototype._clearCallbackDataAtIndex = function(index) {
|
||||
var base = index * 4 - 4;
|
||||
this[base + 2] =
|
||||
this[base + 3] =
|
||||
this[base + 0] =
|
||||
this[base + 1] = undefined;
|
||||
};
|
||||
|
||||
Promise.prototype._fulfill = function (value) {
|
||||
var bitField = this._bitField;
|
||||
if (((bitField & 117506048) >>> 16)) return;
|
||||
if (value === this) {
|
||||
var err = makeSelfResolutionError();
|
||||
this._attachExtraTrace(err);
|
||||
return this._reject(err);
|
||||
}
|
||||
this._setFulfilled();
|
||||
this._rejectionHandler0 = value;
|
||||
|
||||
if ((bitField & 65535) > 0) {
|
||||
if (((bitField & 134217728) !== 0)) {
|
||||
this._settlePromises();
|
||||
} else {
|
||||
async.settlePromises(this);
|
||||
}
|
||||
this._dereferenceTrace();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._reject = function (reason) {
|
||||
var bitField = this._bitField;
|
||||
if (((bitField & 117506048) >>> 16)) return;
|
||||
this._setRejected();
|
||||
this._fulfillmentHandler0 = reason;
|
||||
|
||||
if (this._isFinal()) {
|
||||
return async.fatalError(reason, util.isNode);
|
||||
}
|
||||
|
||||
if ((bitField & 65535) > 0) {
|
||||
async.settlePromises(this);
|
||||
} else {
|
||||
this._ensurePossibleRejectionHandled();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._fulfillPromises = function (len, value) {
|
||||
for (var i = 1; i < len; i++) {
|
||||
var handler = this._fulfillmentHandlerAt(i);
|
||||
var promise = this._promiseAt(i);
|
||||
var receiver = this._receiverAt(i);
|
||||
this._clearCallbackDataAtIndex(i);
|
||||
this._settlePromise(promise, handler, receiver, value);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._rejectPromises = function (len, reason) {
|
||||
for (var i = 1; i < len; i++) {
|
||||
var handler = this._rejectionHandlerAt(i);
|
||||
var promise = this._promiseAt(i);
|
||||
var receiver = this._receiverAt(i);
|
||||
this._clearCallbackDataAtIndex(i);
|
||||
this._settlePromise(promise, handler, receiver, reason);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromises = function () {
|
||||
var bitField = this._bitField;
|
||||
var len = (bitField & 65535);
|
||||
|
||||
if (len > 0) {
|
||||
if (((bitField & 16842752) !== 0)) {
|
||||
var reason = this._fulfillmentHandler0;
|
||||
this._settlePromise0(this._rejectionHandler0, reason, bitField);
|
||||
this._rejectPromises(len, reason);
|
||||
} else {
|
||||
var value = this._rejectionHandler0;
|
||||
this._settlePromise0(this._fulfillmentHandler0, value, bitField);
|
||||
this._fulfillPromises(len, value);
|
||||
}
|
||||
this._setLength(0);
|
||||
}
|
||||
this._clearCancellationData();
|
||||
};
|
||||
|
||||
Promise.prototype._settledValue = function() {
|
||||
var bitField = this._bitField;
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
return this._rejectionHandler0;
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
return this._fulfillmentHandler0;
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
|
||||
es5.defineProperty(Promise.prototype, Symbol.toStringTag, {
|
||||
get: function () {
|
||||
return "Object";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deferResolve(v) {this.promise._resolveCallback(v);}
|
||||
function deferReject(v) {this.promise._rejectCallback(v, false);}
|
||||
|
||||
Promise.defer = Promise.pending = function() {
|
||||
debug.deprecated("Promise.defer", "new Promise");
|
||||
var promise = new Promise(INTERNAL);
|
||||
return {
|
||||
promise: promise,
|
||||
resolve: deferResolve,
|
||||
reject: deferReject
|
||||
};
|
||||
};
|
||||
|
||||
util.notEnumerableProp(Promise,
|
||||
"_makeSelfResolutionError",
|
||||
makeSelfResolutionError);
|
||||
|
||||
require("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
|
||||
debug);
|
||||
require("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
|
||||
require("./cancel")(Promise, PromiseArray, apiRejection, debug);
|
||||
require("./direct_resolve")(Promise);
|
||||
require("./synchronous_inspection")(Promise);
|
||||
require("./join")(
|
||||
Promise, PromiseArray, tryConvertToPromise, INTERNAL, async);
|
||||
Promise.Promise = Promise;
|
||||
Promise.version = "3.7.2";
|
||||
require('./call_get.js')(Promise);
|
||||
require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
|
||||
require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
||||
require('./nodeify.js')(Promise);
|
||||
require('./promisify.js')(Promise, INTERNAL);
|
||||
require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
||||
require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
||||
require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
||||
require('./settle.js')(Promise, PromiseArray, debug);
|
||||
require('./some.js')(Promise, PromiseArray, apiRejection);
|
||||
require('./timers.js')(Promise, INTERNAL, debug);
|
||||
require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
|
||||
require('./any.js')(Promise);
|
||||
require('./each.js')(Promise, INTERNAL);
|
||||
require('./filter.js')(Promise, INTERNAL);
|
||||
|
||||
util.toFastProperties(Promise);
|
||||
util.toFastProperties(Promise.prototype);
|
||||
function fillTypes(value) {
|
||||
var p = new Promise(INTERNAL);
|
||||
p._fulfillmentHandler0 = value;
|
||||
p._rejectionHandler0 = value;
|
||||
p._promise0 = value;
|
||||
p._receiver0 = value;
|
||||
}
|
||||
// Complete slack tracking, opt out of field-type tracking and
|
||||
// stabilize map
|
||||
fillTypes({a: 1});
|
||||
fillTypes({b: 2});
|
||||
fillTypes({c: 3});
|
||||
fillTypes(1);
|
||||
fillTypes(function(){});
|
||||
fillTypes(undefined);
|
||||
fillTypes(false);
|
||||
fillTypes(new Promise(INTERNAL));
|
||||
debug.setBounds(Async.firstLineError, util.lastLineError);
|
||||
return Promise;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user