new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
if(typeof cptable === 'undefined') cptable = {};
|
||||
cptable[1140] = (function(){ var d = "\u0000\u0001\u0002\u0003\t\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013
\b\u0018\u0019\u001c\u001d\u001e\u001f\n\u0017\u001b\u0005\u0006\u0007\u0016\u0004\u0014\u0015\u001a âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);¬-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@'=\"Øabcdefghi«»ðýþ±°jklmnopqrªºæ¸Æ€µ~stuvwxyz¡¿ÐÝÞ®^£¥·©§¶¼½¾[]¯¨´×{ABCDEFGHIôöòóõ}JKLMNOPQR¹ûüùúÿ\\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚ", 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 @@
|
||||
import { MonoTypeOperatorFunction } from '../types';
|
||||
import { EMPTY } from '../observable/empty';
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
|
||||
/**
|
||||
* Emits only the first `count` values emitted by the source Observable.
|
||||
*
|
||||
* <span class="informal">Takes the first `count` values from the source, then
|
||||
* completes.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `take` returns an Observable that emits only the first `count` values emitted
|
||||
* by the source Observable. If the source emits fewer than `count` values then
|
||||
* all of its values are emitted. After that, it completes, regardless if the
|
||||
* source completes.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* Take the first 5 seconds of an infinite 1-second interval Observable
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, take } from 'rxjs';
|
||||
*
|
||||
* const intervalCount = interval(1000);
|
||||
* const takeFive = intervalCount.pipe(take(5));
|
||||
* takeFive.subscribe(x => console.log(x));
|
||||
*
|
||||
* // Logs:
|
||||
* // 0
|
||||
* // 1
|
||||
* // 2
|
||||
* // 3
|
||||
* // 4
|
||||
* ```
|
||||
*
|
||||
* @see {@link takeLast}
|
||||
* @see {@link takeUntil}
|
||||
* @see {@link takeWhile}
|
||||
* @see {@link skip}
|
||||
*
|
||||
* @param count The maximum number of `next` values to emit.
|
||||
* @return A function that returns an Observable that emits only the first
|
||||
* `count` values emitted by the source Observable, or all of the values from
|
||||
* the source if the source emits fewer than `count` values.
|
||||
*/
|
||||
export function take<T>(count: number): MonoTypeOperatorFunction<T> {
|
||||
return count <= 0
|
||||
? // If we are taking no values, that's empty.
|
||||
() => EMPTY
|
||||
: operate((source, subscriber) => {
|
||||
let seen = 0;
|
||||
source.subscribe(
|
||||
createOperatorSubscriber(subscriber, (value) => {
|
||||
// Increment the number of values we have seen,
|
||||
// then check it against the allowed count to see
|
||||
// if we are still letting values through.
|
||||
if (++seen <= count) {
|
||||
subscriber.next(value);
|
||||
// If we have met or passed our allowed count,
|
||||
// we need to complete. We have to do <= here,
|
||||
// because re-entrant code will increment `seen` twice.
|
||||
if (count <= seen) {
|
||||
subscriber.complete();
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./_decimal-adjust")("floor");
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
exports['default'] = function (Handlebars) {
|
||||
/* istanbul ignore next */
|
||||
var root = typeof global !== 'undefined' ? global : window,
|
||||
$Handlebars = root.Handlebars;
|
||||
/* istanbul ignore next */
|
||||
Handlebars.noConflict = function () {
|
||||
if (root.Handlebars === Handlebars) {
|
||||
root.Handlebars = $Handlebars;
|
||||
}
|
||||
return Handlebars;
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = exports['default'];
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL2xpYi9oYW5kbGViYXJzL25vLWNvbmZsaWN0LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7cUJBQWUsVUFBUyxVQUFVLEVBQUU7O0FBRWxDLE1BQUksSUFBSSxHQUFHLE9BQU8sTUFBTSxLQUFLLFdBQVcsR0FBRyxNQUFNLEdBQUcsTUFBTTtNQUN4RCxXQUFXLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQzs7QUFFaEMsWUFBVSxDQUFDLFVBQVUsR0FBRyxZQUFXO0FBQ2pDLFFBQUksSUFBSSxDQUFDLFVBQVUsS0FBSyxVQUFVLEVBQUU7QUFDbEMsVUFBSSxDQUFDLFVBQVUsR0FBRyxXQUFXLENBQUM7S0FDL0I7QUFDRCxXQUFPLFVBQVUsQ0FBQztHQUNuQixDQUFDO0NBQ0giLCJmaWxlIjoibm8tY29uZmxpY3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbihIYW5kbGViYXJzKSB7XG4gIC8qIGlzdGFuYnVsIGlnbm9yZSBuZXh0ICovXG4gIGxldCByb290ID0gdHlwZW9mIGdsb2JhbCAhPT0gJ3VuZGVmaW5lZCcgPyBnbG9iYWwgOiB3aW5kb3csXG4gICAgJEhhbmRsZWJhcnMgPSByb290LkhhbmRsZWJhcnM7XG4gIC8qIGlzdGFuYnVsIGlnbm9yZSBuZXh0ICovXG4gIEhhbmRsZWJhcnMubm9Db25mbGljdCA9IGZ1bmN0aW9uKCkge1xuICAgIGlmIChyb290LkhhbmRsZWJhcnMgPT09IEhhbmRsZWJhcnMpIHtcbiAgICAgIHJvb3QuSGFuZGxlYmFycyA9ICRIYW5kbGViYXJzO1xuICAgIH1cbiAgICByZXR1cm4gSGFuZGxlYmFycztcbiAgfTtcbn1cbiJdfQ==
|
||||
@@ -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":"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":"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 EC FC","132":"KB LB MB","260":"NB OB PB QB"},D:{"1":"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","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","132":"OB PB QB RB","260":"SB TB UB VB WB XB"},E:{"1":"B C K L G 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F A HC zB IC JC KC LC"},F:{"1":"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":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB PC QC RC SC qB AC TC rB","132":"BB CB DB EB","260":"FB GB HB IB JB KB"},G:{"1":"cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC aC","16":"bC"},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 yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I","260":"wC xC"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","260":"AD"}},B:2,C:"IndexedDB 2.0"};
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Generate Changelog
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master]
|
||||
|
||||
jobs:
|
||||
changelog:
|
||||
name: Update Changelog
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Update Changelog
|
||||
uses: AlexxNB/chalogen@master
|
||||
with:
|
||||
title: Tinro Changelog
|
||||
list: feat,fix,perf,docs,other,chore,refactor,test
|
||||
|
||||
- name: Commit Changelog to repository
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: 'docs(Changelog): Update Changelog'
|
||||
file_pattern: CHANGELOG.md
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"max.js","sourceRoot":"","sources":["../../../../src/internal/operators/max.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAElC,iDAAgD;AAgDhD,SAAgB,GAAG,CAAI,QAAiC;IACtD,OAAO,eAAM,CAAC,uBAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAA5B,CAA4B,CAAC,CAAC,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAf,CAAe,CAAC,CAAC;AAC3G,CAAC;AAFD,kBAEC"}
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "ignore",
|
||||
"version": "5.2.4",
|
||||
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
|
||||
"files": [
|
||||
"legacy.js",
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"LICENSE-MIT"
|
||||
],
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build",
|
||||
"build": "babel -o legacy.js index.js",
|
||||
"test:lint": "eslint .",
|
||||
"test:tsc": "tsc ./test/ts/simple.ts --lib ES6",
|
||||
"test:ts": "node ./test/ts/simple.js",
|
||||
"tap": "tap --reporter classic",
|
||||
"test:git": "npm run tap test/git-check-ignore.js",
|
||||
"test:ignore": "npm run tap test/ignore.js",
|
||||
"test:others": "npm run tap test/others.js",
|
||||
"test:cases": "npm run tap test/*.js -- --coverage",
|
||||
"test:no-coverage": "npm run tap test/*.js -- --no-check-coverage",
|
||||
"test:only": "npm run test:lint && npm run test:tsc && npm run test:ts && npm run test:cases",
|
||||
"test": "npm run test:only",
|
||||
"test:win32": "IGNORE_TEST_WIN32=1 npm run test",
|
||||
"report": "tap --coverage-report=html",
|
||||
"posttest": "npm run report && codecov"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:kaelzhang/node-ignore.git"
|
||||
},
|
||||
"keywords": [
|
||||
"ignore",
|
||||
".gitignore",
|
||||
"gitignore",
|
||||
"npmignore",
|
||||
"rules",
|
||||
"manager",
|
||||
"filter",
|
||||
"regexp",
|
||||
"regex",
|
||||
"fnmatch",
|
||||
"glob",
|
||||
"asterisks",
|
||||
"regular-expression"
|
||||
],
|
||||
"author": "kael",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/kaelzhang/node-ignore/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.19.3",
|
||||
"@babel/core": "^7.20.5",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"codecov": "^3.8.2",
|
||||
"debug": "^4.3.4",
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-ostai": "^3.0.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
"pre-suf": "^1.1.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"spawn-sync": "^2.0.0",
|
||||
"tap": "^16.3.2",
|
||||
"tmp": "0.2.1",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../../../src/internal/operators/count.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAyDlC,MAAM,UAAU,KAAK,CAAI,SAAgD;IACvE,OAAO,MAAM,CAAC,UAAC,KAAK,EAAE,KAAK,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAvD,CAAuD,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"combineAll.js","sourceRoot":"","sources":["../../../../src/internal/operators/combineAll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD,MAAM,CAAC,IAAM,UAAU,GAAG,gBAAgB,CAAC"}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type Context from '../Context';
|
||||
import type { Writable } from 'svelte/store';
|
||||
export default class Filters {
|
||||
filters: Writable<any[]>;
|
||||
constructor(context: Context);
|
||||
set(value: string, filterBy: Function | string): void;
|
||||
remove(): void;
|
||||
private parse;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
var $charAt = callBound('String.prototype.charAt');
|
||||
var $stringToString = callBound('String.prototype.toString');
|
||||
|
||||
var CanonicalNumericIndexString = require('./CanonicalNumericIndexString');
|
||||
var IsInteger = require('./IsInteger');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
var isNegativeZero = require('is-negative-zero');
|
||||
|
||||
// https://262.ecma-international.org/8.0/#sec-stringgetownproperty
|
||||
|
||||
module.exports = function StringGetOwnProperty(S, P) {
|
||||
var str;
|
||||
if (Type(S) === 'Object') {
|
||||
try {
|
||||
str = $stringToString(S);
|
||||
} catch (e) { /**/ }
|
||||
}
|
||||
if (Type(str) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `S` must be a boxed string object');
|
||||
}
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
if (Type(P) !== 'String') {
|
||||
return void undefined;
|
||||
}
|
||||
var index = CanonicalNumericIndexString(P);
|
||||
var len = str.length;
|
||||
if (typeof index === 'undefined' || !IsInteger(index) || isNegativeZero(index) || index < 0 || len <= index) {
|
||||
return void undefined;
|
||||
}
|
||||
var resultStr = $charAt(S, index);
|
||||
return {
|
||||
'[[Configurable]]': false,
|
||||
'[[Enumerable]]': true,
|
||||
'[[Value]]': resultStr,
|
||||
'[[Writable]]': false
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "min-indent",
|
||||
"version": "1.0.1",
|
||||
"description": "Get the shortest leading whitespace from lines in a string",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/thejameskyle/min-indent",
|
||||
"author": {
|
||||
"name": "James Kyle",
|
||||
"email": "me@thejameskyle.com",
|
||||
"url": "thejameskyle.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"indent",
|
||||
"indentation",
|
||||
"normalize",
|
||||
"whitespace",
|
||||
"space",
|
||||
"tab",
|
||||
"string",
|
||||
"str",
|
||||
"min",
|
||||
"minimum"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InitializeNumberFormat = void 0;
|
||||
var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
|
||||
var GetOption_1 = require("../GetOption");
|
||||
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
||||
var SetNumberFormatUnitOptions_1 = require("./SetNumberFormatUnitOptions");
|
||||
var CurrencyDigits_1 = require("./CurrencyDigits");
|
||||
var SetNumberFormatDigitOptions_1 = require("./SetNumberFormatDigitOptions");
|
||||
var utils_1 = require("../utils");
|
||||
var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
|
||||
/**
|
||||
* https://tc39.es/ecma402/#sec-initializenumberformat
|
||||
*/
|
||||
function InitializeNumberFormat(nf, locales, opts, _a) {
|
||||
var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
|
||||
// @ts-ignore
|
||||
var requestedLocales = (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(locales);
|
||||
var options = (0, CoerceOptionsToObject_1.CoerceOptionsToObject)(opts);
|
||||
var opt = Object.create(null);
|
||||
var matcher = (0, GetOption_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
||||
opt.localeMatcher = matcher;
|
||||
var numberingSystem = (0, GetOption_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
|
||||
if (numberingSystem !== undefined &&
|
||||
numberingSystemNames.indexOf(numberingSystem) < 0) {
|
||||
// 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
|
||||
// throw a RangeError exception.
|
||||
throw RangeError("Invalid numberingSystems: ".concat(numberingSystem));
|
||||
}
|
||||
opt.nu = numberingSystem;
|
||||
var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt,
|
||||
// [[RelevantExtensionKeys]] slot, which is a constant
|
||||
['nu'], localeData, getDefaultLocale);
|
||||
var dataLocaleData = localeData[r.dataLocale];
|
||||
(0, utils_1.invariant)(!!dataLocaleData, "Missing locale data for ".concat(r.dataLocale));
|
||||
var internalSlots = getInternalSlots(nf);
|
||||
internalSlots.locale = r.locale;
|
||||
internalSlots.dataLocale = r.dataLocale;
|
||||
internalSlots.numberingSystem = r.nu;
|
||||
internalSlots.dataLocaleData = dataLocaleData;
|
||||
(0, SetNumberFormatUnitOptions_1.SetNumberFormatUnitOptions)(nf, options, { getInternalSlots: getInternalSlots });
|
||||
var style = internalSlots.style;
|
||||
var mnfdDefault;
|
||||
var mxfdDefault;
|
||||
if (style === 'currency') {
|
||||
var currency = internalSlots.currency;
|
||||
var cDigits = (0, CurrencyDigits_1.CurrencyDigits)(currency, { currencyDigitsData: currencyDigitsData });
|
||||
mnfdDefault = cDigits;
|
||||
mxfdDefault = cDigits;
|
||||
}
|
||||
else {
|
||||
mnfdDefault = 0;
|
||||
mxfdDefault = style === 'percent' ? 0 : 3;
|
||||
}
|
||||
var notation = (0, GetOption_1.GetOption)(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
|
||||
internalSlots.notation = notation;
|
||||
(0, SetNumberFormatDigitOptions_1.SetNumberFormatDigitOptions)(internalSlots, options, mnfdDefault, mxfdDefault, notation);
|
||||
var compactDisplay = (0, GetOption_1.GetOption)(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
|
||||
if (notation === 'compact') {
|
||||
internalSlots.compactDisplay = compactDisplay;
|
||||
}
|
||||
var useGrouping = (0, GetOption_1.GetOption)(options, 'useGrouping', 'boolean', undefined, true);
|
||||
internalSlots.useGrouping = useGrouping;
|
||||
var signDisplay = (0, GetOption_1.GetOption)(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
|
||||
internalSlots.signDisplay = signDisplay;
|
||||
return nf;
|
||||
}
|
||||
exports.InitializeNumberFormat = InitializeNumberFormat;
|
||||
@@ -0,0 +1,516 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/src/Result.ts</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">csv2json/src</a> Result.ts
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">87.32% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>62/71</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">79.25% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>42/53</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">86.67% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>13/15</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">86.96% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>60/69</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a>
|
||||
<a name='L13'></a><a href='#L13'>13</a>
|
||||
<a name='L14'></a><a href='#L14'>14</a>
|
||||
<a name='L15'></a><a href='#L15'>15</a>
|
||||
<a name='L16'></a><a href='#L16'>16</a>
|
||||
<a name='L17'></a><a href='#L17'>17</a>
|
||||
<a name='L18'></a><a href='#L18'>18</a>
|
||||
<a name='L19'></a><a href='#L19'>19</a>
|
||||
<a name='L20'></a><a href='#L20'>20</a>
|
||||
<a name='L21'></a><a href='#L21'>21</a>
|
||||
<a name='L22'></a><a href='#L22'>22</a>
|
||||
<a name='L23'></a><a href='#L23'>23</a>
|
||||
<a name='L24'></a><a href='#L24'>24</a>
|
||||
<a name='L25'></a><a href='#L25'>25</a>
|
||||
<a name='L26'></a><a href='#L26'>26</a>
|
||||
<a name='L27'></a><a href='#L27'>27</a>
|
||||
<a name='L28'></a><a href='#L28'>28</a>
|
||||
<a name='L29'></a><a href='#L29'>29</a>
|
||||
<a name='L30'></a><a href='#L30'>30</a>
|
||||
<a name='L31'></a><a href='#L31'>31</a>
|
||||
<a name='L32'></a><a href='#L32'>32</a>
|
||||
<a name='L33'></a><a href='#L33'>33</a>
|
||||
<a name='L34'></a><a href='#L34'>34</a>
|
||||
<a name='L35'></a><a href='#L35'>35</a>
|
||||
<a name='L36'></a><a href='#L36'>36</a>
|
||||
<a name='L37'></a><a href='#L37'>37</a>
|
||||
<a name='L38'></a><a href='#L38'>38</a>
|
||||
<a name='L39'></a><a href='#L39'>39</a>
|
||||
<a name='L40'></a><a href='#L40'>40</a>
|
||||
<a name='L41'></a><a href='#L41'>41</a>
|
||||
<a name='L42'></a><a href='#L42'>42</a>
|
||||
<a name='L43'></a><a href='#L43'>43</a>
|
||||
<a name='L44'></a><a href='#L44'>44</a>
|
||||
<a name='L45'></a><a href='#L45'>45</a>
|
||||
<a name='L46'></a><a href='#L46'>46</a>
|
||||
<a name='L47'></a><a href='#L47'>47</a>
|
||||
<a name='L48'></a><a href='#L48'>48</a>
|
||||
<a name='L49'></a><a href='#L49'>49</a>
|
||||
<a name='L50'></a><a href='#L50'>50</a>
|
||||
<a name='L51'></a><a href='#L51'>51</a>
|
||||
<a name='L52'></a><a href='#L52'>52</a>
|
||||
<a name='L53'></a><a href='#L53'>53</a>
|
||||
<a name='L54'></a><a href='#L54'>54</a>
|
||||
<a name='L55'></a><a href='#L55'>55</a>
|
||||
<a name='L56'></a><a href='#L56'>56</a>
|
||||
<a name='L57'></a><a href='#L57'>57</a>
|
||||
<a name='L58'></a><a href='#L58'>58</a>
|
||||
<a name='L59'></a><a href='#L59'>59</a>
|
||||
<a name='L60'></a><a href='#L60'>60</a>
|
||||
<a name='L61'></a><a href='#L61'>61</a>
|
||||
<a name='L62'></a><a href='#L62'>62</a>
|
||||
<a name='L63'></a><a href='#L63'>63</a>
|
||||
<a name='L64'></a><a href='#L64'>64</a>
|
||||
<a name='L65'></a><a href='#L65'>65</a>
|
||||
<a name='L66'></a><a href='#L66'>66</a>
|
||||
<a name='L67'></a><a href='#L67'>67</a>
|
||||
<a name='L68'></a><a href='#L68'>68</a>
|
||||
<a name='L69'></a><a href='#L69'>69</a>
|
||||
<a name='L70'></a><a href='#L70'>70</a>
|
||||
<a name='L71'></a><a href='#L71'>71</a>
|
||||
<a name='L72'></a><a href='#L72'>72</a>
|
||||
<a name='L73'></a><a href='#L73'>73</a>
|
||||
<a name='L74'></a><a href='#L74'>74</a>
|
||||
<a name='L75'></a><a href='#L75'>75</a>
|
||||
<a name='L76'></a><a href='#L76'>76</a>
|
||||
<a name='L77'></a><a href='#L77'>77</a>
|
||||
<a name='L78'></a><a href='#L78'>78</a>
|
||||
<a name='L79'></a><a href='#L79'>79</a>
|
||||
<a name='L80'></a><a href='#L80'>80</a>
|
||||
<a name='L81'></a><a href='#L81'>81</a>
|
||||
<a name='L82'></a><a href='#L82'>82</a>
|
||||
<a name='L83'></a><a href='#L83'>83</a>
|
||||
<a name='L84'></a><a href='#L84'>84</a>
|
||||
<a name='L85'></a><a href='#L85'>85</a>
|
||||
<a name='L86'></a><a href='#L86'>86</a>
|
||||
<a name='L87'></a><a href='#L87'>87</a>
|
||||
<a name='L88'></a><a href='#L88'>88</a>
|
||||
<a name='L89'></a><a href='#L89'>89</a>
|
||||
<a name='L90'></a><a href='#L90'>90</a>
|
||||
<a name='L91'></a><a href='#L91'>91</a>
|
||||
<a name='L92'></a><a href='#L92'>92</a>
|
||||
<a name='L93'></a><a href='#L93'>93</a>
|
||||
<a name='L94'></a><a href='#L94'>94</a>
|
||||
<a name='L95'></a><a href='#L95'>95</a>
|
||||
<a name='L96'></a><a href='#L96'>96</a>
|
||||
<a name='L97'></a><a href='#L97'>97</a>
|
||||
<a name='L98'></a><a href='#L98'>98</a>
|
||||
<a name='L99'></a><a href='#L99'>99</a>
|
||||
<a name='L100'></a><a href='#L100'>100</a>
|
||||
<a name='L101'></a><a href='#L101'>101</a>
|
||||
<a name='L102'></a><a href='#L102'>102</a>
|
||||
<a name='L103'></a><a href='#L103'>103</a>
|
||||
<a name='L104'></a><a href='#L104'>104</a>
|
||||
<a name='L105'></a><a href='#L105'>105</a>
|
||||
<a name='L106'></a><a href='#L106'>106</a>
|
||||
<a name='L107'></a><a href='#L107'>107</a>
|
||||
<a name='L108'></a><a href='#L108'>108</a>
|
||||
<a name='L109'></a><a href='#L109'>109</a>
|
||||
<a name='L110'></a><a href='#L110'>110</a>
|
||||
<a name='L111'></a><a href='#L111'>111</a>
|
||||
<a name='L112'></a><a href='#L112'>112</a>
|
||||
<a name='L113'></a><a href='#L113'>113</a>
|
||||
<a name='L114'></a><a href='#L114'>114</a>
|
||||
<a name='L115'></a><a href='#L115'>115</a>
|
||||
<a name='L116'></a><a href='#L116'>116</a>
|
||||
<a name='L117'></a><a href='#L117'>117</a>
|
||||
<a name='L118'></a><a href='#L118'>118</a>
|
||||
<a name='L119'></a><a href='#L119'>119</a>
|
||||
<a name='L120'></a><a href='#L120'>120</a>
|
||||
<a name='L121'></a><a href='#L121'>121</a>
|
||||
<a name='L122'></a><a href='#L122'>122</a>
|
||||
<a name='L123'></a><a href='#L123'>123</a>
|
||||
<a name='L124'></a><a href='#L124'>124</a>
|
||||
<a name='L125'></a><a href='#L125'>125</a>
|
||||
<a name='L126'></a><a href='#L126'>126</a>
|
||||
<a name='L127'></a><a href='#L127'>127</a>
|
||||
<a name='L128'></a><a href='#L128'>128</a>
|
||||
<a name='L129'></a><a href='#L129'>129</a>
|
||||
<a name='L130'></a><a href='#L130'>130</a>
|
||||
<a name='L131'></a><a href='#L131'>131</a>
|
||||
<a name='L132'></a><a href='#L132'>132</a>
|
||||
<a name='L133'></a><a href='#L133'>133</a>
|
||||
<a name='L134'></a><a href='#L134'>134</a>
|
||||
<a name='L135'></a><a href='#L135'>135</a>
|
||||
<a name='L136'></a><a href='#L136'>136</a>
|
||||
<a name='L137'></a><a href='#L137'>137</a>
|
||||
<a name='L138'></a><a href='#L138'>138</a>
|
||||
<a name='L139'></a><a href='#L139'>139</a>
|
||||
<a name='L140'></a><a href='#L140'>140</a>
|
||||
<a name='L141'></a><a href='#L141'>141</a>
|
||||
<a name='L142'></a><a href='#L142'>142</a>
|
||||
<a name='L143'></a><a href='#L143'>143</a>
|
||||
<a name='L144'></a><a href='#L144'>144</a>
|
||||
<a name='L145'></a><a href='#L145'>145</a>
|
||||
<a name='L146'></a><a href='#L146'>146</a>
|
||||
<a name='L147'></a><a href='#L147'>147</a>
|
||||
<a name='L148'></a><a href='#L148'>148</a>
|
||||
<a name='L149'></a><a href='#L149'>149</a>
|
||||
<a name='L150'></a><a href='#L150'>150</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">102x</span>
|
||||
<span class="cline-any cline-yes">63x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">102x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">155x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">73x</span>
|
||||
<span class="cline-any cline-yes">73x</span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">63x</span>
|
||||
<span class="cline-any cline-yes">63x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-yes">73x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">94x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">61x</span>
|
||||
<span class="cline-any cline-yes">46x</span>
|
||||
<span class="cline-any cline-yes">46x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">61x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-yes">10592x</span>
|
||||
<span class="cline-any cline-yes">10592x</span>
|
||||
<span class="cline-any cline-yes">10592x</span>
|
||||
<span class="cline-any cline-yes">10592x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">23x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-yes">10584x</span>
|
||||
<span class="cline-any cline-yes">10584x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">10586x</span>
|
||||
<span class="cline-any cline-yes">10584x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { Converter } from "./Converter";
|
||||
import { ProcessLineResult } from "./Processor";
|
||||
import P from "bluebird";
|
||||
import CSVError from "./CSVError";
|
||||
|
||||
export class Result {
|
||||
private get needEmitLine(): boolean {
|
||||
return !!this.converter.parseRuntime.subscribe && !!this.converter.parseRuntime.subscribe.onNext || this.needPushDownstream
|
||||
}
|
||||
private _needPushDownstream?: boolean;
|
||||
private get needPushDownstream(): boolean {
|
||||
if (this._needPushDownstream === undefined) {
|
||||
this._needPushDownstream = this.converter.listeners("data").length > 0 || this.converter.listeners("readable").length > 0;
|
||||
}
|
||||
return this._needPushDownstream;
|
||||
}
|
||||
private get needEmitAll(): boolean {
|
||||
return !!this.converter.parseRuntime.then;
|
||||
}
|
||||
private finalResult: any[] = [];
|
||||
constructor(private converter: Converter) { }
|
||||
processResult(resultLines: ProcessLineResult[]): P<any> {
|
||||
const startPos = this.converter.parseRuntime.parsedLineNumber;
|
||||
// let prom: P<any>;
|
||||
return new P((resolve, reject) => {
|
||||
if (this.needEmitLine) {
|
||||
processLineByLine(
|
||||
resultLines,
|
||||
this.converter,
|
||||
0,
|
||||
this.needPushDownstream,
|
||||
(err) => {
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (err) {
|
||||
<span class="cstat-no" title="statement not covered" > reject(err);</span>
|
||||
} else {
|
||||
this.appendFinalResult(resultLines);
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
this.appendFinalResult(resultLines);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
}
|
||||
appendFinalResult(lines: any[]) {
|
||||
if (this.needEmitAll) {
|
||||
this.finalResult = this.finalResult.concat(lines);
|
||||
}
|
||||
this.converter.parseRuntime.parsedLineNumber += lines.length;
|
||||
}
|
||||
processError(err: CSVError) {
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (this.converter.parseRuntime.subscribe && <span class="branch-1 cbranch-no" title="branch not covered" >this.converter.parseRuntime.subscribe.onError)</span> {
|
||||
<span class="cstat-no" title="statement not covered" > this.converter.parseRuntime.subscribe.onError(err);</span>
|
||||
}
|
||||
if (this.converter.parseRuntime.then && this.converter.parseRuntime.then.onrejected) {
|
||||
this.converter.parseRuntime.then.onrejected(err);
|
||||
}
|
||||
}
|
||||
endProcess() {
|
||||
if (this.needEmitAll) {
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (this.converter.parseRuntime.then && this.converter.parseRuntime.then.onfulfilled) {
|
||||
this.converter.parseRuntime.then.onfulfilled(this.finalResult);
|
||||
}
|
||||
}
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (this.converter.parseRuntime.subscribe && this.converter.parseRuntime.subscribe.onCompleted) {
|
||||
<span class="cstat-no" title="statement not covered" > this.converter.parseRuntime.subscribe.onCompleted();</span>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processLineByLine(
|
||||
lines: ProcessLineResult[],
|
||||
|
||||
conv: Converter,
|
||||
offset: number,
|
||||
needPushDownstream: boolean,
|
||||
cb: (err?) => void,
|
||||
) {
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (lines.length === 0) {
|
||||
<span class="cstat-no" title="statement not covered" > cb();</span>
|
||||
} else {
|
||||
if (conv.parseRuntime.subscribe && conv.parseRuntime.subscribe.onNext) {
|
||||
const hook = conv.parseRuntime.subscribe.onNext;
|
||||
const nextLine = lines[offset];
|
||||
const res = hook(nextLine, conv.parseRuntime.parsedLineNumber + offset);
|
||||
offset++;
|
||||
// if (isAsync === undefined) {
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (res && <span class="branch-1 cbranch-no" title="branch not covered" >res.then)</span> {
|
||||
<span class="cstat-no" title="statement not covered" > res.then(<span class="fstat-no" title="function not covered" >function () {</span></span>
|
||||
<span class="cstat-no" title="statement not covered" > processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine);</span>
|
||||
}, cb);
|
||||
} else {
|
||||
// processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
|
||||
if (needPushDownstream){
|
||||
pushDownstream(conv,nextLine);
|
||||
}
|
||||
while (offset<lines.length){
|
||||
const line=lines[offset];
|
||||
hook(line, conv.parseRuntime.parsedLineNumber + offset);
|
||||
offset++;
|
||||
if (needPushDownstream){
|
||||
pushDownstream(conv,line);
|
||||
}
|
||||
}
|
||||
cb();
|
||||
}
|
||||
// } else if (isAsync === true) {
|
||||
// (res as PromiseLike<void>).then(function () {
|
||||
// processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, true);
|
||||
// }, cb);
|
||||
// } else if (isAsync === false) {
|
||||
// processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
|
||||
// }
|
||||
} else {
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (needPushDownstream) {
|
||||
while (offset<lines.length) {
|
||||
const line = lines[offset++];
|
||||
pushDownstream(conv, line);
|
||||
}
|
||||
|
||||
}
|
||||
cb();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
<span class="fstat-no" title="function not covered" >function processRecursive(</span>
|
||||
lines: ProcessLineResult[],
|
||||
hook: (data: any, lineNumber: number) => void | PromiseLike<void>,
|
||||
conv: Converter,
|
||||
offset: number,
|
||||
needPushDownstream: boolean,
|
||||
cb: (err?) => void,
|
||||
res: ProcessLineResult,
|
||||
) {
|
||||
<span class="cstat-no" title="statement not covered" > if (needPushDownstream) {</span>
|
||||
<span class="cstat-no" title="statement not covered" > pushDownstream(conv, res);</span>
|
||||
}
|
||||
<span class="cstat-no" title="statement not covered" > processLineByLine(lines, conv, offset, needPushDownstream, cb);</span>
|
||||
}
|
||||
function pushDownstream(conv: Converter, res: ProcessLineResult) {
|
||||
if (typeof res === "object" && !conv.options.objectMode) {
|
||||
conv.push(JSON.stringify(res) + "\n", "utf8");
|
||||
} else {
|
||||
conv.push(res);
|
||||
}
|
||||
}</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri May 11 2018 21:36:07 GMT+0100 (IST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
<script src="../../block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../../src/internal/operators/share.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGlF,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC;IACjC;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9D;AAED,wBAAgB,KAAK,CAAC,CAAC,KAAK,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAExD,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC"}
|
||||
@@ -0,0 +1,243 @@
|
||||
import { PartialObserver, ObservableNotification, CompleteNotification, NextNotification, ErrorNotification } from './types';
|
||||
import { Observable } from './Observable';
|
||||
import { EMPTY } from './observable/empty';
|
||||
import { of } from './observable/of';
|
||||
import { throwError } from './observable/throwError';
|
||||
import { isFunction } from './util/isFunction';
|
||||
|
||||
// TODO: When this enum is removed, replace it with a type alias. See #4556.
|
||||
/**
|
||||
* @deprecated Use a string literal instead. `NotificationKind` will be replaced with a type alias in v8.
|
||||
* It will not be replaced with a const enum as those are not compatible with isolated modules.
|
||||
*/
|
||||
export enum NotificationKind {
|
||||
NEXT = 'N',
|
||||
ERROR = 'E',
|
||||
COMPLETE = 'C',
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a push-based event or value that an {@link Observable} can emit.
|
||||
* This class is particularly useful for operators that manage notifications,
|
||||
* like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
|
||||
* others. Besides wrapping the actual delivered value, it also annotates it
|
||||
* with metadata of, for instance, what type of push message it is (`next`,
|
||||
* `error`, or `complete`).
|
||||
*
|
||||
* @see {@link materialize}
|
||||
* @see {@link dematerialize}
|
||||
* @see {@link observeOn}
|
||||
* @deprecated It is NOT recommended to create instances of `Notification` directly.
|
||||
* Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
||||
* For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
||||
* Will be removed in v8.
|
||||
*/
|
||||
export class Notification<T> {
|
||||
/**
|
||||
* A value signifying that the notification will "next" if observed. In truth,
|
||||
* This is really synonymous with just checking `kind === "N"`.
|
||||
* @deprecated Will be removed in v8. Instead, just check to see if the value of `kind` is `"N"`.
|
||||
*/
|
||||
readonly hasValue: boolean;
|
||||
|
||||
/**
|
||||
* Creates a "Next" notification object.
|
||||
* @param kind Always `'N'`
|
||||
* @param value The value to notify with if observed.
|
||||
* @deprecated Internal implementation detail. Use {@link Notification#createNext createNext} instead.
|
||||
*/
|
||||
constructor(kind: 'N', value?: T);
|
||||
/**
|
||||
* Creates an "Error" notification object.
|
||||
* @param kind Always `'E'`
|
||||
* @param value Always `undefined`
|
||||
* @param error The error to notify with if observed.
|
||||
* @deprecated Internal implementation detail. Use {@link Notification#createError createError} instead.
|
||||
*/
|
||||
constructor(kind: 'E', value: undefined, error: any);
|
||||
/**
|
||||
* Creates a "completion" notification object.
|
||||
* @param kind Always `'C'`
|
||||
* @deprecated Internal implementation detail. Use {@link Notification#createComplete createComplete} instead.
|
||||
*/
|
||||
constructor(kind: 'C');
|
||||
constructor(public readonly kind: 'N' | 'E' | 'C', public readonly value?: T, public readonly error?: any) {
|
||||
this.hasValue = kind === 'N';
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the appropriate handler on a passed `observer` given the `kind` of notification.
|
||||
* If the handler is missing it will do nothing. Even if the notification is an error, if
|
||||
* there is no error handler on the observer, an error will not be thrown, it will noop.
|
||||
* @param observer The observer to notify.
|
||||
*/
|
||||
observe(observer: PartialObserver<T>): void {
|
||||
return observeNotification(this as ObservableNotification<T>, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a notification on the appropriate handler from a list provided.
|
||||
* If a handler is missing for the kind of notification, nothing is called
|
||||
* and no error is thrown, it will be a noop.
|
||||
* @param next A next handler
|
||||
* @param error An error handler
|
||||
* @param complete A complete handler
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
do(next: (value: T) => void, error: (err: any) => void, complete: () => void): void;
|
||||
/**
|
||||
* Executes a notification on the appropriate handler from a list provided.
|
||||
* If a handler is missing for the kind of notification, nothing is called
|
||||
* and no error is thrown, it will be a noop.
|
||||
* @param next A next handler
|
||||
* @param error An error handler
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
do(next: (value: T) => void, error: (err: any) => void): void;
|
||||
/**
|
||||
* Executes the next handler if the Notification is of `kind` `"N"`. Otherwise
|
||||
* this will not error, and it will be a noop.
|
||||
* @param next The next handler
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
do(next: (value: T) => void): void;
|
||||
do(nextHandler: (value: T) => void, errorHandler?: (err: any) => void, completeHandler?: () => void): void {
|
||||
const { kind, value, error } = this;
|
||||
return kind === 'N' ? nextHandler?.(value!) : kind === 'E' ? errorHandler?.(error) : completeHandler?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a notification on the appropriate handler from a list provided.
|
||||
* If a handler is missing for the kind of notification, nothing is called
|
||||
* and no error is thrown, it will be a noop.
|
||||
* @param next A next handler
|
||||
* @param error An error handler
|
||||
* @param complete A complete handler
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
accept(next: (value: T) => void, error: (err: any) => void, complete: () => void): void;
|
||||
/**
|
||||
* Executes a notification on the appropriate handler from a list provided.
|
||||
* If a handler is missing for the kind of notification, nothing is called
|
||||
* and no error is thrown, it will be a noop.
|
||||
* @param next A next handler
|
||||
* @param error An error handler
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
accept(next: (value: T) => void, error: (err: any) => void): void;
|
||||
/**
|
||||
* Executes the next handler if the Notification is of `kind` `"N"`. Otherwise
|
||||
* this will not error, and it will be a noop.
|
||||
* @param next The next handler
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
accept(next: (value: T) => void): void;
|
||||
|
||||
/**
|
||||
* Executes the appropriate handler on a passed `observer` given the `kind` of notification.
|
||||
* If the handler is missing it will do nothing. Even if the notification is an error, if
|
||||
* there is no error handler on the observer, an error will not be thrown, it will noop.
|
||||
* @param observer The observer to notify.
|
||||
* @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
||||
*/
|
||||
accept(observer: PartialObserver<T>): void;
|
||||
accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void) {
|
||||
return isFunction((nextOrObserver as any)?.next)
|
||||
? this.observe(nextOrObserver as PartialObserver<T>)
|
||||
: this.do(nextOrObserver as (value: T) => void, error as any, complete as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple Observable that just delivers the notification represented
|
||||
* by this Notification instance.
|
||||
*
|
||||
* @deprecated Will be removed in v8. To convert a `Notification` to an {@link Observable},
|
||||
* use {@link of} and {@link dematerialize}: `of(notification).pipe(dematerialize())`.
|
||||
*/
|
||||
toObservable(): Observable<T> {
|
||||
const { kind, value, error } = this;
|
||||
// Select the observable to return by `kind`
|
||||
const result =
|
||||
kind === 'N'
|
||||
? // Next kind. Return an observable of that value.
|
||||
of(value!)
|
||||
: //
|
||||
kind === 'E'
|
||||
? // Error kind. Return an observable that emits the error.
|
||||
throwError(() => error)
|
||||
: //
|
||||
kind === 'C'
|
||||
? // Completion kind. Kind is "C", return an observable that just completes.
|
||||
EMPTY
|
||||
: // Unknown kind, return falsy, so we error below.
|
||||
0;
|
||||
if (!result) {
|
||||
// TODO: consider removing this check. The only way to cause this would be to
|
||||
// use the Notification constructor directly in a way that is not type-safe.
|
||||
// and direct use of the Notification constructor is deprecated.
|
||||
throw new TypeError(`Unexpected notification kind ${kind}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static completeNotification = new Notification('C') as Notification<never> & CompleteNotification;
|
||||
/**
|
||||
* A shortcut to create a Notification instance of the type `next` from a
|
||||
* given value.
|
||||
* @param {T} value The `next` value.
|
||||
* @return {Notification<T>} The "next" Notification representing the
|
||||
* argument.
|
||||
* @nocollapse
|
||||
* @deprecated It is NOT recommended to create instances of `Notification` directly.
|
||||
* Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
||||
* For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
||||
* Will be removed in v8.
|
||||
*/
|
||||
static createNext<T>(value: T) {
|
||||
return new Notification('N', value) as Notification<T> & NextNotification<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A shortcut to create a Notification instance of the type `error` from a
|
||||
* given error.
|
||||
* @param {any} [err] The `error` error.
|
||||
* @return {Notification<T>} The "error" Notification representing the
|
||||
* argument.
|
||||
* @nocollapse
|
||||
* @deprecated It is NOT recommended to create instances of `Notification` directly.
|
||||
* Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
||||
* For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
||||
* Will be removed in v8.
|
||||
*/
|
||||
static createError(err?: any) {
|
||||
return new Notification('E', undefined, err) as Notification<never> & ErrorNotification;
|
||||
}
|
||||
|
||||
/**
|
||||
* A shortcut to create a Notification instance of the type `complete`.
|
||||
* @return {Notification<any>} The valueless "complete" Notification.
|
||||
* @nocollapse
|
||||
* @deprecated It is NOT recommended to create instances of `Notification` directly.
|
||||
* Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
||||
* For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
||||
* Will be removed in v8.
|
||||
*/
|
||||
static createComplete(): Notification<never> & CompleteNotification {
|
||||
return Notification.completeNotification;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the appropriate handler on a passed `observer` given the `kind` of notification.
|
||||
* If the handler is missing it will do nothing. Even if the notification is an error, if
|
||||
* there is no error handler on the observer, an error will not be thrown, it will noop.
|
||||
* @param notification The notification object to observe.
|
||||
* @param observer The observer to notify.
|
||||
*/
|
||||
export function observeNotification<T>(notification: ObservableNotification<T>, observer: PartialObserver<T>) {
|
||||
const { kind, value, error } = notification as any;
|
||||
if (typeof kind !== 'string') {
|
||||
throw new TypeError('Invalid notification, missing "kind"');
|
||||
}
|
||||
kind === 'N' ? observer.next?.(value!) : kind === 'E' ? observer.error?.(error) : observer.complete?.();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
# defer-to-connect
|
||||
|
||||
> The safe way to handle the `connect` socket event
|
||||
|
||||
[](https://coveralls.io/github/szmarczak/defer-to-connect?branch=master)
|
||||
|
||||
Once you receive the socket, it may be already connected (or disconnected).<br>
|
||||
To avoid checking that, use `defer-to-connect`. It'll do that for you.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const deferToConnect = require('defer-to-connect');
|
||||
|
||||
deferToConnect(socket, () => {
|
||||
console.log('Connected!');
|
||||
});
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### deferToConnect(socket, connectListener)
|
||||
|
||||
Calls `connectListener()` when connected.
|
||||
|
||||
### deferToConnect(socket, listeners)
|
||||
|
||||
#### listeners
|
||||
|
||||
An object representing `connect`, `secureConnect` and `close` properties.
|
||||
|
||||
Calls `connect()` when the socket is connected.<br>
|
||||
Calls `secureConnect()` when the socket is securely connected.<br>
|
||||
Calls `close()` when the socket is destroyed.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,38 @@
|
||||
import type {DelimiterCase} from './delimiter-case';
|
||||
|
||||
/**
|
||||
Convert a string literal to kebab-case.
|
||||
|
||||
This can be useful when, for example, converting a camel-cased object property to a kebab-cased CSS class name or a command-line flag.
|
||||
|
||||
@example
|
||||
```
|
||||
import type {KebabCase} from 'type-fest';
|
||||
|
||||
// Simple
|
||||
|
||||
const someVariable: KebabCase<'fooBar'> = 'foo-bar';
|
||||
|
||||
// Advanced
|
||||
|
||||
type KebabCasedProperties<T> = {
|
||||
[K in keyof T as KebabCase<K>]: T[K]
|
||||
};
|
||||
|
||||
interface CliOptions {
|
||||
dryRun: boolean;
|
||||
includeFile: string;
|
||||
foo: number;
|
||||
}
|
||||
|
||||
const rawCliOptions: KebabCasedProperties<CliOptions> = {
|
||||
'dry-run': true,
|
||||
'include-file': 'bar.js',
|
||||
foo: 123
|
||||
};
|
||||
```
|
||||
|
||||
@category Change case
|
||||
@category Template literal
|
||||
*/
|
||||
export type KebabCase<Value> = DelimiterCase<Value, '-'>;
|
||||
@@ -0,0 +1,45 @@
|
||||
var test = require('tape')
|
||||
var through = require('../')
|
||||
|
||||
// must emit end before close.
|
||||
|
||||
test('end before close', function (assert) {
|
||||
var ts = through()
|
||||
var ended = false, closed = false
|
||||
|
||||
ts.on('end', function () {
|
||||
assert.ok(!closed)
|
||||
ended = true
|
||||
})
|
||||
ts.on('close', function () {
|
||||
assert.ok(ended)
|
||||
closed = true
|
||||
})
|
||||
|
||||
ts.write(1)
|
||||
ts.write(2)
|
||||
ts.write(3)
|
||||
ts.end()
|
||||
assert.ok(ended)
|
||||
assert.ok(closed)
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test('end only once', function (t) {
|
||||
|
||||
var ts = through()
|
||||
var ended = false, closed = false
|
||||
|
||||
ts.on('end', function () {
|
||||
t.equal(ended, false)
|
||||
ended = true
|
||||
})
|
||||
|
||||
ts.queue(null)
|
||||
ts.queue(null)
|
||||
ts.queue(null)
|
||||
|
||||
ts.resume()
|
||||
|
||||
t.end()
|
||||
})
|
||||
@@ -0,0 +1,33 @@
|
||||
var baseRepeat = require('./_baseRepeat'),
|
||||
baseToString = require('./_baseToString'),
|
||||
castSlice = require('./_castSlice'),
|
||||
hasUnicode = require('./_hasUnicode'),
|
||||
stringSize = require('./_stringSize'),
|
||||
stringToArray = require('./_stringToArray');
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeCeil = Math.ceil;
|
||||
|
||||
/**
|
||||
* Creates the padding for `string` based on `length`. The `chars` string
|
||||
* is truncated if the number of characters exceeds `length`.
|
||||
*
|
||||
* @private
|
||||
* @param {number} length The padding length.
|
||||
* @param {string} [chars=' '] The string used as padding.
|
||||
* @returns {string} Returns the padding for `string`.
|
||||
*/
|
||||
function createPadding(length, chars) {
|
||||
chars = chars === undefined ? ' ' : baseToString(chars);
|
||||
|
||||
var charsLength = chars.length;
|
||||
if (charsLength < 2) {
|
||||
return charsLength ? baseRepeat(chars, length) : chars;
|
||||
}
|
||||
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
|
||||
return hasUnicode(chars)
|
||||
? castSlice(stringToArray(result), 0, length).join('')
|
||||
: result.slice(0, length);
|
||||
}
|
||||
|
||||
module.exports = createPadding;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { EndpointOptions, RequestParameters as RequestParametersType, EndpointInterface } from "@octokit/types";
|
||||
export type GraphQlEndpointOptions = EndpointOptions & {
|
||||
variables?: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
export type RequestParameters = RequestParametersType;
|
||||
export type Query = string;
|
||||
export interface graphql {
|
||||
/**
|
||||
* Sends a GraphQL query request based on endpoint options
|
||||
* The GraphQL query must be specified in `options`.
|
||||
*
|
||||
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
||||
*/
|
||||
<ResponseData>(options: RequestParameters): GraphQlResponse<ResponseData>;
|
||||
/**
|
||||
* Sends a GraphQL query request based on endpoint options
|
||||
*
|
||||
* @param {string} query GraphQL query. Example: `'query { viewer { login } }'`.
|
||||
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
||||
*/
|
||||
<ResponseData>(query: Query, parameters?: RequestParameters): GraphQlResponse<ResponseData>;
|
||||
/**
|
||||
* Returns a new `endpoint` with updated route and parameters
|
||||
*/
|
||||
defaults: (newDefaults: RequestParameters) => graphql;
|
||||
/**
|
||||
* Octokit endpoint API, see {@link https://github.com/octokit/endpoint.js|@octokit/endpoint}
|
||||
*/
|
||||
endpoint: EndpointInterface;
|
||||
}
|
||||
export type GraphQlResponse<ResponseData> = Promise<ResponseData>;
|
||||
export type GraphQlQueryResponseData = {
|
||||
[key: string]: any;
|
||||
};
|
||||
export type GraphQlQueryResponse<ResponseData> = {
|
||||
data: ResponseData;
|
||||
errors?: [
|
||||
{
|
||||
type: string;
|
||||
message: string;
|
||||
path: [string];
|
||||
extensions: {
|
||||
[key: string]: any;
|
||||
};
|
||||
locations: [
|
||||
{
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
import type {Except} from './except';
|
||||
import type {ConditionalKeys} from './conditional-keys';
|
||||
|
||||
/**
|
||||
Exclude keys from a shape that matches the given `Condition`.
|
||||
|
||||
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
|
||||
|
||||
@example
|
||||
```
|
||||
import type {Primitive, ConditionalExcept} from 'type-fest';
|
||||
|
||||
class Awesome {
|
||||
name: string;
|
||||
successes: number;
|
||||
failures: bigint;
|
||||
|
||||
run() {}
|
||||
}
|
||||
|
||||
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
||||
//=> {run: () => void}
|
||||
```
|
||||
|
||||
@example
|
||||
```
|
||||
import type {ConditionalExcept} from 'type-fest';
|
||||
|
||||
interface Example {
|
||||
a: string;
|
||||
b: string | number;
|
||||
c: () => void;
|
||||
d: {};
|
||||
}
|
||||
|
||||
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
||||
//=> {b: string | number; c: () => void; d: {}}
|
||||
```
|
||||
|
||||
@category Object
|
||||
*/
|
||||
export type ConditionalExcept<Base, Condition> = Except<
|
||||
Base,
|
||||
ConditionalKeys<Base, Condition>
|
||||
>;
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (C) 2012-2018 by various contributors (see AUTHORS)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yCAAwC;AAExC,IAAM,MAAM,GAAG,UAAU,KAA8B,EAAE,OAA0B;IACjF,OAAO,IAAI,qBAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC,CAAA;AACD,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;AACvB,MAAM,CAAC,WAAW,CAAC,GAAG,qBAAS,CAAC;AAChC,iBAAQ,MAAM,CAAC"}
|
||||
@@ -0,0 +1,21 @@
|
||||
var basePropertyOf = require('./_basePropertyOf');
|
||||
|
||||
/** Used to map HTML entities to characters. */
|
||||
var htmlUnescapes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'"
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by `_.unescape` to convert HTML entities to characters.
|
||||
*
|
||||
* @private
|
||||
* @param {string} chr The matched character to unescape.
|
||||
* @returns {string} Returns the unescaped character.
|
||||
*/
|
||||
var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
|
||||
|
||||
module.exports = unescapeHtmlChar;
|
||||
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/gopd
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,6BAA2D;AAG3D,SAAgB,SAAS,CACxB,IAAY,EACZ,IAAmB;IAEnB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,IAAA,YAAM,EAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC/B,IAAI,GAAG,EAAE;gBACR,MAAM,CAAC,GAAG,CAAC,CAAC;aACZ;iBAAM;gBACN,OAAO,CAAC,GAAG,CAAC,CAAC;aACb;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AAbD,8BAaC;AAED,SAAgB,KAAK,CAAC,CAAM;IAC3B,OAAO,CAAC,KAAK,KAAK,CAAC;AACpB,CAAC;AAFD,sBAEC"}
|
||||
@@ -0,0 +1,780 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Def = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var Op = Object.prototype;
|
||||
var objToStr = Op.toString;
|
||||
var hasOwn = Op.hasOwnProperty;
|
||||
var BaseType = /** @class */ (function () {
|
||||
function BaseType() {
|
||||
}
|
||||
BaseType.prototype.assert = function (value, deep) {
|
||||
if (!this.check(value, deep)) {
|
||||
var str = shallowStringify(value);
|
||||
throw new Error(str + " does not match type " + this);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
BaseType.prototype.arrayOf = function () {
|
||||
var elemType = this;
|
||||
return new ArrayType(elemType);
|
||||
};
|
||||
return BaseType;
|
||||
}());
|
||||
var ArrayType = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(ArrayType, _super);
|
||||
function ArrayType(elemType) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.elemType = elemType;
|
||||
_this.kind = "ArrayType";
|
||||
return _this;
|
||||
}
|
||||
ArrayType.prototype.toString = function () {
|
||||
return "[" + this.elemType + "]";
|
||||
};
|
||||
ArrayType.prototype.check = function (value, deep) {
|
||||
var _this = this;
|
||||
return Array.isArray(value) && value.every(function (elem) { return _this.elemType.check(elem, deep); });
|
||||
};
|
||||
return ArrayType;
|
||||
}(BaseType));
|
||||
var IdentityType = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(IdentityType, _super);
|
||||
function IdentityType(value) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.value = value;
|
||||
_this.kind = "IdentityType";
|
||||
return _this;
|
||||
}
|
||||
IdentityType.prototype.toString = function () {
|
||||
return String(this.value);
|
||||
};
|
||||
IdentityType.prototype.check = function (value, deep) {
|
||||
var result = value === this.value;
|
||||
if (!result && typeof deep === "function") {
|
||||
deep(this, value);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return IdentityType;
|
||||
}(BaseType));
|
||||
var ObjectType = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(ObjectType, _super);
|
||||
function ObjectType(fields) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.fields = fields;
|
||||
_this.kind = "ObjectType";
|
||||
return _this;
|
||||
}
|
||||
ObjectType.prototype.toString = function () {
|
||||
return "{ " + this.fields.join(", ") + " }";
|
||||
};
|
||||
ObjectType.prototype.check = function (value, deep) {
|
||||
return (objToStr.call(value) === objToStr.call({}) &&
|
||||
this.fields.every(function (field) {
|
||||
return field.type.check(value[field.name], deep);
|
||||
}));
|
||||
};
|
||||
return ObjectType;
|
||||
}(BaseType));
|
||||
var OrType = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(OrType, _super);
|
||||
function OrType(types) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.types = types;
|
||||
_this.kind = "OrType";
|
||||
return _this;
|
||||
}
|
||||
OrType.prototype.toString = function () {
|
||||
return this.types.join(" | ");
|
||||
};
|
||||
OrType.prototype.check = function (value, deep) {
|
||||
return this.types.some(function (type) {
|
||||
return type.check(value, deep);
|
||||
});
|
||||
};
|
||||
return OrType;
|
||||
}(BaseType));
|
||||
var PredicateType = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(PredicateType, _super);
|
||||
function PredicateType(name, predicate) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.name = name;
|
||||
_this.predicate = predicate;
|
||||
_this.kind = "PredicateType";
|
||||
return _this;
|
||||
}
|
||||
PredicateType.prototype.toString = function () {
|
||||
return this.name;
|
||||
};
|
||||
PredicateType.prototype.check = function (value, deep) {
|
||||
var result = this.predicate(value, deep);
|
||||
if (!result && typeof deep === "function") {
|
||||
deep(this, value);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return PredicateType;
|
||||
}(BaseType));
|
||||
var Def = /** @class */ (function () {
|
||||
function Def(type, typeName) {
|
||||
this.type = type;
|
||||
this.typeName = typeName;
|
||||
this.baseNames = [];
|
||||
this.ownFields = Object.create(null);
|
||||
// Includes own typeName. Populated during finalization.
|
||||
this.allSupertypes = Object.create(null);
|
||||
// Linear inheritance hierarchy. Populated during finalization.
|
||||
this.supertypeList = [];
|
||||
// Includes inherited fields.
|
||||
this.allFields = Object.create(null);
|
||||
// Non-hidden keys of allFields.
|
||||
this.fieldNames = [];
|
||||
// This property will be overridden as true by individual Def instances
|
||||
// when they are finalized.
|
||||
this.finalized = false;
|
||||
// False by default until .build(...) is called on an instance.
|
||||
this.buildable = false;
|
||||
this.buildParams = [];
|
||||
}
|
||||
Def.prototype.isSupertypeOf = function (that) {
|
||||
if (that instanceof Def) {
|
||||
if (this.finalized !== true ||
|
||||
that.finalized !== true) {
|
||||
throw new Error("");
|
||||
}
|
||||
return hasOwn.call(that.allSupertypes, this.typeName);
|
||||
}
|
||||
else {
|
||||
throw new Error(that + " is not a Def");
|
||||
}
|
||||
};
|
||||
Def.prototype.checkAllFields = function (value, deep) {
|
||||
var allFields = this.allFields;
|
||||
if (this.finalized !== true) {
|
||||
throw new Error("" + this.typeName);
|
||||
}
|
||||
function checkFieldByName(name) {
|
||||
var field = allFields[name];
|
||||
var type = field.type;
|
||||
var child = field.getValue(value);
|
||||
return type.check(child, deep);
|
||||
}
|
||||
return value !== null &&
|
||||
typeof value === "object" &&
|
||||
Object.keys(allFields).every(checkFieldByName);
|
||||
};
|
||||
Def.prototype.bases = function () {
|
||||
var supertypeNames = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
supertypeNames[_i] = arguments[_i];
|
||||
}
|
||||
var bases = this.baseNames;
|
||||
if (this.finalized) {
|
||||
if (supertypeNames.length !== bases.length) {
|
||||
throw new Error("");
|
||||
}
|
||||
for (var i = 0; i < supertypeNames.length; i++) {
|
||||
if (supertypeNames[i] !== bases[i]) {
|
||||
throw new Error("");
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
supertypeNames.forEach(function (baseName) {
|
||||
// This indexOf lookup may be O(n), but the typical number of base
|
||||
// names is very small, and indexOf is a native Array method.
|
||||
if (bases.indexOf(baseName) < 0) {
|
||||
bases.push(baseName);
|
||||
}
|
||||
});
|
||||
return this; // For chaining.
|
||||
};
|
||||
return Def;
|
||||
}());
|
||||
exports.Def = Def;
|
||||
var Field = /** @class */ (function () {
|
||||
function Field(name, type, defaultFn, hidden) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.defaultFn = defaultFn;
|
||||
this.hidden = !!hidden;
|
||||
}
|
||||
Field.prototype.toString = function () {
|
||||
return JSON.stringify(this.name) + ": " + this.type;
|
||||
};
|
||||
Field.prototype.getValue = function (obj) {
|
||||
var value = obj[this.name];
|
||||
if (typeof value !== "undefined") {
|
||||
return value;
|
||||
}
|
||||
if (typeof this.defaultFn === "function") {
|
||||
value = this.defaultFn.call(obj);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
return Field;
|
||||
}());
|
||||
function shallowStringify(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return "[" + value.map(shallowStringify).join(", ") + "]";
|
||||
}
|
||||
if (value && typeof value === "object") {
|
||||
return "{ " + Object.keys(value).map(function (key) {
|
||||
return key + ": " + value[key];
|
||||
}).join(", ") + " }";
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
function typesPlugin(_fork) {
|
||||
var Type = {
|
||||
or: function () {
|
||||
var types = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
types[_i] = arguments[_i];
|
||||
}
|
||||
return new OrType(types.map(function (type) { return Type.from(type); }));
|
||||
},
|
||||
from: function (value, name) {
|
||||
if (value instanceof ArrayType ||
|
||||
value instanceof IdentityType ||
|
||||
value instanceof ObjectType ||
|
||||
value instanceof OrType ||
|
||||
value instanceof PredicateType) {
|
||||
return value;
|
||||
}
|
||||
// The Def type is used as a helper for constructing compound
|
||||
// interface types for AST nodes.
|
||||
if (value instanceof Def) {
|
||||
return value.type;
|
||||
}
|
||||
// Support [ElemType] syntax.
|
||||
if (isArray.check(value)) {
|
||||
if (value.length !== 1) {
|
||||
throw new Error("only one element type is permitted for typed arrays");
|
||||
}
|
||||
return new ArrayType(Type.from(value[0]));
|
||||
}
|
||||
// Support { someField: FieldType, ... } syntax.
|
||||
if (isObject.check(value)) {
|
||||
return new ObjectType(Object.keys(value).map(function (name) {
|
||||
return new Field(name, Type.from(value[name], name));
|
||||
}));
|
||||
}
|
||||
if (typeof value === "function") {
|
||||
var bicfIndex = builtInCtorFns.indexOf(value);
|
||||
if (bicfIndex >= 0) {
|
||||
return builtInCtorTypes[bicfIndex];
|
||||
}
|
||||
if (typeof name !== "string") {
|
||||
throw new Error("missing name");
|
||||
}
|
||||
return new PredicateType(name, value);
|
||||
}
|
||||
// As a last resort, toType returns a type that matches any value that
|
||||
// is === from. This is primarily useful for literal values like
|
||||
// toType(null), but it has the additional advantage of allowing
|
||||
// toType to be a total function.
|
||||
return new IdentityType(value);
|
||||
},
|
||||
// Define a type whose name is registered in a namespace (the defCache) so
|
||||
// that future definitions will return the same type given the same name.
|
||||
// In particular, this system allows for circular and forward definitions.
|
||||
// The Def object d returned from Type.def may be used to configure the
|
||||
// type d.type by calling methods such as d.bases, d.build, and d.field.
|
||||
def: function (typeName) {
|
||||
return hasOwn.call(defCache, typeName)
|
||||
? defCache[typeName]
|
||||
: defCache[typeName] = new DefImpl(typeName);
|
||||
},
|
||||
hasDef: function (typeName) {
|
||||
return hasOwn.call(defCache, typeName);
|
||||
}
|
||||
};
|
||||
var builtInCtorFns = [];
|
||||
var builtInCtorTypes = [];
|
||||
function defBuiltInType(name, example) {
|
||||
var objStr = objToStr.call(example);
|
||||
var type = new PredicateType(name, function (value) { return objToStr.call(value) === objStr; });
|
||||
if (example && typeof example.constructor === "function") {
|
||||
builtInCtorFns.push(example.constructor);
|
||||
builtInCtorTypes.push(type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
// These types check the underlying [[Class]] attribute of the given
|
||||
// value, rather than using the problematic typeof operator. Note however
|
||||
// that no subtyping is considered; so, for instance, isObject.check
|
||||
// returns false for [], /./, new Date, and null.
|
||||
var isString = defBuiltInType("string", "truthy");
|
||||
var isFunction = defBuiltInType("function", function () { });
|
||||
var isArray = defBuiltInType("array", []);
|
||||
var isObject = defBuiltInType("object", {});
|
||||
var isRegExp = defBuiltInType("RegExp", /./);
|
||||
var isDate = defBuiltInType("Date", new Date());
|
||||
var isNumber = defBuiltInType("number", 3);
|
||||
var isBoolean = defBuiltInType("boolean", true);
|
||||
var isNull = defBuiltInType("null", null);
|
||||
var isUndefined = defBuiltInType("undefined", undefined);
|
||||
var builtInTypes = {
|
||||
string: isString,
|
||||
function: isFunction,
|
||||
array: isArray,
|
||||
object: isObject,
|
||||
RegExp: isRegExp,
|
||||
Date: isDate,
|
||||
number: isNumber,
|
||||
boolean: isBoolean,
|
||||
null: isNull,
|
||||
undefined: isUndefined,
|
||||
};
|
||||
// In order to return the same Def instance every time Type.def is called
|
||||
// with a particular name, those instances need to be stored in a cache.
|
||||
var defCache = Object.create(null);
|
||||
function defFromValue(value) {
|
||||
if (value && typeof value === "object") {
|
||||
var type = value.type;
|
||||
if (typeof type === "string" &&
|
||||
hasOwn.call(defCache, type)) {
|
||||
var d = defCache[type];
|
||||
if (d.finalized) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var DefImpl = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(DefImpl, _super);
|
||||
function DefImpl(typeName) {
|
||||
var _this = _super.call(this, new PredicateType(typeName, function (value, deep) { return _this.check(value, deep); }), typeName) || this;
|
||||
return _this;
|
||||
}
|
||||
DefImpl.prototype.check = function (value, deep) {
|
||||
if (this.finalized !== true) {
|
||||
throw new Error("prematurely checking unfinalized type " + this.typeName);
|
||||
}
|
||||
// A Def type can only match an object value.
|
||||
if (value === null || typeof value !== "object") {
|
||||
return false;
|
||||
}
|
||||
var vDef = defFromValue(value);
|
||||
if (!vDef) {
|
||||
// If we couldn't infer the Def associated with the given value,
|
||||
// and we expected it to be a SourceLocation or a Position, it was
|
||||
// probably just missing a "type" field (because Esprima does not
|
||||
// assign a type property to such nodes). Be optimistic and let
|
||||
// this.checkAllFields make the final decision.
|
||||
if (this.typeName === "SourceLocation" ||
|
||||
this.typeName === "Position") {
|
||||
return this.checkAllFields(value, deep);
|
||||
}
|
||||
// Calling this.checkAllFields for any other type of node is both
|
||||
// bad for performance and way too forgiving.
|
||||
return false;
|
||||
}
|
||||
// If checking deeply and vDef === this, then we only need to call
|
||||
// checkAllFields once. Calling checkAllFields is too strict when deep
|
||||
// is false, because then we only care about this.isSupertypeOf(vDef).
|
||||
if (deep && vDef === this) {
|
||||
return this.checkAllFields(value, deep);
|
||||
}
|
||||
// In most cases we rely exclusively on isSupertypeOf to make O(1)
|
||||
// subtyping determinations. This suffices in most situations outside
|
||||
// of unit tests, since interface conformance is checked whenever new
|
||||
// instances are created using builder functions.
|
||||
if (!this.isSupertypeOf(vDef)) {
|
||||
return false;
|
||||
}
|
||||
// The exception is when deep is true; then, we recursively check all
|
||||
// fields.
|
||||
if (!deep) {
|
||||
return true;
|
||||
}
|
||||
// Use the more specific Def (vDef) to perform the deep check, but
|
||||
// shallow-check fields defined by the less specific Def (this).
|
||||
return vDef.checkAllFields(value, deep)
|
||||
&& this.checkAllFields(value, false);
|
||||
};
|
||||
DefImpl.prototype.build = function () {
|
||||
var _this = this;
|
||||
var buildParams = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
buildParams[_i] = arguments[_i];
|
||||
}
|
||||
// Calling Def.prototype.build multiple times has the effect of merely
|
||||
// redefining this property.
|
||||
this.buildParams = buildParams;
|
||||
if (this.buildable) {
|
||||
// If this Def is already buildable, update self.buildParams and
|
||||
// continue using the old builder function.
|
||||
return this;
|
||||
}
|
||||
// Every buildable type will have its "type" field filled in
|
||||
// automatically. This includes types that are not subtypes of Node,
|
||||
// like SourceLocation, but that seems harmless (TODO?).
|
||||
this.field("type", String, function () { return _this.typeName; });
|
||||
// Override Dp.buildable for this Def instance.
|
||||
this.buildable = true;
|
||||
var addParam = function (built, param, arg, isArgAvailable) {
|
||||
if (hasOwn.call(built, param))
|
||||
return;
|
||||
var all = _this.allFields;
|
||||
if (!hasOwn.call(all, param)) {
|
||||
throw new Error("" + param);
|
||||
}
|
||||
var field = all[param];
|
||||
var type = field.type;
|
||||
var value;
|
||||
if (isArgAvailable) {
|
||||
value = arg;
|
||||
}
|
||||
else if (field.defaultFn) {
|
||||
// Expose the partially-built object to the default
|
||||
// function as its `this` object.
|
||||
value = field.defaultFn.call(built);
|
||||
}
|
||||
else {
|
||||
var message = "no value or default function given for field " +
|
||||
JSON.stringify(param) + " of " + _this.typeName + "(" +
|
||||
_this.buildParams.map(function (name) {
|
||||
return all[name];
|
||||
}).join(", ") + ")";
|
||||
throw new Error(message);
|
||||
}
|
||||
if (!type.check(value)) {
|
||||
throw new Error(shallowStringify(value) +
|
||||
" does not match field " + field +
|
||||
" of type " + _this.typeName);
|
||||
}
|
||||
built[param] = value;
|
||||
};
|
||||
// Calling the builder function will construct an instance of the Def,
|
||||
// with positional arguments mapped to the fields original passed to .build.
|
||||
// If not enough arguments are provided, the default value for the remaining fields
|
||||
// will be used.
|
||||
var builder = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var argc = args.length;
|
||||
if (!_this.finalized) {
|
||||
throw new Error("attempting to instantiate unfinalized type " +
|
||||
_this.typeName);
|
||||
}
|
||||
var built = Object.create(nodePrototype);
|
||||
_this.buildParams.forEach(function (param, i) {
|
||||
if (i < argc) {
|
||||
addParam(built, param, args[i], true);
|
||||
}
|
||||
else {
|
||||
addParam(built, param, null, false);
|
||||
}
|
||||
});
|
||||
Object.keys(_this.allFields).forEach(function (param) {
|
||||
// Use the default value.
|
||||
addParam(built, param, null, false);
|
||||
});
|
||||
// Make sure that the "type" field was filled automatically.
|
||||
if (built.type !== _this.typeName) {
|
||||
throw new Error("");
|
||||
}
|
||||
return built;
|
||||
};
|
||||
// Calling .from on the builder function will construct an instance of the Def,
|
||||
// using field values from the passed object. For fields missing from the passed object,
|
||||
// their default value will be used.
|
||||
builder.from = function (obj) {
|
||||
if (!_this.finalized) {
|
||||
throw new Error("attempting to instantiate unfinalized type " +
|
||||
_this.typeName);
|
||||
}
|
||||
var built = Object.create(nodePrototype);
|
||||
Object.keys(_this.allFields).forEach(function (param) {
|
||||
if (hasOwn.call(obj, param)) {
|
||||
addParam(built, param, obj[param], true);
|
||||
}
|
||||
else {
|
||||
addParam(built, param, null, false);
|
||||
}
|
||||
});
|
||||
// Make sure that the "type" field was filled automatically.
|
||||
if (built.type !== _this.typeName) {
|
||||
throw new Error("");
|
||||
}
|
||||
return built;
|
||||
};
|
||||
Object.defineProperty(builders, getBuilderName(this.typeName), {
|
||||
enumerable: true,
|
||||
value: builder
|
||||
});
|
||||
return this;
|
||||
};
|
||||
// The reason fields are specified using .field(...) instead of an object
|
||||
// literal syntax is somewhat subtle: the object literal syntax would
|
||||
// support only one key and one value, but with .field(...) we can pass
|
||||
// any number of arguments to specify the field.
|
||||
DefImpl.prototype.field = function (name, type, defaultFn, hidden) {
|
||||
if (this.finalized) {
|
||||
console.error("Ignoring attempt to redefine field " +
|
||||
JSON.stringify(name) + " of finalized type " +
|
||||
JSON.stringify(this.typeName));
|
||||
return this;
|
||||
}
|
||||
this.ownFields[name] = new Field(name, Type.from(type), defaultFn, hidden);
|
||||
return this; // For chaining.
|
||||
};
|
||||
DefImpl.prototype.finalize = function () {
|
||||
var _this = this;
|
||||
// It's not an error to finalize a type more than once, but only the
|
||||
// first call to .finalize does anything.
|
||||
if (!this.finalized) {
|
||||
var allFields = this.allFields;
|
||||
var allSupertypes = this.allSupertypes;
|
||||
this.baseNames.forEach(function (name) {
|
||||
var def = defCache[name];
|
||||
if (def instanceof Def) {
|
||||
def.finalize();
|
||||
extend(allFields, def.allFields);
|
||||
extend(allSupertypes, def.allSupertypes);
|
||||
}
|
||||
else {
|
||||
var message = "unknown supertype name " +
|
||||
JSON.stringify(name) +
|
||||
" for subtype " +
|
||||
JSON.stringify(_this.typeName);
|
||||
throw new Error(message);
|
||||
}
|
||||
});
|
||||
// TODO Warn if fields are overridden with incompatible types.
|
||||
extend(allFields, this.ownFields);
|
||||
allSupertypes[this.typeName] = this;
|
||||
this.fieldNames.length = 0;
|
||||
for (var fieldName in allFields) {
|
||||
if (hasOwn.call(allFields, fieldName) &&
|
||||
!allFields[fieldName].hidden) {
|
||||
this.fieldNames.push(fieldName);
|
||||
}
|
||||
}
|
||||
// Types are exported only once they have been finalized.
|
||||
Object.defineProperty(namedTypes, this.typeName, {
|
||||
enumerable: true,
|
||||
value: this.type
|
||||
});
|
||||
this.finalized = true;
|
||||
// A linearization of the inheritance hierarchy.
|
||||
populateSupertypeList(this.typeName, this.supertypeList);
|
||||
if (this.buildable &&
|
||||
this.supertypeList.lastIndexOf("Expression") >= 0) {
|
||||
wrapExpressionBuilderWithStatement(this.typeName);
|
||||
}
|
||||
}
|
||||
};
|
||||
return DefImpl;
|
||||
}(Def));
|
||||
// Note that the list returned by this function is a copy of the internal
|
||||
// supertypeList, *without* the typeName itself as the first element.
|
||||
function getSupertypeNames(typeName) {
|
||||
if (!hasOwn.call(defCache, typeName)) {
|
||||
throw new Error("");
|
||||
}
|
||||
var d = defCache[typeName];
|
||||
if (d.finalized !== true) {
|
||||
throw new Error("");
|
||||
}
|
||||
return d.supertypeList.slice(1);
|
||||
}
|
||||
// Returns an object mapping from every known type in the defCache to the
|
||||
// most specific supertype whose name is an own property of the candidates
|
||||
// object.
|
||||
function computeSupertypeLookupTable(candidates) {
|
||||
var table = {};
|
||||
var typeNames = Object.keys(defCache);
|
||||
var typeNameCount = typeNames.length;
|
||||
for (var i = 0; i < typeNameCount; ++i) {
|
||||
var typeName = typeNames[i];
|
||||
var d = defCache[typeName];
|
||||
if (d.finalized !== true) {
|
||||
throw new Error("" + typeName);
|
||||
}
|
||||
for (var j = 0; j < d.supertypeList.length; ++j) {
|
||||
var superTypeName = d.supertypeList[j];
|
||||
if (hasOwn.call(candidates, superTypeName)) {
|
||||
table[typeName] = superTypeName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return table;
|
||||
}
|
||||
var builders = Object.create(null);
|
||||
// This object is used as prototype for any node created by a builder.
|
||||
var nodePrototype = {};
|
||||
// Call this function to define a new method to be shared by all AST
|
||||
// nodes. The replaced method (if any) is returned for easy wrapping.
|
||||
function defineMethod(name, func) {
|
||||
var old = nodePrototype[name];
|
||||
// Pass undefined as func to delete nodePrototype[name].
|
||||
if (isUndefined.check(func)) {
|
||||
delete nodePrototype[name];
|
||||
}
|
||||
else {
|
||||
isFunction.assert(func);
|
||||
Object.defineProperty(nodePrototype, name, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: func
|
||||
});
|
||||
}
|
||||
return old;
|
||||
}
|
||||
function getBuilderName(typeName) {
|
||||
return typeName.replace(/^[A-Z]+/, function (upperCasePrefix) {
|
||||
var len = upperCasePrefix.length;
|
||||
switch (len) {
|
||||
case 0: return "";
|
||||
// If there's only one initial capital letter, just lower-case it.
|
||||
case 1: return upperCasePrefix.toLowerCase();
|
||||
default:
|
||||
// If there's more than one initial capital letter, lower-case
|
||||
// all but the last one, so that XMLDefaultDeclaration (for
|
||||
// example) becomes xmlDefaultDeclaration.
|
||||
return upperCasePrefix.slice(0, len - 1).toLowerCase() +
|
||||
upperCasePrefix.charAt(len - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
function getStatementBuilderName(typeName) {
|
||||
typeName = getBuilderName(typeName);
|
||||
return typeName.replace(/(Expression)?$/, "Statement");
|
||||
}
|
||||
var namedTypes = {};
|
||||
// Like Object.keys, but aware of what fields each AST type should have.
|
||||
function getFieldNames(object) {
|
||||
var d = defFromValue(object);
|
||||
if (d) {
|
||||
return d.fieldNames.slice(0);
|
||||
}
|
||||
if ("type" in object) {
|
||||
throw new Error("did not recognize object of type " +
|
||||
JSON.stringify(object.type));
|
||||
}
|
||||
return Object.keys(object);
|
||||
}
|
||||
// Get the value of an object property, taking object.type and default
|
||||
// functions into account.
|
||||
function getFieldValue(object, fieldName) {
|
||||
var d = defFromValue(object);
|
||||
if (d) {
|
||||
var field = d.allFields[fieldName];
|
||||
if (field) {
|
||||
return field.getValue(object);
|
||||
}
|
||||
}
|
||||
return object && object[fieldName];
|
||||
}
|
||||
// Iterate over all defined fields of an object, including those missing
|
||||
// or undefined, passing each field name and effective value (as returned
|
||||
// by getFieldValue) to the callback. If the object has no corresponding
|
||||
// Def, the callback will never be called.
|
||||
function eachField(object, callback, context) {
|
||||
getFieldNames(object).forEach(function (name) {
|
||||
callback.call(this, name, getFieldValue(object, name));
|
||||
}, context);
|
||||
}
|
||||
// Similar to eachField, except that iteration stops as soon as the
|
||||
// callback returns a truthy value. Like Array.prototype.some, the final
|
||||
// result is either true or false to indicates whether the callback
|
||||
// returned true for any element or not.
|
||||
function someField(object, callback, context) {
|
||||
return getFieldNames(object).some(function (name) {
|
||||
return callback.call(this, name, getFieldValue(object, name));
|
||||
}, context);
|
||||
}
|
||||
// Adds an additional builder for Expression subtypes
|
||||
// that wraps the built Expression in an ExpressionStatements.
|
||||
function wrapExpressionBuilderWithStatement(typeName) {
|
||||
var wrapperName = getStatementBuilderName(typeName);
|
||||
// skip if the builder already exists
|
||||
if (builders[wrapperName])
|
||||
return;
|
||||
// the builder function to wrap with builders.ExpressionStatement
|
||||
var wrapped = builders[getBuilderName(typeName)];
|
||||
// skip if there is nothing to wrap
|
||||
if (!wrapped)
|
||||
return;
|
||||
var builder = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return builders.expressionStatement(wrapped.apply(builders, args));
|
||||
};
|
||||
builder.from = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return builders.expressionStatement(wrapped.from.apply(builders, args));
|
||||
};
|
||||
builders[wrapperName] = builder;
|
||||
}
|
||||
function populateSupertypeList(typeName, list) {
|
||||
list.length = 0;
|
||||
list.push(typeName);
|
||||
var lastSeen = Object.create(null);
|
||||
for (var pos = 0; pos < list.length; ++pos) {
|
||||
typeName = list[pos];
|
||||
var d = defCache[typeName];
|
||||
if (d.finalized !== true) {
|
||||
throw new Error("");
|
||||
}
|
||||
// If we saw typeName earlier in the breadth-first traversal,
|
||||
// delete the last-seen occurrence.
|
||||
if (hasOwn.call(lastSeen, typeName)) {
|
||||
delete list[lastSeen[typeName]];
|
||||
}
|
||||
// Record the new index of the last-seen occurrence of typeName.
|
||||
lastSeen[typeName] = pos;
|
||||
// Enqueue the base names of this type.
|
||||
list.push.apply(list, d.baseNames);
|
||||
}
|
||||
// Compaction loop to remove array holes.
|
||||
for (var to = 0, from = to, len = list.length; from < len; ++from) {
|
||||
if (hasOwn.call(list, from)) {
|
||||
list[to++] = list[from];
|
||||
}
|
||||
}
|
||||
list.length = to;
|
||||
}
|
||||
function extend(into, from) {
|
||||
Object.keys(from).forEach(function (name) {
|
||||
into[name] = from[name];
|
||||
});
|
||||
return into;
|
||||
}
|
||||
function finalize() {
|
||||
Object.keys(defCache).forEach(function (name) {
|
||||
defCache[name].finalize();
|
||||
});
|
||||
}
|
||||
return {
|
||||
Type: Type,
|
||||
builtInTypes: builtInTypes,
|
||||
getSupertypeNames: getSupertypeNames,
|
||||
computeSupertypeLookupTable: computeSupertypeLookupTable,
|
||||
builders: builders,
|
||||
defineMethod: defineMethod,
|
||||
getBuilderName: getBuilderName,
|
||||
getStatementBuilderName: getStatementBuilderName,
|
||||
namedTypes: namedTypes,
|
||||
getFieldNames: getFieldNames,
|
||||
getFieldValue: getFieldValue,
|
||||
eachField: eachField,
|
||||
someField: someField,
|
||||
finalize: finalize,
|
||||
};
|
||||
}
|
||||
exports.default = typesPlugin;
|
||||
;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"B","2":"J D CC","66":"E F A"},B:{"1":"C K L G M 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"},C:{"1":"3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB 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 I v J D E F A B C K L G M N O w g x y z EC FC","66":"0 1 2"},D:{"1":"5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB 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","2":"0 1 2 3 4 I v J D E F A B C K L G M N O w g x y z"},E:{"1":"D E F A B C K L G KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J HC zB IC JC"},F:{"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 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 G PC","66":"B C QC RC SC qB AC TC rB"},G:{"1":"E 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","2":"zB UC BC"},H:{"1":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"1":"A","2":"D"},K:{"1":"h rB","2":"A B C qB AC"},L:{"1":"H"},M:{"1":"H"},N:{"1":"B","66":"A"},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:6,C:"TLS 1.2"};
|
||||
@@ -0,0 +1 @@
|
||||
@tailwind variants;
|
||||
@@ -0,0 +1,10 @@
|
||||
import { MonoTypeOperatorFunction, Observer } from '../types';
|
||||
export interface TapObserver<T> extends Observer<T> {
|
||||
subscribe: () => void;
|
||||
unsubscribe: () => void;
|
||||
finalize: () => void;
|
||||
}
|
||||
export declare function tap<T>(observerOrNext?: Partial<TapObserver<T>> | ((value: T) => void)): MonoTypeOperatorFunction<T>;
|
||||
/** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */
|
||||
export declare function tap<T>(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): MonoTypeOperatorFunction<T>;
|
||||
//# sourceMappingURL=tap.d.ts.map
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Special language-specific overrides.
|
||||
*
|
||||
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
var LANGUAGES = {
|
||||
tr: {
|
||||
regexp: /[\u0069]/g,
|
||||
map: {
|
||||
'\u0069': '\u0130'
|
||||
}
|
||||
},
|
||||
az: {
|
||||
regexp: /[\u0069]/g,
|
||||
map: {
|
||||
'\u0069': '\u0130'
|
||||
}
|
||||
},
|
||||
lt: {
|
||||
regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
|
||||
map: {
|
||||
'\u0069\u0307': '\u0049',
|
||||
'\u006A\u0307': '\u004A',
|
||||
'\u012F\u0307': '\u012E',
|
||||
'\u0069\u0307\u0300': '\u00CC',
|
||||
'\u0069\u0307\u0301': '\u00CD',
|
||||
'\u0069\u0307\u0303': '\u0128'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upper case a string.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
*/
|
||||
module.exports = function (str, locale) {
|
||||
var lang = LANGUAGES[locale]
|
||||
|
||||
str = str == null ? '' : String(str)
|
||||
|
||||
if (lang) {
|
||||
str = str.replace(lang.regexp, function (m) { return lang.map[m] })
|
||||
}
|
||||
|
||||
return str.toUpperCase()
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
var baseGet = require('./_baseGet');
|
||||
|
||||
/**
|
||||
* Gets the value at `path` of `object`. If the resolved value is
|
||||
* `undefined`, the `defaultValue` is returned in its place.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.7.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Array|string} path The path of the property to get.
|
||||
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
||||
* @returns {*} Returns the resolved value.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
*
|
||||
* _.get(object, 'a[0].b.c');
|
||||
* // => 3
|
||||
*
|
||||
* _.get(object, ['a', '0', 'b', 'c']);
|
||||
* // => 3
|
||||
*
|
||||
* _.get(object, 'a.b.c', 'default');
|
||||
* // => 'default'
|
||||
*/
|
||||
function get(object, path, defaultValue) {
|
||||
var result = object == null ? undefined : baseGet(object, path);
|
||||
return result === undefined ? defaultValue : result;
|
||||
}
|
||||
|
||||
module.exports = get;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { request as Request } from "@octokit/request";
|
||||
import { graphql as ApiInterface, RequestParameters } from "./types";
|
||||
export declare function withDefaults(request: typeof Request, newDefaults: RequestParameters): ApiInterface;
|
||||
@@ -0,0 +1,203 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const events_1 = require("events");
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const promisify_1 = __importDefault(require("./promisify"));
|
||||
const debug = debug_1.default('agent-base');
|
||||
function isAgent(v) {
|
||||
return Boolean(v) && typeof v.addRequest === 'function';
|
||||
}
|
||||
function isSecureEndpoint() {
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string')
|
||||
return false;
|
||||
return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
function createAgent(callback, opts) {
|
||||
return new createAgent.Agent(callback, opts);
|
||||
}
|
||||
(function (createAgent) {
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
class Agent extends events_1.EventEmitter {
|
||||
constructor(callback, _opts) {
|
||||
super();
|
||||
let opts = _opts;
|
||||
if (typeof callback === 'function') {
|
||||
this.callback = callback;
|
||||
}
|
||||
else if (callback) {
|
||||
opts = callback;
|
||||
}
|
||||
// Timeout for the socket to be returned from the callback
|
||||
this.timeout = null;
|
||||
if (opts && typeof opts.timeout === 'number') {
|
||||
this.timeout = opts.timeout;
|
||||
}
|
||||
// These aren't actually used by `agent-base`, but are required
|
||||
// for the TypeScript definition files in `@types/node` :/
|
||||
this.maxFreeSockets = 1;
|
||||
this.maxSockets = 1;
|
||||
this.maxTotalSockets = Infinity;
|
||||
this.sockets = {};
|
||||
this.freeSockets = {};
|
||||
this.requests = {};
|
||||
this.options = {};
|
||||
}
|
||||
get defaultPort() {
|
||||
if (typeof this.explicitDefaultPort === 'number') {
|
||||
return this.explicitDefaultPort;
|
||||
}
|
||||
return isSecureEndpoint() ? 443 : 80;
|
||||
}
|
||||
set defaultPort(v) {
|
||||
this.explicitDefaultPort = v;
|
||||
}
|
||||
get protocol() {
|
||||
if (typeof this.explicitProtocol === 'string') {
|
||||
return this.explicitProtocol;
|
||||
}
|
||||
return isSecureEndpoint() ? 'https:' : 'http:';
|
||||
}
|
||||
set protocol(v) {
|
||||
this.explicitProtocol = v;
|
||||
}
|
||||
callback(req, opts, fn) {
|
||||
throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
|
||||
}
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
addRequest(req, _opts) {
|
||||
const opts = Object.assign({}, _opts);
|
||||
if (typeof opts.secureEndpoint !== 'boolean') {
|
||||
opts.secureEndpoint = isSecureEndpoint();
|
||||
}
|
||||
if (opts.host == null) {
|
||||
opts.host = 'localhost';
|
||||
}
|
||||
if (opts.port == null) {
|
||||
opts.port = opts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
if (opts.protocol == null) {
|
||||
opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
|
||||
}
|
||||
if (opts.host && opts.path) {
|
||||
// If both a `host` and `path` are specified then it's most
|
||||
// likely the result of a `url.parse()` call... we need to
|
||||
// remove the `path` portion so that `net.connect()` doesn't
|
||||
// attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
// Hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
let timedOut = false;
|
||||
let timeoutId = null;
|
||||
const timeoutMs = opts.timeout || this.timeout;
|
||||
const onerror = (err) => {
|
||||
if (req._hadError)
|
||||
return;
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
};
|
||||
const ontimeout = () => {
|
||||
timeoutId = null;
|
||||
timedOut = true;
|
||||
const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
|
||||
err.code = 'ETIMEOUT';
|
||||
onerror(err);
|
||||
};
|
||||
const callbackError = (err) => {
|
||||
if (timedOut)
|
||||
return;
|
||||
if (timeoutId !== null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
onerror(err);
|
||||
};
|
||||
const onsocket = (socket) => {
|
||||
if (timedOut)
|
||||
return;
|
||||
if (timeoutId != null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
if (isAgent(socket)) {
|
||||
// `socket` is actually an `http.Agent` instance, so
|
||||
// relinquish responsibility for this `req` to the Agent
|
||||
// from here on
|
||||
debug('Callback returned another Agent instance %o', socket.constructor.name);
|
||||
socket.addRequest(req, opts);
|
||||
return;
|
||||
}
|
||||
if (socket) {
|
||||
socket.once('free', () => {
|
||||
this.freeSocket(socket, opts);
|
||||
});
|
||||
req.onSocket(socket);
|
||||
return;
|
||||
}
|
||||
const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
|
||||
onerror(err);
|
||||
};
|
||||
if (typeof this.callback !== 'function') {
|
||||
onerror(new Error('`callback` is not defined'));
|
||||
return;
|
||||
}
|
||||
if (!this.promisifiedCallback) {
|
||||
if (this.callback.length >= 3) {
|
||||
debug('Converting legacy callback function to promise');
|
||||
this.promisifiedCallback = promisify_1.default(this.callback);
|
||||
}
|
||||
else {
|
||||
this.promisifiedCallback = this.callback;
|
||||
}
|
||||
}
|
||||
if (typeof timeoutMs === 'number' && timeoutMs > 0) {
|
||||
timeoutId = setTimeout(ontimeout, timeoutMs);
|
||||
}
|
||||
if ('port' in opts && typeof opts.port !== 'number') {
|
||||
opts.port = Number(opts.port);
|
||||
}
|
||||
try {
|
||||
debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
|
||||
Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
|
||||
}
|
||||
catch (err) {
|
||||
Promise.reject(err).catch(callbackError);
|
||||
}
|
||||
}
|
||||
freeSocket(socket, opts) {
|
||||
debug('Freeing socket %o %o', socket.constructor.name, opts);
|
||||
socket.destroy();
|
||||
}
|
||||
destroy() {
|
||||
debug('Destroying agent %o', this.constructor.name);
|
||||
}
|
||||
}
|
||||
createAgent.Agent = Agent;
|
||||
// So that `instanceof` works correctly
|
||||
createAgent.prototype = createAgent.Agent.prototype;
|
||||
})(createAgent || (createAgent = {}));
|
||||
module.exports = createAgent;
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1,22 @@
|
||||
interface Timing {
|
||||
label: string;
|
||||
start: number;
|
||||
end: number;
|
||||
children: Timing[];
|
||||
}
|
||||
export default class Stats {
|
||||
start_time: number;
|
||||
current_timing: Timing;
|
||||
current_children: Timing[];
|
||||
timings: Timing[];
|
||||
stack: Timing[];
|
||||
constructor();
|
||||
start(label: any): void;
|
||||
stop(label: any): void;
|
||||
render(): {
|
||||
timings: {
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
export {};
|
||||
Reference in New Issue
Block a user