new license file version [CI SKIP]

This commit is contained in:
2023-03-15 12:34:41 +00:00
parent 0a6d92a1f3
commit 61328d20ed
13115 changed files with 1892314 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
if(typeof cptable === 'undefined') cptable = {};
cptable[28596] = (function(){ var d = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ <C29F><C2A0><EFBFBD>¤<EFBFBD><C2A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>،­<D88C><C2AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>؛<EFBFBD><D89B><EFBFBD>؟<EFBFBD>ءآأؤإئابةتثجحخدذرزسشصضطظعغ<D8B9><D8BA><EFBFBD><EFBFBD><EFBFBD>ـفقكلمنهوىيًٌٍَُِّْ<D991><D992><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 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 }; })();

View File

@@ -0,0 +1,34 @@
{
"name": "mousetrap",
"version": "1.6.5",
"description": "Simple library for handling keyboard shortcuts",
"main": "mousetrap.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "mocha --reporter=nyan tests/test.mousetrap.js"
},
"repository": {
"type": "git",
"url": "git://github.com/ccampbell/mousetrap.git"
},
"keywords": [
"keyboard",
"shortcuts",
"events"
],
"author": "Craig Campbell",
"license": "Apache-2.0 WITH LLVM-exception",
"gitHead": "c202a0bd4967d5a3064f9cb376db51dec9345336",
"readmeFilename": "README.md",
"devDependencies": {
"chai": "^4.2.0",
"grunt": "~1.0.3",
"grunt-complexity": "~1.1.0",
"jsdom": "^13.1.0",
"jsdom-global": "^3.0.2",
"mocha": "^5.2.0",
"sinon": "^7.2.2"
}
}

View File

@@ -0,0 +1,58 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
var Call = require('./Call');
var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow');
var Get = require('./Get');
var HasProperty = require('./HasProperty');
var IsArray = require('./IsArray');
var ToLength = require('./ToLength');
var ToString = require('./ToString');
// https://262.ecma-international.org/10.0/#sec-flattenintoarray
// eslint-disable-next-line max-params
module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) {
var mapperFunction;
if (arguments.length > 5) {
mapperFunction = arguments[5];
}
var targetIndex = start;
var sourceIndex = 0;
while (sourceIndex < sourceLen) {
var P = ToString(sourceIndex);
var exists = HasProperty(source, P);
if (exists === true) {
var element = Get(source, P);
if (typeof mapperFunction !== 'undefined') {
if (arguments.length <= 6) {
throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided');
}
element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]);
}
var shouldFlatten = false;
if (depth > 0) {
shouldFlatten = IsArray(element);
}
if (shouldFlatten) {
var elementLen = ToLength(Get(element, 'length'));
targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1);
} else {
if (targetIndex >= MAX_SAFE_INTEGER) {
throw new $TypeError('index too large');
}
CreateDataPropertyOrThrow(target, ToString(targetIndex), element);
targetIndex += 1;
}
}
sourceIndex += 1;
}
return targetIndex;
};

View File

@@ -0,0 +1,5 @@
var convert = require('./convert'),
func = convert('isElement', require('../isElement'), require('./_falseOptions'));
func.placeholder = require('./placeholder');
module.exports = func;

View File

@@ -0,0 +1 @@
{"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/types/date-time.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO,GAAG,IAAI,CACxB,IAAI,CAAC,qBAAqB,EACxB,SAAS,GACT,KAAK,GACL,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,cAAc,CACjB,GAAG;IACF,sBAAsB,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAClC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,EAAE,aAAa,CAAC,CAAA;IACzD,eAAe,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,EAAE,aAAa,CAAC,CAAA;CAC5D,CAAA;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IAChD,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACpC,GAAG,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IAChC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAA;IAC3B,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IAC1D,GAAG,EAAE,SAAS,GAAG,SAAS,CAAA;IAC1B,SAAS,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACtC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAA;IAC3B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;IAC7B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;IAC7B,YAAY,EAAE,OAAO,GAAG,MAAM,CAAA;IAC9B,sBAAsB,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,EAAE,aAAa,CAAC,CAAA;IACzD,WAAW,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;CAC5C;AAED,MAAM,WAAW,gBAAgB,CAC/B,CAAC,SAAS,gBAAgB,GAAG,gBAAgB;IAE7C,MAAM,EAAE,CAAC,CAAA;IACT,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,oBAAY,aAAa,GAAG,IAAI,CAC9B,IAAI,CAAC,qBAAqB,EACxB,SAAS,GACT,KAAK,GACL,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,cAAc,CACjB,GAAG;IACF,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAA;CACtC,CAAA;AAED,oBAAY,gBAAgB;IAC1B,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,oBAAY,OAAO,GACf,SAAS,GACT,KAAK,GACL,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,wBAAwB,GACxB,cAAc,CAAA;AAElB,oBAAY,OAAO,GACf,KAAK,GACL,MAAM,GACN,OAAO,GACP,KAAK,GACL,WAAW,GACX,MAAM,GACN,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,wBAAwB,CAAA;AAE5B,oBAAY,gBAAgB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzB,CACF,CAAA;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,gCAAgC;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,KAAK,EAAE,MAAM,EAAE,CAAA;KAChB,CAAA;IACD,GAAG,EAAE;QACH,MAAM,EAAE,OAAO,CAAA;QACf,IAAI,EAAE,OAAO,CAAA;QACb,KAAK,EAAE,OAAO,CAAA;KACf,CAAA;IACD,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,KAAK,EAAE,MAAM,EAAE,CAAA;KAChB,CAAA;IACD,YAAY,EAAE,gBAAgB,CAAA;IAC9B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAC,CAAA;IAC3E,UAAU,EAAE;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAC,CAAA;IAC3E,cAAc,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAA;IAC3E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;IAClC,EAAE,EAAE,MAAM,EAAE,CAAA;IACZ,EAAE,EAAE,MAAM,EAAE,CAAA;IACZ,EAAE,EAAE,MAAM,EAAE,CAAA;CACb;AAED,oBAAY,mBAAmB,GAAG;IAChC,sBAAsB,EAAE,MAAM,CAAA;CAC/B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAE1C,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC;IACpD,eAAe,IAAI,6BAA6B,CAAA;IAChD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAA;IACrE,kBAAkB,CAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,sBAAsB,EAAE,CAAA;CAC5B;AAED,MAAM,WAAW,6BACf,SAAQ,IAAI,CAAC,6BAA6B;IAC1C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IAChD,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,oBAAY,gBAAgB,GAAG;IAE7B,MAAM;IAEN,MAAM;IAEN,MAAM;IAEN,OAAO;CACR,CAAA;AAED,oBAAY,0BAA0B,GAClC,IAAI,CAAC,uBAAuB,GAC5B,MAAM,GACN,aAAa,GACb,UAAU,GACV,SAAS,GACT,wBAAwB,CAAA;AAE5B,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,0BAA0B,CAAA;IAChC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAC1B"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"Explorer.d.ts","sourceRoot":"","sources":["../src/Explorer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;AAEhF,cAAM,QAAS,SAAQ,YAAY,CAAC,eAAe,CAAC;gBAC/B,OAAO,EAAE,eAAe;IAI9B,MAAM,CACjB,UAAU,GAAE,MAAsB,GACjC,OAAO,CAAC,iBAAiB,CAAC;YAUf,mBAAmB;YAqBnB,eAAe;YAaf,eAAe;YAUf,eAAe;YAmBf,uBAAuB;IAcxB,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAIjD,SAAS;CA2BxB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}

View File

@@ -0,0 +1,868 @@
/* MIT license */
var cssKeywords = require('color-name');
// NOTE: conversions should only return primitive values (i.e. arrays, or
// values that give correct `typeof` results).
// do not use box values types (i.e. Number(), String(), etc.)
var reverseKeywords = {};
for (var key in cssKeywords) {
if (cssKeywords.hasOwnProperty(key)) {
reverseKeywords[cssKeywords[key]] = key;
}
}
var convert = module.exports = {
rgb: {channels: 3, labels: 'rgb'},
hsl: {channels: 3, labels: 'hsl'},
hsv: {channels: 3, labels: 'hsv'},
hwb: {channels: 3, labels: 'hwb'},
cmyk: {channels: 4, labels: 'cmyk'},
xyz: {channels: 3, labels: 'xyz'},
lab: {channels: 3, labels: 'lab'},
lch: {channels: 3, labels: 'lch'},
hex: {channels: 1, labels: ['hex']},
keyword: {channels: 1, labels: ['keyword']},
ansi16: {channels: 1, labels: ['ansi16']},
ansi256: {channels: 1, labels: ['ansi256']},
hcg: {channels: 3, labels: ['h', 'c', 'g']},
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
gray: {channels: 1, labels: ['gray']}
};
// hide .channels and .labels properties
for (var model in convert) {
if (convert.hasOwnProperty(model)) {
if (!('channels' in convert[model])) {
throw new Error('missing channels property: ' + model);
}
if (!('labels' in convert[model])) {
throw new Error('missing channel labels property: ' + model);
}
if (convert[model].labels.length !== convert[model].channels) {
throw new Error('channel and label counts mismatch: ' + model);
}
var channels = convert[model].channels;
var labels = convert[model].labels;
delete convert[model].channels;
delete convert[model].labels;
Object.defineProperty(convert[model], 'channels', {value: channels});
Object.defineProperty(convert[model], 'labels', {value: labels});
}
}
convert.rgb.hsl = function (rgb) {
var r = rgb[0] / 255;
var g = rgb[1] / 255;
var b = rgb[2] / 255;
var min = Math.min(r, g, b);
var max = Math.max(r, g, b);
var delta = max - min;
var h;
var s;
var l;
if (max === min) {
h = 0;
} else if (r === max) {
h = (g - b) / delta;
} else if (g === max) {
h = 2 + (b - r) / delta;
} else if (b === max) {
h = 4 + (r - g) / delta;
}
h = Math.min(h * 60, 360);
if (h < 0) {
h += 360;
}
l = (min + max) / 2;
if (max === min) {
s = 0;
} else if (l <= 0.5) {
s = delta / (max + min);
} else {
s = delta / (2 - max - min);
}
return [h, s * 100, l * 100];
};
convert.rgb.hsv = function (rgb) {
var rdif;
var gdif;
var bdif;
var h;
var s;
var r = rgb[0] / 255;
var g = rgb[1] / 255;
var b = rgb[2] / 255;
var v = Math.max(r, g, b);
var diff = v - Math.min(r, g, b);
var diffc = function (c) {
return (v - c) / 6 / diff + 1 / 2;
};
if (diff === 0) {
h = s = 0;
} else {
s = diff / v;
rdif = diffc(r);
gdif = diffc(g);
bdif = diffc(b);
if (r === v) {
h = bdif - gdif;
} else if (g === v) {
h = (1 / 3) + rdif - bdif;
} else if (b === v) {
h = (2 / 3) + gdif - rdif;
}
if (h < 0) {
h += 1;
} else if (h > 1) {
h -= 1;
}
}
return [
h * 360,
s * 100,
v * 100
];
};
convert.rgb.hwb = function (rgb) {
var r = rgb[0];
var g = rgb[1];
var b = rgb[2];
var h = convert.rgb.hsl(rgb)[0];
var w = 1 / 255 * Math.min(r, Math.min(g, b));
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
return [h, w * 100, b * 100];
};
convert.rgb.cmyk = function (rgb) {
var r = rgb[0] / 255;
var g = rgb[1] / 255;
var b = rgb[2] / 255;
var c;
var m;
var y;
var k;
k = Math.min(1 - r, 1 - g, 1 - b);
c = (1 - r - k) / (1 - k) || 0;
m = (1 - g - k) / (1 - k) || 0;
y = (1 - b - k) / (1 - k) || 0;
return [c * 100, m * 100, y * 100, k * 100];
};
/**
* See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
* */
function comparativeDistance(x, y) {
return (
Math.pow(x[0] - y[0], 2) +
Math.pow(x[1] - y[1], 2) +
Math.pow(x[2] - y[2], 2)
);
}
convert.rgb.keyword = function (rgb) {
var reversed = reverseKeywords[rgb];
if (reversed) {
return reversed;
}
var currentClosestDistance = Infinity;
var currentClosestKeyword;
for (var keyword in cssKeywords) {
if (cssKeywords.hasOwnProperty(keyword)) {
var value = cssKeywords[keyword];
// Compute comparative distance
var distance = comparativeDistance(rgb, value);
// Check if its less, if so set as closest
if (distance < currentClosestDistance) {
currentClosestDistance = distance;
currentClosestKeyword = keyword;
}
}
}
return currentClosestKeyword;
};
convert.keyword.rgb = function (keyword) {
return cssKeywords[keyword];
};
convert.rgb.xyz = function (rgb) {
var r = rgb[0] / 255;
var g = rgb[1] / 255;
var b = rgb[2] / 255;
// assume sRGB
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
return [x * 100, y * 100, z * 100];
};
convert.rgb.lab = function (rgb) {
var xyz = convert.rgb.xyz(rgb);
var x = xyz[0];
var y = xyz[1];
var z = xyz[2];
var l;
var a;
var b;
x /= 95.047;
y /= 100;
z /= 108.883;
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
l = (116 * y) - 16;
a = 500 * (x - y);
b = 200 * (y - z);
return [l, a, b];
};
convert.hsl.rgb = function (hsl) {
var h = hsl[0] / 360;
var s = hsl[1] / 100;
var l = hsl[2] / 100;
var t1;
var t2;
var t3;
var rgb;
var val;
if (s === 0) {
val = l * 255;
return [val, val, val];
}
if (l < 0.5) {
t2 = l * (1 + s);
} else {
t2 = l + s - l * s;
}
t1 = 2 * l - t2;
rgb = [0, 0, 0];
for (var i = 0; i < 3; i++) {
t3 = h + 1 / 3 * -(i - 1);
if (t3 < 0) {
t3++;
}
if (t3 > 1) {
t3--;
}
if (6 * t3 < 1) {
val = t1 + (t2 - t1) * 6 * t3;
} else if (2 * t3 < 1) {
val = t2;
} else if (3 * t3 < 2) {
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
} else {
val = t1;
}
rgb[i] = val * 255;
}
return rgb;
};
convert.hsl.hsv = function (hsl) {
var h = hsl[0];
var s = hsl[1] / 100;
var l = hsl[2] / 100;
var smin = s;
var lmin = Math.max(l, 0.01);
var sv;
var v;
l *= 2;
s *= (l <= 1) ? l : 2 - l;
smin *= lmin <= 1 ? lmin : 2 - lmin;
v = (l + s) / 2;
sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
return [h, sv * 100, v * 100];
};
convert.hsv.rgb = function (hsv) {
var h = hsv[0] / 60;
var s = hsv[1] / 100;
var v = hsv[2] / 100;
var hi = Math.floor(h) % 6;
var f = h - Math.floor(h);
var p = 255 * v * (1 - s);
var q = 255 * v * (1 - (s * f));
var t = 255 * v * (1 - (s * (1 - f)));
v *= 255;
switch (hi) {
case 0:
return [v, t, p];
case 1:
return [q, v, p];
case 2:
return [p, v, t];
case 3:
return [p, q, v];
case 4:
return [t, p, v];
case 5:
return [v, p, q];
}
};
convert.hsv.hsl = function (hsv) {
var h = hsv[0];
var s = hsv[1] / 100;
var v = hsv[2] / 100;
var vmin = Math.max(v, 0.01);
var lmin;
var sl;
var l;
l = (2 - s) * v;
lmin = (2 - s) * vmin;
sl = s * vmin;
sl /= (lmin <= 1) ? lmin : 2 - lmin;
sl = sl || 0;
l /= 2;
return [h, sl * 100, l * 100];
};
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
convert.hwb.rgb = function (hwb) {
var h = hwb[0] / 360;
var wh = hwb[1] / 100;
var bl = hwb[2] / 100;
var ratio = wh + bl;
var i;
var v;
var f;
var n;
// wh + bl cant be > 1
if (ratio > 1) {
wh /= ratio;
bl /= ratio;
}
i = Math.floor(6 * h);
v = 1 - bl;
f = 6 * h - i;
if ((i & 0x01) !== 0) {
f = 1 - f;
}
n = wh + f * (v - wh); // linear interpolation
var r;
var g;
var b;
switch (i) {
default:
case 6:
case 0: r = v; g = n; b = wh; break;
case 1: r = n; g = v; b = wh; break;
case 2: r = wh; g = v; b = n; break;
case 3: r = wh; g = n; b = v; break;
case 4: r = n; g = wh; b = v; break;
case 5: r = v; g = wh; b = n; break;
}
return [r * 255, g * 255, b * 255];
};
convert.cmyk.rgb = function (cmyk) {
var c = cmyk[0] / 100;
var m = cmyk[1] / 100;
var y = cmyk[2] / 100;
var k = cmyk[3] / 100;
var r;
var g;
var b;
r = 1 - Math.min(1, c * (1 - k) + k);
g = 1 - Math.min(1, m * (1 - k) + k);
b = 1 - Math.min(1, y * (1 - k) + k);
return [r * 255, g * 255, b * 255];
};
convert.xyz.rgb = function (xyz) {
var x = xyz[0] / 100;
var y = xyz[1] / 100;
var z = xyz[2] / 100;
var r;
var g;
var b;
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
// assume sRGB
r = r > 0.0031308
? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
: r * 12.92;
g = g > 0.0031308
? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
: g * 12.92;
b = b > 0.0031308
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
: b * 12.92;
r = Math.min(Math.max(0, r), 1);
g = Math.min(Math.max(0, g), 1);
b = Math.min(Math.max(0, b), 1);
return [r * 255, g * 255, b * 255];
};
convert.xyz.lab = function (xyz) {
var x = xyz[0];
var y = xyz[1];
var z = xyz[2];
var l;
var a;
var b;
x /= 95.047;
y /= 100;
z /= 108.883;
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
l = (116 * y) - 16;
a = 500 * (x - y);
b = 200 * (y - z);
return [l, a, b];
};
convert.lab.xyz = function (lab) {
var l = lab[0];
var a = lab[1];
var b = lab[2];
var x;
var y;
var z;
y = (l + 16) / 116;
x = a / 500 + y;
z = y - b / 200;
var y2 = Math.pow(y, 3);
var x2 = Math.pow(x, 3);
var z2 = Math.pow(z, 3);
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
x *= 95.047;
y *= 100;
z *= 108.883;
return [x, y, z];
};
convert.lab.lch = function (lab) {
var l = lab[0];
var a = lab[1];
var b = lab[2];
var hr;
var h;
var c;
hr = Math.atan2(b, a);
h = hr * 360 / 2 / Math.PI;
if (h < 0) {
h += 360;
}
c = Math.sqrt(a * a + b * b);
return [l, c, h];
};
convert.lch.lab = function (lch) {
var l = lch[0];
var c = lch[1];
var h = lch[2];
var a;
var b;
var hr;
hr = h / 360 * 2 * Math.PI;
a = c * Math.cos(hr);
b = c * Math.sin(hr);
return [l, a, b];
};
convert.rgb.ansi16 = function (args) {
var r = args[0];
var g = args[1];
var b = args[2];
var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
value = Math.round(value / 50);
if (value === 0) {
return 30;
}
var ansi = 30
+ ((Math.round(b / 255) << 2)
| (Math.round(g / 255) << 1)
| Math.round(r / 255));
if (value === 2) {
ansi += 60;
}
return ansi;
};
convert.hsv.ansi16 = function (args) {
// optimization here; we already know the value and don't need to get
// it converted for us.
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
};
convert.rgb.ansi256 = function (args) {
var r = args[0];
var g = args[1];
var b = args[2];
// we use the extended greyscale palette here, with the exception of
// black and white. normal palette only has 4 greyscale shades.
if (r === g && g === b) {
if (r < 8) {
return 16;
}
if (r > 248) {
return 231;
}
return Math.round(((r - 8) / 247) * 24) + 232;
}
var ansi = 16
+ (36 * Math.round(r / 255 * 5))
+ (6 * Math.round(g / 255 * 5))
+ Math.round(b / 255 * 5);
return ansi;
};
convert.ansi16.rgb = function (args) {
var color = args % 10;
// handle greyscale
if (color === 0 || color === 7) {
if (args > 50) {
color += 3.5;
}
color = color / 10.5 * 255;
return [color, color, color];
}
var mult = (~~(args > 50) + 1) * 0.5;
var r = ((color & 1) * mult) * 255;
var g = (((color >> 1) & 1) * mult) * 255;
var b = (((color >> 2) & 1) * mult) * 255;
return [r, g, b];
};
convert.ansi256.rgb = function (args) {
// handle greyscale
if (args >= 232) {
var c = (args - 232) * 10 + 8;
return [c, c, c];
}
args -= 16;
var rem;
var r = Math.floor(args / 36) / 5 * 255;
var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
var b = (rem % 6) / 5 * 255;
return [r, g, b];
};
convert.rgb.hex = function (args) {
var integer = ((Math.round(args[0]) & 0xFF) << 16)
+ ((Math.round(args[1]) & 0xFF) << 8)
+ (Math.round(args[2]) & 0xFF);
var string = integer.toString(16).toUpperCase();
return '000000'.substring(string.length) + string;
};
convert.hex.rgb = function (args) {
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
if (!match) {
return [0, 0, 0];
}
var colorString = match[0];
if (match[0].length === 3) {
colorString = colorString.split('').map(function (char) {
return char + char;
}).join('');
}
var integer = parseInt(colorString, 16);
var r = (integer >> 16) & 0xFF;
var g = (integer >> 8) & 0xFF;
var b = integer & 0xFF;
return [r, g, b];
};
convert.rgb.hcg = function (rgb) {
var r = rgb[0] / 255;
var g = rgb[1] / 255;
var b = rgb[2] / 255;
var max = Math.max(Math.max(r, g), b);
var min = Math.min(Math.min(r, g), b);
var chroma = (max - min);
var grayscale;
var hue;
if (chroma < 1) {
grayscale = min / (1 - chroma);
} else {
grayscale = 0;
}
if (chroma <= 0) {
hue = 0;
} else
if (max === r) {
hue = ((g - b) / chroma) % 6;
} else
if (max === g) {
hue = 2 + (b - r) / chroma;
} else {
hue = 4 + (r - g) / chroma + 4;
}
hue /= 6;
hue %= 1;
return [hue * 360, chroma * 100, grayscale * 100];
};
convert.hsl.hcg = function (hsl) {
var s = hsl[1] / 100;
var l = hsl[2] / 100;
var c = 1;
var f = 0;
if (l < 0.5) {
c = 2.0 * s * l;
} else {
c = 2.0 * s * (1.0 - l);
}
if (c < 1.0) {
f = (l - 0.5 * c) / (1.0 - c);
}
return [hsl[0], c * 100, f * 100];
};
convert.hsv.hcg = function (hsv) {
var s = hsv[1] / 100;
var v = hsv[2] / 100;
var c = s * v;
var f = 0;
if (c < 1.0) {
f = (v - c) / (1 - c);
}
return [hsv[0], c * 100, f * 100];
};
convert.hcg.rgb = function (hcg) {
var h = hcg[0] / 360;
var c = hcg[1] / 100;
var g = hcg[2] / 100;
if (c === 0.0) {
return [g * 255, g * 255, g * 255];
}
var pure = [0, 0, 0];
var hi = (h % 1) * 6;
var v = hi % 1;
var w = 1 - v;
var mg = 0;
switch (Math.floor(hi)) {
case 0:
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
case 1:
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
case 2:
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
case 3:
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
case 4:
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
default:
pure[0] = 1; pure[1] = 0; pure[2] = w;
}
mg = (1.0 - c) * g;
return [
(c * pure[0] + mg) * 255,
(c * pure[1] + mg) * 255,
(c * pure[2] + mg) * 255
];
};
convert.hcg.hsv = function (hcg) {
var c = hcg[1] / 100;
var g = hcg[2] / 100;
var v = c + g * (1.0 - c);
var f = 0;
if (v > 0.0) {
f = c / v;
}
return [hcg[0], f * 100, v * 100];
};
convert.hcg.hsl = function (hcg) {
var c = hcg[1] / 100;
var g = hcg[2] / 100;
var l = g * (1.0 - c) + 0.5 * c;
var s = 0;
if (l > 0.0 && l < 0.5) {
s = c / (2 * l);
} else
if (l >= 0.5 && l < 1.0) {
s = c / (2 * (1 - l));
}
return [hcg[0], s * 100, l * 100];
};
convert.hcg.hwb = function (hcg) {
var c = hcg[1] / 100;
var g = hcg[2] / 100;
var v = c + g * (1.0 - c);
return [hcg[0], (v - c) * 100, (1 - v) * 100];
};
convert.hwb.hcg = function (hwb) {
var w = hwb[1] / 100;
var b = hwb[2] / 100;
var v = 1 - b;
var c = v - w;
var g = 0;
if (c < 1) {
g = (v - c) / (1 - c);
}
return [hwb[0], c * 100, g * 100];
};
convert.apple.rgb = function (apple) {
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
};
convert.rgb.apple = function (rgb) {
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
};
convert.gray.rgb = function (args) {
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
};
convert.gray.hsl = convert.gray.hsv = function (args) {
return [0, 0, args[0]];
};
convert.gray.hwb = function (gray) {
return [0, 100, gray[0]];
};
convert.gray.cmyk = function (gray) {
return [0, 0, 0, gray[0]];
};
convert.gray.lab = function (gray) {
return [gray[0], 0, 0];
};
convert.gray.hex = function (gray) {
var val = Math.round(gray[0] / 100 * 255) & 0xFF;
var integer = (val << 16) + (val << 8) + val;
var string = integer.toString(16).toUpperCase();
return '000000'.substring(string.length) + string;
};
convert.rgb.gray = function (rgb) {
var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
return [val / 255 * 100];
};

View File

@@ -0,0 +1,191 @@
import type {StringDigit} from '../source/internal';
import type {Split} from './split';
import type {StringKeyOf} from './string-key-of';
type GetOptions = {
/**
Include `undefined` in the return type when accessing properties.
Setting this to `false` is not recommended.
@default true
*/
strict?: boolean;
};
/**
Like the `Get` type but receives an array of strings as a path parameter.
*/
type GetWithPath<BaseType, Keys extends readonly string[], Options extends GetOptions = {}> =
Keys extends []
? BaseType
: Keys extends readonly [infer Head, ...infer Tail]
? GetWithPath<
PropertyOf<BaseType, Extract<Head, string>, Options>,
Extract<Tail, string[]>,
Options
>
: never;
/**
Adds `undefined` to `Type` if `strict` is enabled.
*/
type Strictify<Type, Options extends GetOptions> =
Options['strict'] extends false ? Type : (Type | undefined);
/**
If `Options['strict']` is `true`, includes `undefined` in the returned type when accessing properties on `Record<string, any>`.
Known limitations:
- Does not include `undefined` in the type on object types with an index signature (for example, `{a: string; [key: string]: string}`).
*/
type StrictPropertyOf<BaseType, Key extends keyof BaseType, Options extends GetOptions> =
Record<string, any> extends BaseType
? string extends keyof BaseType
? Strictify<BaseType[Key], Options> // Record<string, any>
: BaseType[Key] // Record<'a' | 'b', any> (Records with a string union as keys have required properties)
: BaseType[Key];
/**
Splits a dot-prop style path into a tuple comprised of the properties in the path. Handles square-bracket notation.
@example
```
ToPath<'foo.bar.baz'>
//=> ['foo', 'bar', 'baz']
ToPath<'foo[0].bar.baz'>
//=> ['foo', '0', 'bar', 'baz']
```
*/
type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, '.'>;
/**
Replaces square-bracketed dot notation with dots, for example, `foo[0].bar` -> `foo.0.bar`.
*/
type FixPathSquareBrackets<Path extends string> =
Path extends `[${infer Head}]${infer Tail}`
? Tail extends `[${string}`
? `${Head}.${FixPathSquareBrackets<Tail>}`
: `${Head}${FixPathSquareBrackets<Tail>}`
: Path extends `${infer Head}[${infer Middle}]${infer Tail}`
? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}`
: Path;
/**
Returns true if `LongString` is made up out of `Substring` repeated 0 or more times.
@example
```
ConsistsOnlyOf<'aaa', 'a'> //=> true
ConsistsOnlyOf<'ababab', 'ab'> //=> true
ConsistsOnlyOf<'aBa', 'a'> //=> false
ConsistsOnlyOf<'', 'a'> //=> true
```
*/
type ConsistsOnlyOf<LongString extends string, Substring extends string> =
LongString extends ''
? true
: LongString extends `${Substring}${infer Tail}`
? ConsistsOnlyOf<Tail, Substring>
: false;
/**
Convert a type which may have number keys to one with string keys, making it possible to index using strings retrieved from template types.
@example
```
type WithNumbers = {foo: string; 0: boolean};
type WithStrings = WithStringKeys<WithNumbers>;
type WithNumbersKeys = keyof WithNumbers;
//=> 'foo' | 0
type WithStringsKeys = keyof WithStrings;
//=> 'foo' | '0'
```
*/
type WithStringKeys<BaseType> = {
[Key in StringKeyOf<BaseType>]: UncheckedIndex<BaseType, Key>
};
/**
Perform a `T[U]` operation if `T` supports indexing.
*/
type UncheckedIndex<T, U extends string | number> = [T] extends [Record<string | number, any>] ? T[U] : never;
/**
Get a property of an object or array. Works when indexing arrays using number-literal-strings, for example, `PropertyOf<number[], '0'> = number`, and when indexing objects with number keys.
Note:
- Returns `unknown` if `Key` is not a property of `BaseType`, since TypeScript uses structural typing, and it cannot be guaranteed that extra properties unknown to the type system will exist at runtime.
- Returns `undefined` from nullish values, to match the behaviour of most deep-key libraries like `lodash`, `dot-prop`, etc.
*/
type PropertyOf<BaseType, Key extends string, Options extends GetOptions = {}> =
BaseType extends null | undefined
? undefined
: Key extends keyof BaseType
? StrictPropertyOf<BaseType, Key, Options>
: BaseType extends [] | [unknown, ...unknown[]]
? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
: BaseType extends {
[n: number]: infer Item;
length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
}
? (
ConsistsOnlyOf<Key, StringDigit> extends true
? Strictify<Item, Options>
: unknown
)
: Key extends keyof WithStringKeys<BaseType>
? StrictPropertyOf<WithStringKeys<BaseType>, Key, Options>
: unknown;
// This works by first splitting the path based on `.` and `[...]` characters into a tuple of string keys. Then it recursively uses the head key to get the next property of the current object, until there are no keys left. Number keys extract the item type from arrays, or are converted to strings to extract types from tuples and dictionaries with number keys.
/**
Get a deeply-nested property from an object using a key path, like Lodash's `.get()` function.
Use-case: Retrieve a property from deep inside an API response or some other complex object.
@example
```
import type {Get} from 'type-fest';
import * as lodash from 'lodash';
const get = <BaseType, Path extends string | readonly string[]>(object: BaseType, path: Path): Get<BaseType, Path> =>
lodash.get(object, path);
interface ApiResponse {
hits: {
hits: Array<{
_id: string
_source: {
name: Array<{
given: string[]
family: string
}>
birthDate: string
}
}>
}
}
const getName = (apiResponse: ApiResponse) =>
get(apiResponse, 'hits.hits[0]._source.name');
//=> Array<{given: string[]; family: string}> | undefined
// Path also supports a readonly array of strings
const getNameWithPathArray = (apiResponse: ApiResponse) =>
get(apiResponse, ['hits','hits', '0', '_source', 'name'] as const);
//=> Array<{given: string[]; family: string}> | undefined
// Non-strict mode:
Get<string[], '3', {strict: false}> //=> string
Get<Record<string, string>, 'foo', {strict: true}> // => string
```
@category Object
@category Array
@category Template literal
*/
export type Get<BaseType, Path extends string | readonly string[], Options extends GetOptions = {}> =
GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;

View File

@@ -0,0 +1,189 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for ProcessorLocal.test.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> ProcessorLocal.test.ts
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>31/31</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>6/6</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>29/29</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></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import {ProcessorLocal} from "./ProcessorLocal";
import { Converter } from "./Converter";
import P from "bluebird";
import {readFileSync} from "fs";
import path from "path";
import assert from "assert";
import { JSONResult } from "./lineToJson";
const dataDir=path.join(__dirname,"../test/data/");
describe("ProcessLocal",()=&gt;{
it ("should process csv chunks and output json",async function (){
const processor=new ProcessorLocal(new Converter());
const data=readFileSync(dataDir+"/complexJSONCSV");
const lines=await processor.process(data);
assert(lines.length === 2);
const line0=lines[0] as JSONResult;
assert.equal(line0.fieldA.title,"Food Factory");
assert.equal(line0.fieldA.children.length,2);
assert.equal(line0.fieldA.children[1].employee[0].name,"Tim");
})
it ("should process csv chunks and output csv rows",async function (){
const processor=new ProcessorLocal(new Converter({output:"line"}));
const data=readFileSync(dataDir+"/complexJSONCSV");
const lines=await processor.process(data);
assert(lines.length === 2);
})
it ("should return empty array if preRawHook removed the data",()=&gt;{
const conv=new Converter();
conv.preRawData((str)=&gt;{
return "";
});
const processor=new ProcessorLocal(conv);
const data=readFileSync(dataDir+"/complexJSONCSV");
return processor.process(data)
.then((list)=&gt;{
assert.equal(list.length,0);
})
})
})
&nbsp;
&nbsp;</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 Thu May 17 2018 01:25:26 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>

View File

@@ -0,0 +1 @@
{"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../../../src/internal/operators/isEmpty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wBAAgB,OAAO,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAgBzD"}

View File

@@ -0,0 +1 @@
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.01792,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.03135,"35":0,"36":0,"37":0,"38":0.00448,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00896,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0.00448,"61":0,"62":0,"63":0,"64":0,"65":0.00448,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00448,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0.00448,"90":0,"91":0.00448,"92":0.00896,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.01344,"103":0.00448,"104":0.00448,"105":0.00448,"106":0.00448,"107":0.00896,"108":0.01792,"109":0.41207,"110":0.31801,"111":0.01344,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0.00448,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0.00448,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0.00448,"47":0,"48":0,"49":0.01344,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0.00896,"64":0,"65":0.00448,"66":0,"67":0.00448,"68":0,"69":0,"70":0.00448,"71":0,"72":0.00448,"73":0.00896,"74":0.00448,"75":0,"76":0.00448,"77":0.00896,"78":0.00896,"79":0.01344,"80":0.00448,"81":0.04927,"83":0.00448,"84":0,"85":0.00448,"86":0.00448,"87":0.00896,"88":0.01344,"89":0.00896,"90":0.00896,"91":0.01344,"92":0.01344,"93":0.00448,"94":0.00896,"95":0.01792,"96":0.01792,"97":0.00896,"98":0.01344,"99":0.0224,"100":0.01344,"101":0.01344,"102":0.02687,"103":0.04927,"104":0.10302,"105":0.0224,"106":0.03135,"107":0.10302,"108":0.22395,"109":7.51128,"110":4.13412,"111":0,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0.00896,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0.01344,"62":0,"63":0.00896,"64":0,"65":0.00448,"66":0.06271,"67":0.17916,"68":0,"69":0,"70":0,"71":0,"72":0.00896,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00448,"79":0.00896,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.01344,"94":0.18364,"95":0.22843,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0.00448,"13":0.00448,"14":0.00896,"15":0.00448,"16":0.00448,"17":0.00448,"18":0.0224,"79":0,"80":0.04031,"81":0,"83":0,"84":0.00896,"85":0,"86":0,"87":0,"88":0,"89":0.00448,"90":0.00448,"91":0,"92":0.09406,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00448,"101":0.00896,"102":0,"103":0,"104":0,"105":0.01344,"106":0.00896,"107":0.06719,"108":0.06271,"109":1.09736,"110":1.5363},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.00896,"15":0.01344,_:"0","3.1":0,"3.2":0,"5.1":0.00448,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0.00448,"13.1":0.05823,"14.1":0.0224,"15.1":0.00448,"15.2-15.3":0.00896,"15.4":0.02687,"15.5":0.03135,"15.6":0.07614,"16.0":0.00896,"16.1":0.05375,"16.2":0.07614,"16.3":0.03583,"16.4":0},G:{"8":0,"3.2":0.0014,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.00559,"6.0-6.1":0.0021,"7.0-7.1":0.08252,"8.1-8.4":0,"9.0-9.2":0.0014,"9.3":0.05664,"10.0-10.2":0,"10.3":0.08112,"11.0-11.2":0.0014,"11.3-11.4":0.0965,"12.0-12.1":0.00979,"12.2-12.5":0.31048,"13.0-13.1":0,"13.2":0.0049,"13.3":0.0021,"13.4-13.7":0.11119,"14.0-14.4":0.11818,"14.5-14.8":0.11119,"15.0-15.1":0.0958,"15.2-15.3":0.14196,"15.4":0.11259,"15.5":0.2993,"15.6":0.62307,"16.0":0.77201,"16.1":1.06711,"16.2":1.24613,"16.3":0.8804,"16.4":0.0007},P:{"4":0.32622,"20":0.35681,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.26506,"8.2":0,"9.2":0.01019,"10.1":0.01019,"11.1-11.2":0.04078,"12.0":0,"13.0":0.03058,"14.0":0.13253,"15.0":0.01019,"16.0":0.07136,"17.0":0.09175,"18.0":0.05097,"19.0":0.9277},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00614,"4.4":0,"4.4.3-4.4.4":0.10313},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.04031,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0.06625,_:"3.0-3.1"},J:{"7":0,"10":0.01104},O:{"0":1.08212},H:{"0":0.91471},L:{"0":68.93983},R:{_:"0"},M:{"0":0.1049},Q:{"13.1":0}};

View File

@@ -0,0 +1,3 @@
"use strict";
module.exports = require("./is-implemented")() ? Object.assign : require("./shim");

View File

@@ -0,0 +1,42 @@
{
"name": "bytes",
"description": "Utility to parse a string bytes to bytes and vice-versa",
"version": "3.1.2",
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
"contributors": [
"Jed Watson <jed.watson@me.com>",
"Théo FIDRY <theo.fidry@gmail.com>"
],
"license": "MIT",
"keywords": [
"byte",
"bytes",
"utility",
"parse",
"parser",
"convert",
"converter"
],
"repository": "visionmedia/bytes.js",
"devDependencies": {
"eslint": "7.32.0",
"eslint-plugin-markdown": "2.2.1",
"mocha": "9.2.0",
"nyc": "15.1.0"
},
"files": [
"History.md",
"LICENSE",
"Readme.md",
"index.js"
],
"engines": {
"node": ">= 0.8"
},
"scripts": {
"lint": "eslint .",
"test": "mocha --check-leaks --reporter spec",
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}

View File

@@ -0,0 +1,23 @@
{
"name": "webidl-conversions",
"version": "3.0.1",
"description": "Implements the WebIDL algorithms for converting to and from JavaScript values",
"main": "lib/index.js",
"scripts": {
"test": "mocha test/*.js"
},
"repository": "jsdom/webidl-conversions",
"keywords": [
"webidl",
"web",
"types"
],
"files": [
"lib/"
],
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
"license": "BSD-2-Clause",
"devDependencies": {
"mocha": "^1.21.4"
}
}

View File

@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunnerService = void 0;
const request_1 = require("../core/request");
class RunnerService {
/**
* Get all
* Lists all runners from all teams/orgs. <br> This includes the runner's group and distance ran.
* @result ResponseRunner
* @throws ApiError
*/
static async runnerControllerGetAll() {
const result = await (0, request_1.request)({
method: 'GET',
path: `/api/runners`,
});
return result.body;
}
/**
* Post
* Create a new runner. <br> Please remeber to provide the runner's group's id.
* @param requestBody CreateRunner
* @result any
* @throws ApiError
*/
static async runnerControllerPost(requestBody) {
const result = await (0, request_1.request)({
method: 'POST',
path: `/api/runners`,
body: requestBody,
});
return result.body;
}
/**
* Get one
* Lists all information about the runner whose id got provided.
* @param id
* @result ResponseRunner
* @throws ApiError
*/
static async runnerControllerGetOne(id) {
const result = await (0, request_1.request)({
method: 'GET',
path: `/api/runners/${id}`,
});
return result.body;
}
/**
* Put
* Update the runner whose id you provided. <br> Please remember that ids can't be changed.
* @param id
* @param requestBody UpdateRunner
* @result ResponseRunner
* @throws ApiError
*/
static async runnerControllerPut(id, requestBody) {
const result = await (0, request_1.request)({
method: 'PUT',
path: `/api/runners/${id}`,
body: requestBody,
});
return result.body;
}
/**
* Remove
* Delete the runner whose id you provided. <br> This will also delete all scans and cards associated with the runner. <br> If no runner with this id exists it will just return 204(no content).
* @param id
* @param force
* @result ResponseRunner
* @result ResponseEmpty
* @throws ApiError
*/
static async runnerControllerRemove(id, force) {
const result = await (0, request_1.request)({
method: 'DELETE',
path: `/api/runners/${id}`,
query: {
'force': force,
},
});
return result.body;
}
/**
* Get scans
* Lists all scans of the runner whose id got provided. <br> If you only want the valid scans just add the ?onlyValid=true query param.
* @param id
* @result any
* @throws ApiError
*/
static async runnerControllerGetScans(id) {
const result = await (0, request_1.request)({
method: 'GET',
path: `/api/runners/${id}/scans`,
});
return result.body;
}
}
exports.RunnerService = RunnerService;

View File

@@ -0,0 +1,104 @@
import { Subject } from '../Subject';
import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { Subscription } from '../Subscription';
import { refCount as higherOrderRefCount } from '../operators/refCount';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { hasLift } from '../util/lift';
/**
* @class ConnectableObservable<T>
* @deprecated Will be removed in v8. Use {@link connectable} to create a connectable observable.
* If you are using the `refCount` method of `ConnectableObservable`, use the {@link share} operator
* instead.
* Details: https://rxjs.dev/deprecations/multicasting
*/
export class ConnectableObservable<T> extends Observable<T> {
protected _subject: Subject<T> | null = null;
protected _refCount: number = 0;
protected _connection: Subscription | null = null;
/**
* @param source The source observable
* @param subjectFactory The factory that creates the subject used internally.
* @deprecated Will be removed in v8. Use {@link connectable} to create a connectable observable.
* `new ConnectableObservable(source, factory)` is equivalent to
* `connectable(source, { connector: factory })`.
* When the `refCount()` method is needed, the {@link share} operator should be used instead:
* `new ConnectableObservable(source, factory).refCount()` is equivalent to
* `source.pipe(share({ connector: factory }))`.
* Details: https://rxjs.dev/deprecations/multicasting
*/
constructor(public source: Observable<T>, protected subjectFactory: () => Subject<T>) {
super();
// If we have lift, monkey patch that here. This is done so custom observable
// types will compose through multicast. Otherwise the resulting observable would
// simply be an instance of `ConnectableObservable`.
if (hasLift(source)) {
this.lift = source.lift;
}
}
/** @internal */
protected _subscribe(subscriber: Subscriber<T>) {
return this.getSubject().subscribe(subscriber);
}
protected getSubject(): Subject<T> {
const subject = this._subject;
if (!subject || subject.isStopped) {
this._subject = this.subjectFactory();
}
return this._subject!;
}
protected _teardown() {
this._refCount = 0;
const { _connection } = this;
this._subject = this._connection = null;
_connection?.unsubscribe();
}
/**
* @deprecated {@link ConnectableObservable} will be removed in v8. Use {@link connectable} instead.
* Details: https://rxjs.dev/deprecations/multicasting
*/
connect(): Subscription {
let connection = this._connection;
if (!connection) {
connection = this._connection = new Subscription();
const subject = this.getSubject();
connection.add(
this.source.subscribe(
createOperatorSubscriber(
subject as any,
undefined,
() => {
this._teardown();
subject.complete();
},
(err) => {
this._teardown();
subject.error(err);
},
() => this._teardown()
)
)
);
if (connection.closed) {
this._connection = null;
connection = Subscription.EMPTY;
}
}
return connection;
}
/**
* @deprecated {@link ConnectableObservable} will be removed in v8. Use the {@link share} operator instead.
* Details: https://rxjs.dev/deprecations/multicasting
*/
refCount(): Observable<T> {
return higherOrderRefCount()(this) as Observable<T>;
}
}

View File

@@ -0,0 +1,4 @@
export type ResponseUserPermissions = {
directlyGranted?: Array<any>;
inherited?: Array<any>;
};

View File

@@ -0,0 +1,84 @@
var param = null;
var fileLine = require("./fileline");
var csvline = require("./csvline");
var linesToJson = require("./linesToJson");
var CSVError = require('./CSVError');
var eom = "\x03";
var eom1 = "\x0e";
var eom2 = "\x0f";
/**
* message is like :
* 0{"a":"b"}
* 13345|a,b,c
* <cmd><data>
* <cmd> is 0-9
*/
var buffer="";
process.stdin.on("data", function(d) {
var str = d.toString("utf8");
var all = buffer + str;
var cmdArr = all.split(eom);
while (cmdArr.length > 1) {
processMsg(cmdArr.shift());
}
buffer = cmdArr[0];
});
process.on("message", processMsg);
function processMsg(msg) {
if (msg) {
var cmd = msg[0];
var data = msg.substr(1);
switch (cmd) {
case "0":
initParams(data);
break;
case "1":
processData(data);
break;
default:
console.error("Unknown command: " + msg);
}
}
}
function initParams(data) {
param = JSON.parse(data);
}
/**
* e.g.
* 1023|a,b,c,d\ne,f,g,h\n
* <start line number>|<raw csv data>
*/
function processData(data) {
if (!param){
console.error("Parameter not initialised when processing data.");
process.exit(1);
}
var sepIdx = data.indexOf("|");
var startIdx = parseInt(data.substr(0, sepIdx));
var csvData = data.substr(sepIdx + 1);
var lines = fileLine(csvData,param); //convert to file lines.
// process.send("0"+lines.lines.length+"|"+lines.partial);
var csvLines = csvline(lines.lines,param);
var res = linesToJson(csvLines.lines,param,startIdx);
if (csvLines.partial) {
var lastIdx = res.length > 0 ? res[res.length - 1].index + 1 : startIdx;
res.push({
err:CSVError.unclosed_quote(lastIdx, csvLines.partial)
});
}
// console.error(res)
//1<line num>|^<row>|^err|^data|&<line num>|^<row>|^err|^data
var str="1";
res.forEach(function(item) {
var errStr = item.err ? item.err.toString() : "";
str += item.index + eom2 + JSON.stringify(item.row) + eom2 + errStr + eom2 + JSON.stringify(item.json) + eom1;
});
sendData(str);
}
function sendData(str) {
process.stdout.write(str + eom);
}

View File

@@ -0,0 +1,5 @@
var convert = require('./convert'),
func = convert('invoke', require('../invoke'));
func.placeholder = require('./placeholder');
module.exports = func;

View File

@@ -0,0 +1,7 @@
'use strict';
// https://262.ecma-international.org/11.0/#sec-isbigintelementtype
module.exports = function IsBigIntElementType(type) {
return type === 'BigUint64' || type === 'BigInt64';
};

View File

@@ -0,0 +1,3 @@
export declare function parse(): void;
export * from './types';
//# sourceMappingURL=no-parser.d.ts.map

View File

@@ -0,0 +1,18 @@
/**
* Removes `key` and its value from the stack.
*
* @private
* @name delete
* @memberOf Stack
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function stackDelete(key) {
var data = this.__data__,
result = data['delete'](key);
this.size = data.size;
return result;
}
module.exports = stackDelete;

View File

@@ -0,0 +1,30 @@
var Token = require('../../tokenizer/token');
var serializeAll = require('../../writer/one-time').all;
var FONT_FACE_SCOPE = '@font-face';
function removeDuplicateFontAtRules(tokens) {
var fontAtRules = [];
var token;
var key;
var i, l;
for (i = 0, l = tokens.length; i < l; i++) {
token = tokens[i];
if (token[0] != Token.AT_RULE_BLOCK && token[1][0][1] != FONT_FACE_SCOPE) {
continue;
}
key = serializeAll([token]);
if (fontAtRules.indexOf(key) > -1) {
token[2] = [];
} else {
fontAtRules.push(key);
}
}
}
module.exports = removeDuplicateFontAtRules;

View File

@@ -0,0 +1,57 @@
'use strict';
exports.__esModule = true;
exports.parseWithoutProcessing = parseWithoutProcessing;
exports.parse = parse;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _parser = require('./parser');
var _parser2 = _interopRequireDefault(_parser);
var _whitespaceControl = require('./whitespace-control');
var _whitespaceControl2 = _interopRequireDefault(_whitespaceControl);
var _helpers = require('./helpers');
var Helpers = _interopRequireWildcard(_helpers);
var _utils = require('../utils');
exports.parser = _parser2['default'];
var yy = {};
_utils.extend(yy, Helpers);
function parseWithoutProcessing(input, options) {
// Just return if an already-compiled AST was passed in.
if (input.type === 'Program') {
return input;
}
_parser2['default'].yy = yy;
// Altering the shared object here, but this is ok as parser is a sync operation
yy.locInfo = function (locInfo) {
return new yy.SourceLocation(options && options.srcName, locInfo);
};
var ast = _parser2['default'].parse(input);
return ast;
}
function parse(input, options) {
var ast = parseWithoutProcessing(input, options);
var strip = new _whitespaceControl2['default'](options);
return strip.accept(ast);
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2xpYi9oYW5kbGViYXJzL2NvbXBpbGVyL2Jhc2UuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7OztzQkFBbUIsVUFBVTs7OztpQ0FDQyxzQkFBc0I7Ozs7dUJBQzNCLFdBQVc7O0lBQXhCLE9BQU87O3FCQUNJLFVBQVU7O1FBRXhCLE1BQU07O0FBRWYsSUFBSSxFQUFFLEdBQUcsRUFBRSxDQUFDO0FBQ1osY0FBTyxFQUFFLEVBQUUsT0FBTyxDQUFDLENBQUM7O0FBRWIsU0FBUyxzQkFBc0IsQ0FBQyxLQUFLLEVBQUUsT0FBTyxFQUFFOztBQUVyRCxNQUFJLEtBQUssQ0FBQyxJQUFJLEtBQUssU0FBUyxFQUFFO0FBQzVCLFdBQU8sS0FBSyxDQUFDO0dBQ2Q7O0FBRUQsc0JBQU8sRUFBRSxHQUFHLEVBQUUsQ0FBQzs7O0FBR2YsSUFBRSxDQUFDLE9BQU8sR0FBRyxVQUFTLE9BQU8sRUFBRTtBQUM3QixXQUFPLElBQUksRUFBRSxDQUFDLGNBQWMsQ0FBQyxPQUFPLElBQUksT0FBTyxDQUFDLE9BQU8sRUFBRSxPQUFPLENBQUMsQ0FBQztHQUNuRSxDQUFDOztBQUVGLE1BQUksR0FBRyxHQUFHLG9CQUFPLEtBQUssQ0FBQyxLQUFLLENBQUMsQ0FBQzs7QUFFOUIsU0FBTyxHQUFHLENBQUM7Q0FDWjs7QUFFTSxTQUFTLEtBQUssQ0FBQyxLQUFLLEVBQUUsT0FBTyxFQUFFO0FBQ3BDLE1BQUksR0FBRyxHQUFHLHNCQUFzQixDQUFDLEtBQUssRUFBRSxPQUFPLENBQUMsQ0FBQztBQUNqRCxNQUFJLEtBQUssR0FBRyxtQ0FBc0IsT0FBTyxDQUFDLENBQUM7O0FBRTNDLFNBQU8sS0FBSyxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQztDQUMxQiIsImZpbGUiOiJiYXNlLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHBhcnNlciBmcm9tICcuL3BhcnNlcic7XG5pbXBvcnQgV2hpdGVzcGFjZUNvbnRyb2wgZnJvbSAnLi93aGl0ZXNwYWNlLWNvbnRyb2wnO1xuaW1wb3J0ICogYXMgSGVscGVycyBmcm9tICcuL2hlbHBlcnMnO1xuaW1wb3J0IHsgZXh0ZW5kIH0gZnJvbSAnLi4vdXRpbHMnO1xuXG5leHBvcnQgeyBwYXJzZXIgfTtcblxubGV0IHl5ID0ge307XG5leHRlbmQoeXksIEhlbHBlcnMpO1xuXG5leHBvcnQgZnVuY3Rpb24gcGFyc2VXaXRob3V0UHJvY2Vzc2luZyhpbnB1dCwgb3B0aW9ucykge1xuICAvLyBKdXN0IHJldHVybiBpZiBhbiBhbHJlYWR5LWNvbXBpbGVkIEFTVCB3YXMgcGFzc2VkIGluLlxuICBpZiAoaW5wdXQudHlwZSA9PT0gJ1Byb2dyYW0nKSB7XG4gICAgcmV0dXJuIGlucHV0O1xuICB9XG5cbiAgcGFyc2VyLnl5ID0geXk7XG5cbiAgLy8gQWx0ZXJpbmcgdGhlIHNoYXJlZCBvYmplY3QgaGVyZSwgYnV0IHRoaXMgaXMgb2sgYXMgcGFyc2VyIGlzIGEgc3luYyBvcGVyYXRpb25cbiAgeXkubG9jSW5mbyA9IGZ1bmN0aW9uKGxvY0luZm8pIHtcbiAgICByZXR1cm4gbmV3IHl5LlNvdXJjZUxvY2F0aW9uKG9wdGlvbnMgJiYgb3B0aW9ucy5zcmNOYW1lLCBsb2NJbmZvKTtcbiAgfTtcblxuICBsZXQgYXN0ID0gcGFyc2VyLnBhcnNlKGlucHV0KTtcblxuICByZXR1cm4gYXN0O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gcGFyc2UoaW5wdXQsIG9wdGlvbnMpIHtcbiAgbGV0IGFzdCA9IHBhcnNlV2l0aG91dFByb2Nlc3NpbmcoaW5wdXQsIG9wdGlvbnMpO1xuICBsZXQgc3RyaXAgPSBuZXcgV2hpdGVzcGFjZUNvbnRyb2wob3B0aW9ucyk7XG5cbiAgcmV0dXJuIHN0cmlwLmFjY2VwdChhc3QpO1xufVxuIl19

View File

@@ -0,0 +1,158 @@
/**
* The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives sandboxed WebAssembly applications access to the
* underlying operating system via a collection of POSIX-like functions.
*
* ```js
* import { readFile } from 'fs/promises';
* import { WASI } from 'wasi';
* import { argv, env } from 'process';
*
* const wasi = new WASI({
* args: argv,
* env,
* preopens: {
* '/sandbox': '/some/real/path/that/wasm/can/access'
* }
* });
*
* // Some WASI binaries require:
* // const importObject = { wasi_unstable: wasi.wasiImport };
* const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
*
* const wasm = await WebAssembly.compile(
* await readFile(new URL('./demo.wasm', import.meta.url))
* );
* const instance = await WebAssembly.instantiate(wasm, importObject);
*
* wasi.start(instance);
* ```
*
* To run the above example, create a new WebAssembly text format file named`demo.wat`:
*
* ```text
* (module
* ;; Import the required fd_write WASI function which will write the given io vectors to stdout
* ;; The function signature for fd_write is:
* ;; (File Descriptor, *iovs, iovs_len, nwritten) -> Returns number of bytes written
* (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
*
* (memory 1)
* (export "memory" (memory 0))
*
* ;; Write 'hello world\n' to memory at an offset of 8 bytes
* ;; Note the trailing newline which is required for the text to appear
* (data (i32.const 8) "hello world\n")
*
* (func $main (export "_start")
* ;; Creating a new io vector within linear memory
* (i32.store (i32.const 0) (i32.const 8)) ;; iov.iov_base - This is a pointer to the start of the 'hello world\n' string
* (i32.store (i32.const 4) (i32.const 12)) ;; iov.iov_len - The length of the 'hello world\n' string
*
* (call $fd_write
* (i32.const 1) ;; file_descriptor - 1 for stdout
* (i32.const 0) ;; *iovs - The pointer to the iov array, which is stored at memory location 0
* (i32.const 1) ;; iovs_len - We're printing 1 string stored in an iov - so one.
* (i32.const 20) ;; nwritten - A place in memory to store the number of bytes written
* )
* drop ;; Discard the number of bytes written from the top of the stack
* )
* )
* ```
*
* Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm`
*
* ```console
* $ wat2wasm demo.wat
* ```
*
* The `--experimental-wasi-unstable-preview1` CLI argument is needed for this
* example to run.
* @experimental
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/wasi.js)
*/
declare module 'wasi' {
interface WASIOptions {
/**
* An array of strings that the WebAssembly application will
* see as command line arguments. The first argument is the virtual path to the
* WASI command itself.
*/
args?: string[] | undefined;
/**
* An object similar to `process.env` that the WebAssembly
* application will see as its environment.
*/
env?: object | undefined;
/**
* This object represents the WebAssembly application's
* sandbox directory structure. The string keys of `preopens` are treated as
* directories within the sandbox. The corresponding values in `preopens` are
* the real paths to those directories on the host machine.
*/
preopens?: NodeJS.Dict<string> | undefined;
/**
* By default, WASI applications terminate the Node.js
* process via the `__wasi_proc_exit()` function. Setting this option to `true`
* causes `wasi.start()` to return the exit code rather than terminate the
* process.
* @default false
*/
returnOnExit?: boolean | undefined;
/**
* The file descriptor used as standard input in the WebAssembly application.
* @default 0
*/
stdin?: number | undefined;
/**
* The file descriptor used as standard output in the WebAssembly application.
* @default 1
*/
stdout?: number | undefined;
/**
* The file descriptor used as standard error in the WebAssembly application.
* @default 2
*/
stderr?: number | undefined;
}
/**
* The `WASI` class provides the WASI system call API and additional convenience
* methods for working with WASI-based applications. Each `WASI` instance
* represents a distinct sandbox environment. For security purposes, each `WASI`instance must have its command-line arguments, environment variables, and
* sandbox directory structure configured explicitly.
* @since v13.3.0, v12.16.0
*/
class WASI {
constructor(options?: WASIOptions);
/**
* Attempt to begin execution of `instance` as a WASI command by invoking its`_start()` export. If `instance` does not contain a `_start()` export, or if`instance` contains an `_initialize()`
* export, then an exception is thrown.
*
* `start()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named`memory`. If
* `instance` does not have a `memory` export an exception is thrown.
*
* If `start()` is called more than once, an exception is thrown.
* @since v13.3.0, v12.16.0
*/
start(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
/**
* Attempt to initialize `instance` as a WASI reactor by invoking its`_initialize()` export, if it is present. If `instance` contains a `_start()`export, then an exception is thrown.
*
* `initialize()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named`memory`.
* If `instance` does not have a `memory` export an exception is thrown.
*
* If `initialize()` is called more than once, an exception is thrown.
* @since v14.6.0, v12.19.0
*/
initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
/**
* `wasiImport` is an object that implements the WASI system call API. This object
* should be passed as the `wasi_snapshot_preview1` import during the instantiation
* of a [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance).
* @since v13.3.0, v12.16.0
*/
readonly wasiImport: NodeJS.Dict<any>; // TODO: Narrow to DOM types
}
}
declare module 'node:wasi' {
export * from 'wasi';
}

View File

@@ -0,0 +1,465 @@
// Generated by LiveScript 1.6.0
(function(){
var VERSION, ref$, id, map, compact, any, groupBy, partition, chars, isItNaN, keys, Obj, camelize, deepIs, closestString, nameToRaw, dasherize, naturalJoin, generateHelp, generateHelpForOption, parsedTypeCheck, parseType, parseLevn, camelizeKeys, parseString, main, toString$ = {}.toString, slice$ = [].slice, arrayFrom$ = Array.from || function(x){return slice$.call(x);};
VERSION = '0.8.3';
ref$ = require('prelude-ls'), id = ref$.id, map = ref$.map, compact = ref$.compact, any = ref$.any, groupBy = ref$.groupBy, partition = ref$.partition, chars = ref$.chars, isItNaN = ref$.isItNaN, keys = ref$.keys, Obj = ref$.Obj, camelize = ref$.camelize;
deepIs = require('deep-is');
ref$ = require('./util'), closestString = ref$.closestString, nameToRaw = ref$.nameToRaw, dasherize = ref$.dasherize, naturalJoin = ref$.naturalJoin;
ref$ = require('./help'), generateHelp = ref$.generateHelp, generateHelpForOption = ref$.generateHelpForOption;
ref$ = require('type-check'), parsedTypeCheck = ref$.parsedTypeCheck, parseType = ref$.parseType;
parseLevn = require('levn').parsedTypeParse;
camelizeKeys = function(obj){
var key, value, resultObj$ = {};
for (key in obj) {
value = obj[key];
resultObj$[camelize(key)] = value;
}
return resultObj$;
};
parseString = function(string){
var assignOpt, regex, replaceRegex, result;
assignOpt = '--?[a-zA-Z][-a-z-A-Z0-9]*=';
regex = RegExp('(?:' + assignOpt + ')?(?:\'(?:\\\\\'|[^\'])+\'|"(?:\\\\"|[^"])+")|[^\'"\\s]+', 'g');
replaceRegex = RegExp('^(' + assignOpt + ')?[\'"]([\\s\\S]*)[\'"]$');
result = map(function(it){
return it.replace(replaceRegex, '$1$2');
}, string.match(regex) || []);
return result;
};
main = function(libOptions){
var opts, defaults, required, traverse, getOption, parse;
opts = {};
defaults = {};
required = [];
if (toString$.call(libOptions.stdout).slice(8, -1) === 'Undefined') {
libOptions.stdout = process.stdout;
}
libOptions.positionalAnywhere == null && (libOptions.positionalAnywhere = true);
libOptions.typeAliases == null && (libOptions.typeAliases = {});
libOptions.defaults == null && (libOptions.defaults = {});
if (libOptions.concatRepeatedArrays != null) {
libOptions.defaults.concatRepeatedArrays = libOptions.concatRepeatedArrays;
}
if (libOptions.mergeRepeatedObjects != null) {
libOptions.defaults.mergeRepeatedObjects = libOptions.mergeRepeatedObjects;
}
traverse = function(options){
var i$, len$, option, name, k, ref$, v, type, that, e, parsedPossibilities, parsedType, j$, len1$, possibility, rawDependsType, dependsOpts, dependsType, cra, alias, shortNames, longNames;
if (toString$.call(options).slice(8, -1) !== 'Array') {
throw new Error('No options defined.');
}
for (i$ = 0, len$ = options.length; i$ < len$; ++i$) {
option = options[i$];
if (option.heading == null) {
name = option.option;
if (opts[name] != null) {
throw new Error("Option '" + name + "' already defined.");
}
for (k in ref$ = libOptions.defaults) {
v = ref$[k];
option[k] == null && (option[k] = v);
}
if (option.type === 'Boolean') {
option.boolean == null && (option.boolean = true);
}
if (option.parsedType == null) {
if (!option.type) {
throw new Error("No type defined for option '" + name + "'.");
}
try {
type = (that = libOptions.typeAliases[option.type]) != null
? that
: option.type;
option.parsedType = parseType(type);
} catch (e$) {
e = e$;
throw new Error("Option '" + name + "': Error parsing type '" + option.type + "': " + e.message);
}
}
if (option['default']) {
try {
defaults[name] = parseLevn(option.parsedType, option['default']);
} catch (e$) {
e = e$;
throw new Error("Option '" + name + "': Error parsing default value '" + option['default'] + "' for type '" + option.type + "': " + e.message);
}
}
if (option['enum'] && !option.parsedPossiblities) {
parsedPossibilities = [];
parsedType = option.parsedType;
for (j$ = 0, len1$ = (ref$ = option['enum']).length; j$ < len1$; ++j$) {
possibility = ref$[j$];
try {
parsedPossibilities.push(parseLevn(parsedType, possibility));
} catch (e$) {
e = e$;
throw new Error("Option '" + name + "': Error parsing enum value '" + possibility + "' for type '" + option.type + "': " + e.message);
}
}
option.parsedPossibilities = parsedPossibilities;
}
if (that = option.dependsOn) {
if (that.length) {
ref$ = [].concat(option.dependsOn), rawDependsType = ref$[0], dependsOpts = slice$.call(ref$, 1);
dependsType = rawDependsType.toLowerCase();
if (dependsOpts.length) {
if (dependsType === 'and' || dependsType === 'or') {
option.dependsOn = [dependsType].concat(arrayFrom$(dependsOpts));
} else {
throw new Error("Option '" + name + "': If you have more than one dependency, you must specify either 'and' or 'or'");
}
} else {
if ((ref$ = dependsType.toLowerCase()) === 'and' || ref$ === 'or') {
option.dependsOn = null;
} else {
option.dependsOn = ['and', rawDependsType];
}
}
} else {
option.dependsOn = null;
}
}
if (option.required) {
required.push(name);
}
opts[name] = option;
if (option.concatRepeatedArrays != null) {
cra = option.concatRepeatedArrays;
if ('Boolean' === toString$.call(cra).slice(8, -1)) {
option.concatRepeatedArrays = [cra, {}];
} else if (cra.length === 1) {
option.concatRepeatedArrays = [cra[0], {}];
} else if (cra.length !== 2) {
throw new Error("Invalid setting for concatRepeatedArrays");
}
}
if (option.alias || option.aliases) {
if (name === 'NUM') {
throw new Error("-NUM option can't have aliases.");
}
if (option.alias) {
option.aliases == null && (option.aliases = [].concat(option.alias));
}
for (j$ = 0, len1$ = (ref$ = option.aliases).length; j$ < len1$; ++j$) {
alias = ref$[j$];
if (opts[alias] != null) {
throw new Error("Option '" + alias + "' already defined.");
}
opts[alias] = option;
}
ref$ = partition(fn$, option.aliases), shortNames = ref$[0], longNames = ref$[1];
option.shortNames == null && (option.shortNames = shortNames);
option.longNames == null && (option.longNames = longNames);
}
if ((!option.aliases || option.shortNames.length === 0) && option.type === 'Boolean' && option['default'] === 'true') {
option.negateName = true;
}
}
}
function fn$(it){
return it.length === 1;
}
};
traverse(libOptions.options);
getOption = function(name){
var opt, possiblyMeant;
opt = opts[name];
if (opt == null) {
possiblyMeant = closestString(keys(opts), name);
throw new Error("Invalid option '" + nameToRaw(name) + "'" + (possiblyMeant ? " - perhaps you meant '" + nameToRaw(possiblyMeant) + "'?" : '.'));
}
return opt;
};
parse = function(input, arg$){
var slice, obj, positional, restPositional, overrideRequired, prop, setValue, setDefaults, checkRequired, mutuallyExclusiveError, checkMutuallyExclusive, checkDependency, checkDependencies, checkProp, args, key, value, option, ref$, i$, len$, arg, that, result, short, argName, usingAssign, val, flags, len, j$, len1$, i, flag, opt, name, valPrime, negated, noedName;
slice = (arg$ != null
? arg$
: {}).slice;
obj = {};
positional = [];
restPositional = false;
overrideRequired = false;
prop = null;
setValue = function(name, value){
var opt, val, cra, e, currentType;
opt = getOption(name);
if (opt.boolean) {
val = value;
} else {
try {
cra = opt.concatRepeatedArrays;
if (cra != null && cra[0] && cra[1].oneValuePerFlag && opt.parsedType.length === 1 && opt.parsedType[0].structure === 'array') {
val = [parseLevn(opt.parsedType[0].of, value)];
} else {
val = parseLevn(opt.parsedType, value);
}
} catch (e$) {
e = e$;
throw new Error("Invalid value for option '" + name + "' - expected type " + opt.type + ", received value: " + value + ".");
}
if (opt['enum'] && !any(function(it){
return deepIs(it, val);
}, opt.parsedPossibilities)) {
throw new Error("Option " + name + ": '" + val + "' not one of " + naturalJoin(opt['enum']) + ".");
}
}
currentType = toString$.call(obj[name]).slice(8, -1);
if (obj[name] != null) {
if (opt.concatRepeatedArrays != null && opt.concatRepeatedArrays[0] && currentType === 'Array') {
obj[name] = obj[name].concat(val);
} else if (opt.mergeRepeatedObjects && currentType === 'Object') {
import$(obj[name], val);
} else {
obj[name] = val;
}
} else {
obj[name] = val;
}
if (opt.restPositional) {
restPositional = true;
}
if (opt.overrideRequired) {
overrideRequired = true;
}
};
setDefaults = function(){
var name, ref$, value;
for (name in ref$ = defaults) {
value = ref$[name];
if (obj[name] == null) {
obj[name] = value;
}
}
};
checkRequired = function(){
var i$, ref$, len$, name;
if (overrideRequired) {
return;
}
for (i$ = 0, len$ = (ref$ = required).length; i$ < len$; ++i$) {
name = ref$[i$];
if (!obj[name]) {
throw new Error("Option " + nameToRaw(name) + " is required.");
}
}
};
mutuallyExclusiveError = function(first, second){
throw new Error("The options " + nameToRaw(first) + " and " + nameToRaw(second) + " are mutually exclusive - you cannot use them at the same time.");
};
checkMutuallyExclusive = function(){
var rules, i$, len$, rule, present, j$, len1$, element, k$, len2$, opt;
rules = libOptions.mutuallyExclusive;
if (!rules) {
return;
}
for (i$ = 0, len$ = rules.length; i$ < len$; ++i$) {
rule = rules[i$];
present = null;
for (j$ = 0, len1$ = rule.length; j$ < len1$; ++j$) {
element = rule[j$];
if (toString$.call(element).slice(8, -1) === 'Array') {
for (k$ = 0, len2$ = element.length; k$ < len2$; ++k$) {
opt = element[k$];
if (opt in obj) {
if (present != null) {
mutuallyExclusiveError(present, opt);
} else {
present = opt;
break;
}
}
}
} else {
if (element in obj) {
if (present != null) {
mutuallyExclusiveError(present, element);
} else {
present = element;
}
}
}
}
}
};
checkDependency = function(option){
var dependsOn, type, targetOptionNames, i$, len$, targetOptionName, targetOption;
dependsOn = option.dependsOn;
if (!dependsOn || option.dependenciesMet) {
return true;
}
type = dependsOn[0], targetOptionNames = slice$.call(dependsOn, 1);
for (i$ = 0, len$ = targetOptionNames.length; i$ < len$; ++i$) {
targetOptionName = targetOptionNames[i$];
targetOption = obj[targetOptionName];
if (targetOption && checkDependency(targetOption)) {
if (type === 'or') {
return true;
}
} else if (type === 'and') {
throw new Error("The option '" + option.option + "' did not have its dependencies met.");
}
}
if (type === 'and') {
return true;
} else {
throw new Error("The option '" + option.option + "' did not meet any of its dependencies.");
}
};
checkDependencies = function(){
var name;
for (name in obj) {
checkDependency(opts[name]);
}
};
checkProp = function(){
if (prop) {
throw new Error("Value for '" + prop + "' of type '" + getOption(prop).type + "' required.");
}
};
switch (toString$.call(input).slice(8, -1)) {
case 'String':
args = parseString(input.slice(slice != null ? slice : 0));
break;
case 'Array':
args = input.slice(slice != null ? slice : 2);
break;
case 'Object':
obj = {};
for (key in input) {
value = input[key];
if (key !== '_') {
option = getOption(dasherize(key));
if (parsedTypeCheck(option.parsedType, value)) {
obj[option.option] = value;
} else {
throw new Error("Option '" + option.option + "': Invalid type for '" + value + "' - expected type '" + option.type + "'.");
}
}
}
checkMutuallyExclusive();
checkDependencies();
setDefaults();
checkRequired();
return ref$ = camelizeKeys(obj), ref$._ = input._ || [], ref$;
default:
throw new Error("Invalid argument to 'parse': " + input + ".");
}
for (i$ = 0, len$ = args.length; i$ < len$; ++i$) {
arg = args[i$];
if (arg === '--') {
restPositional = true;
} else if (restPositional) {
positional.push(arg);
} else {
if (that = arg.match(/^(--?)([a-zA-Z][-a-zA-Z0-9]*)(=)?(.*)?$/)) {
result = that;
checkProp();
short = result[1].length === 1;
argName = result[2];
usingAssign = result[3] != null;
val = result[4];
if (usingAssign && val == null) {
throw new Error("No value for '" + argName + "' specified.");
}
if (short) {
flags = chars(argName);
len = flags.length;
for (j$ = 0, len1$ = flags.length; j$ < len1$; ++j$) {
i = j$;
flag = flags[j$];
opt = getOption(flag);
name = opt.option;
if (restPositional) {
positional.push(flag);
} else if (i === len - 1) {
if (usingAssign) {
valPrime = opt.boolean ? parseLevn([{
type: 'Boolean'
}], val) : val;
setValue(name, valPrime);
} else if (opt.boolean) {
setValue(name, true);
} else {
prop = name;
}
} else if (opt.boolean) {
setValue(name, true);
} else {
throw new Error("Can't set argument '" + flag + "' when not last flag in a group of short flags.");
}
}
} else {
negated = false;
if (that = argName.match(/^no-(.+)$/)) {
negated = true;
noedName = that[1];
opt = getOption(noedName);
} else {
opt = getOption(argName);
}
name = opt.option;
if (opt.boolean) {
valPrime = usingAssign ? parseLevn([{
type: 'Boolean'
}], val) : true;
if (negated) {
setValue(name, !valPrime);
} else {
setValue(name, valPrime);
}
} else {
if (negated) {
throw new Error("Only use 'no-' prefix for Boolean options, not with '" + noedName + "'.");
}
if (usingAssign) {
setValue(name, val);
} else {
prop = name;
}
}
}
} else if (that = arg.match(/^-([0-9]+(?:\.[0-9]+)?)$/)) {
opt = opts.NUM;
if (!opt) {
throw new Error('No -NUM option defined.');
}
setValue(opt.option, that[1]);
} else {
if (prop) {
setValue(prop, arg);
prop = null;
} else {
positional.push(arg);
if (!libOptions.positionalAnywhere) {
restPositional = true;
}
}
}
}
}
checkProp();
checkMutuallyExclusive();
checkDependencies();
setDefaults();
checkRequired();
return ref$ = camelizeKeys(obj), ref$._ = positional, ref$;
};
return {
parse: parse,
parseArgv: function(it){
return parse(it, {
slice: 2
});
},
generateHelp: generateHelp(libOptions),
generateHelpForOption: generateHelpForOption(getOption, libOptions)
};
};
main.VERSION = VERSION;
module.exports = main;
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
}).call(this);

View File

@@ -0,0 +1 @@
{"name":"npm-run-path","version":"4.0.1","files":{"license":{"checkedAt":1678883669272,"integrity":"sha512-nIst73auX/5NY2Fmv5Y116vWnNrEv4GaIUX3lpZG05rpXJY2S8EX+fpUS5hRjClCM0VdT2Za9DDHXXB5jdSrEw==","mode":420,"size":1109},"index.js":{"checkedAt":1678883671522,"integrity":"sha512-meiNviwLmYvPFfHmkJwKydNBE8Jut5kRIuAL7Yp+mNL3XRkUIM/jLl8gyEH8OK/BT8pLX+NcBo1SSDDRBnQ8Pw==","mode":420,"size":1013},"package.json":{"checkedAt":1678883671522,"integrity":"sha512-ZhY14uuXD6sneKKB9f5ToIjKcgRLji6CCYUAwDdFEZhT3vXT3qc63Xr1eEwC0wXpCIf29/ZNR+wr994xKcxO2g==","mode":420,"size":712},"readme.md":{"checkedAt":1678883671522,"integrity":"sha512-ArOchXWaVFuyE711FpqOkFxSe7B6Ha9bnzN6m9cBTx57rTZLxlY3ud8fHS5lGfJj01JMT6++l8TyJAmDLVx4lw==","mode":420,"size":2965},"index.d.ts":{"checkedAt":1678883671526,"integrity":"sha512-IDg0Nkb3Rn6MGfQpUpEYWfiP/M3/8aEWDy1ldHMMbfUpMTdL+z+VAosDQwDTbR95AP5dir8KbSBXpANlV0PUtQ==","mode":420,"size":2329}}}

View File

@@ -0,0 +1 @@
{"version":3,"file":"fromSubscribable.js","sourceRoot":"","sources":["../../../../src/internal/observable/fromSubscribable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAc3C,MAAM,UAAU,gBAAgB,CAAI,YAA6B;IAC/D,OAAO,IAAI,UAAU,CAAC,UAAC,UAAyB,IAAK,OAAA,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,EAAlC,CAAkC,CAAC,CAAC;AAC3F,CAAC"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"fileline.js","sourceRoot":"","sources":["../src/fileline.ts"],"names":[],"mappings":";;;;;AACA,oDAA8B;AAC9B,sCAAsC;AACtC;;;;;GAKG;AACH,uBAA8B,IAAY,EAAE,KAAmB;IAC7D,IAAM,GAAG,GAAG,gBAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC;AALD,sCAKC;AAAA,CAAC"}

View File

@@ -0,0 +1,9 @@
import { LookupMatcherResult } from './types';
/**
* https://tc39.es/ecma402/#sec-bestfitmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
export declare function BestFitMatcher(availableLocales: Set<string>, requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult;
//# sourceMappingURL=BestFitMatcher.d.ts.map

View File

@@ -0,0 +1,30 @@
/// <reference types="node" />
import net from 'net';
import { Agent, ClientRequest, RequestOptions } from 'agent-base';
import { HttpsProxyAgentOptions } from '.';
/**
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
*
* Outgoing HTTP requests are first tunneled through the proxy server using the
* `CONNECT` HTTP request method to establish a connection to the proxy server,
* and then the proxy server connects to the destination target and issues the
* HTTP request from the proxy server.
*
* `https:` requests have their socket connection upgraded to TLS once
* the connection to the proxy server has been established.
*
* @api public
*/
export default class HttpsProxyAgent extends Agent {
private secureProxy;
private proxy;
constructor(_opts: string | HttpsProxyAgentOptions);
/**
* Called when the node-core HTTP client library is creating a
* new HTTP request.
*
* @api protected
*/
callback(req: ClientRequest, opts: RequestOptions): Promise<net.Socket>;
}

View File

@@ -0,0 +1,7 @@
"use strict";
var isValue = require("../is-value");
var keys = Object.keys;
module.exports = function (object) { return keys(isValue(object) ? Object(object) : object); };

View File

@@ -0,0 +1,116 @@
import assert from 'node:assert';
import _ from 'lodash';
import Separator from './separator.js';
import Choice from './choice.js';
/**
* Choices collection
* Collection of multiple `choice` object
*/
export default class Choices {
/** @param {Array} choices All `choice` to keep in the collection */
constructor(choices, answers) {
this.choices = choices.map((val) => {
if (val.type === 'separator') {
if (!(val instanceof Separator)) {
val = new Separator(val.line);
}
return val;
}
return new Choice(val, answers);
});
this.realChoices = this.choices
.filter(Separator.exclude)
.filter((item) => !item.disabled);
Object.defineProperty(this, 'length', {
get() {
return this.choices.length;
},
set(val) {
this.choices.length = val;
},
});
Object.defineProperty(this, 'realLength', {
get() {
return this.realChoices.length;
},
set() {
throw new Error('Cannot set `realLength` of a Choices collection');
},
});
}
/**
* Get a valid choice from the collection
* @param {Number} selector The selected choice index
* @return {Choice|Undefined} Return the matched choice or undefined
*/
getChoice(selector) {
assert(typeof selector === 'number');
return this.realChoices[selector];
}
/**
* Get a raw element from the collection
* @param {Number} selector The selected index value
* @return {Choice|Undefined} Return the matched choice or undefined
*/
get(selector) {
assert(typeof selector === 'number');
return this.choices[selector];
}
/**
* Match the valid choices against a where clause
* @param {Object} whereClause Lodash `where` clause
* @return {Array} Matching choices or empty array
*/
where(whereClause) {
return _.filter(this.realChoices, whereClause);
}
/**
* Pluck a particular key from the choices
* @param {String} propertyName Property name to select
* @return {Array} Selected properties
*/
pluck(propertyName) {
return _.map(this.realChoices, propertyName);
}
// Expose usual Array methods
indexOf(...args) {
return this.choices.indexOf(...args);
}
forEach(...args) {
return this.choices.forEach(...args);
}
filter(...args) {
return this.choices.filter(...args);
}
reduce(...args) {
return this.choices.reduce(...args);
}
find(func) {
return this.choices.find(func);
}
push(...args) {
const objs = args.map((val) => new Choice(val));
this.choices.push(...objs);
this.realChoices = this.choices
.filter(Separator.exclude)
.filter((item) => !item.disabled);
return this.choices;
}
}

View File

@@ -0,0 +1,336 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for ParseRuntime.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> ParseRuntime.ts
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>8/8</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>4/4</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>1/1</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>8/8</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></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">83x</span>
<span class="cline-any cline-yes">83x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">83x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">83x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">83x</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import { CSVParseParam, CellParser } from "./Parameters";
import { Converter, PreRawDataCallback, PreFileLineCallback } from "./Converter";
import { ChildProcess } from "child_process";
import CSVError from "./CSVError";
&nbsp;
export interface ParseRuntime {
/**
* If need convert ignoreColumn from column name(string) to column index (number). Parser needs column index.
*/
needProcessIgnoreColumn: boolean;
/**
* If need convert includeColumn from column name(string) to column index (number). Parser needs column index.
*/
needProcessIncludeColumn: boolean;
/**
* the indexes of columns to reserve, undefined means reserve all, [] means hide all
*/
selectedColumns?: number[];
ended: boolean;
hasError: boolean;
error?: Error;
/**
* Inferred delimiter
*/
delimiter: string | string[];
/**
* Inferred eol
*/
eol?: string;
/**
* Converter function for a column. Populated at runtime.
*/
columnConv: (CellParser | null)[],
headerType: any[],
headerTitle: string[],
headerFlag: any[],
/**
* Inferred headers
*/
headers?: any[],
csvLineBuffer?: Buffer,
/**
* after first chunk of data being processed and emitted, started will become true.
*/
started: boolean,
preRawDataHook?: PreRawDataCallback,
preFileLineHook?: PreFileLineCallback,
parsedLineNumber: number,
&nbsp;
columnValueSetter: Function[];
subscribe?: {
onNext?: (data: any, lineNumber:number) =&gt; void | PromiseLike&lt;void&gt;;
onError?: (err: CSVError) =&gt; void;
onCompleted?: () =&gt; void;
};
then?: {
onfulfilled: (value: any[]) =&gt; any;
onrejected: (err: Error) =&gt; any;
}
&nbsp;
}
export function initParseRuntime(converter: Converter): ParseRuntime {
const params = converter.parseParam;
const rtn: ParseRuntime = {
needProcessIgnoreColumn: false,
needProcessIncludeColumn: false,
selectedColumns: undefined,
ended: false,
hasError: false,
error: undefined,
delimiter: converter.parseParam.delimiter,
eol: converter.parseParam.eol,
columnConv: [],
headerType: [],
headerTitle: [],
headerFlag: [],
headers: undefined,
started: false,
parsedLineNumber: 0,
columnValueSetter: [],
}
if (params.ignoreColumns) {
rtn.needProcessIgnoreColumn = true;
}
if (params.includeColumns) {
rtn.needProcessIncludeColumn = true;
}
return rtn;
}</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 Thu May 17 2018 01:22:23 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>

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"1":"F A B","2":"J D E CC"},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":"0 1 2 3 4 5 6 7 8 9 G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB 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 EC FC"},D:{"1":"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 5 I v J D E F A B C K L G M N O w g x y z"},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":"0 1 2 3 4 5 6 7 8 9 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 rB","2":"F B G M PC QC RC SC qB AC TC","16":"C"},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 bC"},H:{"2":"oC"},I:{"1":"f tC uC","2":"tB I pC qC rC sC BC"},J:{"2":"D A"},K:{"1":"h rB","2":"A B qB AC","16":"C"},L:{"1":"H"},M:{"1":"H"},N:{"1":"A B"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:5,C:"KeyboardEvent.getModifierState()"};

View File

@@ -0,0 +1,3 @@
import { Node } from 'acorn';
export declare const parse: (source: string) => Node;
export declare const parse_expression_at: (source: string, index: number) => Node;

View File

@@ -0,0 +1,20 @@
/* eslint id-length: "off" */
"use strict";
var pad = require("../../number/#/pad")
, date = require("../valid-date")
, format;
format = require("../../string/format-method")({
Y: function () { return String(this.getFullYear()); },
y: function () { return String(this.getFullYear()).slice(-2); },
m: function () { return pad.call(this.getMonth() + 1, 2); },
d: function () { return pad.call(this.getDate(), 2); },
H: function () { return pad.call(this.getHours(), 2); },
M: function () { return pad.call(this.getMinutes(), 2); },
S: function () { return pad.call(this.getSeconds(), 2); },
L: function () { return pad.call(this.getMilliseconds(), 3); }
});
module.exports = function (pattern) { return format.call(date(this), pattern); };

View File

@@ -0,0 +1,31 @@
export type CreatePermission = {
principal: number;
target: CreatePermission.target;
action: CreatePermission.action;
};
export declare namespace CreatePermission {
enum target {
RUNNER = "RUNNER",
ORGANIZATION = "ORGANIZATION",
TEAM = "TEAM",
TRACK = "TRACK",
USER = "USER",
USERGROUP = "USERGROUP",
PERMISSION = "PERMISSION",
STATSCLIENT = "STATSCLIENT",
DONOR = "DONOR",
SCAN = "SCAN",
STATION = "STATION",
CARD = "CARD",
DONATION = "DONATION",
CONTACT = "CONTACT",
MAIL = "MAIL"
}
enum action {
GET = "GET",
CREATE = "CREATE",
UPDATE = "UPDATE",
DELETE = "DELETE",
IMPORT = "IMPORT"
}
}

View File

@@ -0,0 +1 @@
module.exports={A:{D:{"2":"I v J D E F A B C K L G M N O w g x","33":"0 1 2 3 4 5 6 7 8 9 y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},L:{"33":"H"},B:{"2":"C K L G M N O","33":"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:{"2":"DC","33":"0 1 2 3 4 5 6 7 8 9 tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB EC FC"},M:{"33":"H"},A:{"2":"J D E F A B CC"},F:{"2":"F B C PC QC RC SC qB AC TC rB","33":"0 1 2 3 4 5 6 7 8 9 G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e"},K:{"2":"A B C qB AC rB","33":"h"},E:{"2":"I v J HC zB IC JC OC","33":"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"},G:{"2":"zB UC BC VC WC","33":"E 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"},P:{"2":"I","33":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},I:{"2":"tB I pC qC rC sC BC","33":"f tC uC"}},B:6,C:"width: stretch property"};

View File

@@ -0,0 +1,40 @@
'use strict'
const u = require('universalify').fromCallback
const fs = require('graceful-fs')
const path = require('path')
const mkdir = require('../mkdirs')
const pathExists = require('../path-exists').pathExists
function outputFile (file, data, encoding, callback) {
if (typeof encoding === 'function') {
callback = encoding
encoding = 'utf8'
}
const dir = path.dirname(file)
pathExists(dir, (err, itDoes) => {
if (err) return callback(err)
if (itDoes) return fs.writeFile(file, data, encoding, callback)
mkdir.mkdirs(dir, err => {
if (err) return callback(err)
fs.writeFile(file, data, encoding, callback)
})
})
}
function outputFileSync (file, ...args) {
const dir = path.dirname(file)
if (fs.existsSync(dir)) {
return fs.writeFileSync(file, ...args)
}
mkdir.mkdirsSync(dir)
fs.writeFileSync(file, ...args)
}
module.exports = {
outputFile: u(outputFile),
outputFileSync
}

View File

@@ -0,0 +1 @@
{"version":3,"file":"scheduled.js","sourceRoot":"","sources":["../../../../src/internal/scheduled/scheduled.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,qDAAoD;AACpD,iDAAgD;AAChD,uDAAsD;AACtD,iEAAgE;AAChE,mEAAkE;AAClE,+CAA8C;AAC9C,mDAAkD;AAClD,iDAAgD;AAGhD,2DAA0D;AAC1D,yEAAkF;AAClF,qEAAoE;AACpE,2EAA0E;AAa1E,SAAgB,SAAS,CAAI,KAAyB,EAAE,SAAwB;IAC9E,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,IAAI,yCAAmB,CAAC,KAAK,CAAC,EAAE;YAC9B,OAAO,uCAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAC7C;QACD,IAAI,yBAAW,CAAC,KAAK,CAAC,EAAE;YACtB,OAAO,6BAAa,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SACxC;QACD,IAAI,qBAAS,CAAC,KAAK,CAAC,EAAE;YACpB,OAAO,iCAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAC1C;QACD,IAAI,iCAAe,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,6CAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAChD;QACD,IAAI,uBAAU,CAAC,KAAK,CAAC,EAAE;YACrB,OAAO,mCAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAC3C;QACD,IAAI,2CAAoB,CAAC,KAAK,CAAC,EAAE;YAC/B,OAAO,uDAA0B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SACrD;KACF;IACD,MAAM,yDAAgC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAtBD,8BAsBC"}

View File

@@ -0,0 +1,7 @@
"use strict";
module.exports = function () {
var numberIsNaN = Number.isNaN;
if (typeof numberIsNaN !== "function") return false;
return !numberIsNaN({}) && numberIsNaN(NaN) && !numberIsNaN(34);
};

View File

@@ -0,0 +1,67 @@
require('../auto');
var test = require('tape');
var defineProperties = require('define-properties');
var callBind = require('call-bind');
var hasStrictMode = require('has-strict-mode')();
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = require('functions-have-names')();
var runTests = require('./tests');
test('shimmed', function (t) {
t.equal(Array.prototype.map.length, 1, 'Array#map has a length of 1');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Array.prototype.map.name, 'map', 'Array#map has name "map"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Array.prototype, 'map'), 'Array#map is not enumerable');
et.end();
});
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
st['throws'](function () { return Array.prototype.map.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
st['throws'](function () { return Array.prototype.map.call(null, 'a'); }, TypeError, 'null is not an object');
st.end();
});
t.test('receiver boxing', function (st) {
st.plan(hasStrictMode ? 3 : 2);
var context = 'x';
Array.prototype.map.call(
'f',
function () {
st.equal(typeof this, 'object');
st.equal(String.prototype.toString.call(this), context);
},
context
);
st.test('strict mode', { skip: !hasStrictMode }, function (sst) {
sst.plan(2);
Array.prototype.map.call(
'f',
function () {
'use strict';
sst.equal(typeof this, 'string');
sst.equal(this, context);
},
context
);
sst.end();
});
st.end();
});
runTests(callBind(Array.prototype.map), t);
t.end();
});

View File

@@ -0,0 +1,17 @@
import path from 'path'
export const cli = 'tailwind'
export const defaultConfigFile = './tailwind.config.js'
export const defaultPostCssConfigFile = './postcss.config.js'
export const cjsConfigFile = './tailwind.config.cjs'
export const cjsPostCssConfigFile = './postcss.config.cjs'
export const supportedConfigFiles = [cjsConfigFile, defaultConfigFile]
export const supportedPostCssConfigFile = [cjsPostCssConfigFile, defaultPostCssConfigFile]
export const defaultConfigStubFile = path.resolve(__dirname, '../stubs/defaultConfig.stub.js')
export const simpleConfigStubFile = path.resolve(__dirname, '../stubs/simpleConfig.stub.js')
export const defaultPostCssConfigStubFile = path.resolve(
__dirname,
'../stubs/defaultPostCssConfig.stub.js'
)

View File

@@ -0,0 +1,14 @@
/**
* Gets what should be in the `response` property of the XHR. However,
* since we still support the final versions of IE, we need to do a little
* checking here to make sure that we get the right thing back. Consequently,
* we need to do a JSON.parse() in here, which *could* throw if the response
* isn't valid JSON.
*
* This is used both in creating an AjaxResponse, and in creating certain errors
* that we throw, so we can give the user whatever was in the response property.
*
* @param xhr The XHR to examine the response of
*/
export declare function getXHRResponse(xhr: XMLHttpRequest): any;
//# sourceMappingURL=getXHRResponse.d.ts.map

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.of = void 0;
var args_1 = require("../util/args");
var from_1 = require("./from");
function of() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var scheduler = args_1.popScheduler(args);
return from_1.from(args, scheduler);
}
exports.of = of;
//# sourceMappingURL=of.js.map

View File

@@ -0,0 +1,33 @@
var path = require('path');
var test = require('tape');
var resolve = require('../');
test('filter', function (t) {
var dir = path.join(__dirname, 'resolver');
var packageFilterArgs;
var res = resolve.sync('./baz', {
basedir: dir,
// NOTE: in v2.x, this will be `pkg, pkgfile, dir`, but must remain "broken" here in v1.x for compatibility
packageFilter: function (pkg, /*pkgfile,*/ dir) { // eslint-disable-line spaced-comment
pkg.main = 'doom'; // eslint-disable-line no-param-reassign
packageFilterArgs = 'is 1.x' ? [pkg, dir] : [pkg, pkgfile, dir]; // eslint-disable-line no-constant-condition, no-undef
return pkg;
}
});
t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works');
var packageData = packageFilterArgs[0];
t.equal(packageData.main, 'doom', 'package "main" was altered');
if (!'is 1.x') { // eslint-disable-line no-constant-condition
var packageFile = packageFilterArgs[1];
t.equal(packageFile, path.join(dir, 'baz', 'package.json'), 'package.json path is correct');
}
var packageDir = packageFilterArgs['is 1.x' ? 1 : 2]; // eslint-disable-line no-constant-condition
// eslint-disable-next-line no-constant-condition
t.equal(packageDir, path.join(dir, 'baz'), ('is 1.x' ? 'second' : 'third') + ' packageFilter argument is "dir"');
t.end();
});

View File

@@ -0,0 +1,606 @@
import postcss from 'postcss'
import parser from 'postcss-selector-parser'
import { resolveMatches } from './generateRules'
import escapeClassName from '../util/escapeClassName'
/** @typedef {Map<string, [any, import('postcss').Rule[]]>} ApplyCache */
function extractClasses(node) {
/** @type {Map<string, Set<string>>} */
let groups = new Map()
let container = postcss.root({ nodes: [node.clone()] })
container.walkRules((rule) => {
parser((selectors) => {
selectors.walkClasses((classSelector) => {
let parentSelector = classSelector.parent.toString()
let classes = groups.get(parentSelector)
if (!classes) {
groups.set(parentSelector, (classes = new Set()))
}
classes.add(classSelector.value)
})
}).processSync(rule.selector)
})
let normalizedGroups = Array.from(groups.values(), (classes) => Array.from(classes))
let classes = normalizedGroups.flat()
return Object.assign(classes, { groups: normalizedGroups })
}
let selectorExtractor = parser()
/**
* @param {string} ruleSelectors
*/
function extractSelectors(ruleSelectors) {
return selectorExtractor.astSync(ruleSelectors)
}
function extractBaseCandidates(candidates, separator) {
let baseClasses = new Set()
for (let candidate of candidates) {
baseClasses.add(candidate.split(separator).pop())
}
return Array.from(baseClasses)
}
function prefix(context, selector) {
let prefix = context.tailwindConfig.prefix
return typeof prefix === 'function' ? prefix(selector) : prefix + selector
}
function* pathToRoot(node) {
yield node
while (node.parent) {
yield node.parent
node = node.parent
}
}
/**
* Only clone the node itself and not its children
*
* @param {*} node
* @param {*} overrides
* @returns
*/
function shallowClone(node, overrides = {}) {
let children = node.nodes
node.nodes = []
let tmp = node.clone(overrides)
node.nodes = children
return tmp
}
/**
* Clone just the nodes all the way to the top that are required to represent
* this singular rule in the tree.
*
* For example, if we have CSS like this:
* ```css
* @media (min-width: 768px) {
* @supports (display: grid) {
* .foo {
* display: grid;
* grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
* }
* }
*
* @supports (backdrop-filter: blur(1px)) {
* .bar {
* backdrop-filter: blur(1px);
* }
* }
*
* .baz {
* color: orange;
* }
* }
* ```
*
* And we're cloning `.bar` it'll return a cloned version of what's required for just that single node:
*
* ```css
* @media (min-width: 768px) {
* @supports (backdrop-filter: blur(1px)) {
* .bar {
* backdrop-filter: blur(1px);
* }
* }
* }
* ```
*
* @param {import('postcss').Node} node
*/
function nestedClone(node) {
for (let parent of pathToRoot(node)) {
if (node === parent) {
continue
}
if (parent.type === 'root') {
break
}
node = shallowClone(parent, {
nodes: [node],
})
}
return node
}
/**
* @param {import('postcss').Root} root
*/
function buildLocalApplyCache(root, context) {
/** @type {ApplyCache} */
let cache = new Map()
root.walkRules((rule) => {
// Ignore rules generated by Tailwind
for (let node of pathToRoot(rule)) {
if (node.raws.tailwind?.layer !== undefined) {
return
}
}
// Clone what's required to represent this singular rule in the tree
let container = nestedClone(rule)
let sort = context.offsets.create('user')
for (let className of extractClasses(rule)) {
let list = cache.get(className) || []
cache.set(className, list)
list.push([
{
layer: 'user',
sort,
important: false,
},
container,
])
}
})
return cache
}
/**
* @returns {ApplyCache}
*/
function buildApplyCache(applyCandidates, context) {
for (let candidate of applyCandidates) {
if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
continue
}
if (context.classCache.has(candidate)) {
context.applyClassCache.set(
candidate,
context.classCache.get(candidate).map(([meta, rule]) => [meta, rule.clone()])
)
continue
}
let matches = Array.from(resolveMatches(candidate, context))
if (matches.length === 0) {
context.notClassCache.add(candidate)
continue
}
context.applyClassCache.set(candidate, matches)
}
return context.applyClassCache
}
/**
* Build a cache only when it's first used
*
* @param {() => ApplyCache} buildCacheFn
* @returns {ApplyCache}
*/
function lazyCache(buildCacheFn) {
let cache = null
return {
get: (name) => {
cache = cache || buildCacheFn()
return cache.get(name)
},
has: (name) => {
cache = cache || buildCacheFn()
return cache.has(name)
},
}
}
/**
* Take a series of multiple caches and merge
* them so they act like one large cache
*
* @param {ApplyCache[]} caches
* @returns {ApplyCache}
*/
function combineCaches(caches) {
return {
get: (name) => caches.flatMap((cache) => cache.get(name) || []),
has: (name) => caches.some((cache) => cache.has(name)),
}
}
function extractApplyCandidates(params) {
let candidates = params.split(/[\s\t\n]+/g)
if (candidates[candidates.length - 1] === '!important') {
return [candidates.slice(0, -1), true]
}
return [candidates, false]
}
function processApply(root, context, localCache) {
let applyCandidates = new Set()
// Collect all @apply rules and candidates
let applies = []
root.walkAtRules('apply', (rule) => {
let [candidates] = extractApplyCandidates(rule.params)
for (let util of candidates) {
applyCandidates.add(util)
}
applies.push(rule)
})
// Start the @apply process if we have rules with @apply in them
if (applies.length === 0) {
return
}
// Fill up some caches!
let applyClassCache = combineCaches([localCache, buildApplyCache(applyCandidates, context)])
/**
* When we have an apply like this:
*
* .abc {
* @apply hover:font-bold;
* }
*
* What we essentially will do is resolve to this:
*
* .abc {
* @apply .hover\:font-bold:hover {
* font-weight: 500;
* }
* }
*
* Notice that the to-be-applied class is `.hover\:font-bold:hover` and that the utility candidate was `hover:font-bold`.
* What happens in this function is that we prepend a `.` and escape the candidate.
* This will result in `.hover\:font-bold`
* Which means that we can replace `.hover\:font-bold` with `.abc` in `.hover\:font-bold:hover` resulting in `.abc:hover`
*
* @param {string} selector
* @param {string} utilitySelectors
* @param {string} candidate
*/
function replaceSelector(selector, utilitySelectors, candidate) {
let selectorList = extractSelectors(selector)
let utilitySelectorsList = extractSelectors(utilitySelectors)
let candidateList = extractSelectors(`.${escapeClassName(candidate)}`)
let candidateClass = candidateList.nodes[0].nodes[0]
selectorList.each((sel) => {
/** @type {Set<import('postcss-selector-parser').Selector>} */
let replaced = new Set()
utilitySelectorsList.each((utilitySelector) => {
let hasReplaced = false
utilitySelector = utilitySelector.clone()
utilitySelector.walkClasses((node) => {
if (node.value !== candidateClass.value) {
return
}
// Don't replace multiple instances of the same class
// This is theoretically correct but only partially
// We'd need to generate every possible permutation of the replacement
// For example with `.foo + .foo { … }` and `section { @apply foo; }`
// We'd need to generate all of these:
// - `.foo + .foo`
// - `.foo + section`
// - `section + .foo`
// - `section + section`
if (hasReplaced) {
return
}
// Since you can only `@apply` class names this is sufficient
// We want to replace the matched class name with the selector the user is using
// Ex: Replace `.text-blue-500` with `.foo.bar:is(.something-cool)`
node.replaceWith(...sel.nodes.map((node) => node.clone()))
// Record that we did something and we want to use this new selector
replaced.add(utilitySelector)
hasReplaced = true
})
})
// Sort tag names before class names (but only sort each group (separated by a combinator)
// separately and not in total)
// This happens when replacing `.bar` in `.foo.bar` with a tag like `section`
for (let sel of replaced) {
let groups = [[]]
for (let node of sel.nodes) {
if (node.type === 'combinator') {
groups.push(node)
groups.push([])
} else {
let last = groups[groups.length - 1]
last.push(node)
}
}
sel.nodes = []
for (let group of groups) {
if (Array.isArray(group)) {
group.sort((a, b) => {
if (a.type === 'tag' && b.type === 'class') {
return -1
} else if (a.type === 'class' && b.type === 'tag') {
return 1
} else if (a.type === 'class' && b.type === 'pseudo' && b.value.startsWith('::')) {
return -1
} else if (a.type === 'pseudo' && a.value.startsWith('::') && b.type === 'class') {
return 1
}
return 0
})
}
sel.nodes = sel.nodes.concat(group)
}
}
sel.replaceWith(...replaced)
})
return selectorList.toString()
}
let perParentApplies = new Map()
// Collect all apply candidates and their rules
for (let apply of applies) {
let [candidates] = perParentApplies.get(apply.parent) || [[], apply.source]
perParentApplies.set(apply.parent, [candidates, apply.source])
let [applyCandidates, important] = extractApplyCandidates(apply.params)
if (apply.parent.type === 'atrule') {
if (apply.parent.name === 'screen') {
let screenType = apply.parent.params
throw apply.error(
`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates
.map((c) => `${screenType}:${c}`)
.join(' ')} instead.`
)
}
throw apply.error(
`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`
)
}
for (let applyCandidate of applyCandidates) {
if ([prefix(context, 'group'), prefix(context, 'peer')].includes(applyCandidate)) {
// TODO: Link to specific documentation page with error code.
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`)
}
if (!applyClassCache.has(applyCandidate)) {
throw apply.error(
`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`
)
}
let rules = applyClassCache.get(applyCandidate)
candidates.push([applyCandidate, important, rules])
}
}
for (let [parent, [candidates, atApplySource]] of perParentApplies) {
let siblings = []
for (let [applyCandidate, important, rules] of candidates) {
let potentialApplyCandidates = [
applyCandidate,
...extractBaseCandidates([applyCandidate], context.tailwindConfig.separator),
]
for (let [meta, node] of rules) {
let parentClasses = extractClasses(parent)
let nodeClasses = extractClasses(node)
// When we encounter a rule like `.dark .a, .b { … }` we only want to be left with `[.dark, .a]` if the base applyCandidate is `.a` or with `[.b]` if the base applyCandidate is `.b`
// So we've split them into groups
nodeClasses = nodeClasses.groups
.filter((classList) =>
classList.some((className) => potentialApplyCandidates.includes(className))
)
.flat()
// Add base utility classes from the @apply node to the list of
// classes to check whether it intersects and therefore results in a
// circular dependency or not.
//
// E.g.:
// .foo {
// @apply hover:a; // This applies "a" but with a modifier
// }
//
// We only have to do that with base classes of the `node`, not of the `parent`
// E.g.:
// .hover\:foo {
// @apply bar;
// }
// .bar {
// @apply foo;
// }
//
// This should not result in a circular dependency because we are
// just applying `.foo` and the rule above is `.hover\:foo` which is
// unrelated. However, if we were to apply `hover:foo` then we _did_
// have to include this one.
nodeClasses = nodeClasses.concat(
extractBaseCandidates(nodeClasses, context.tailwindConfig.separator)
)
let intersects = parentClasses.some((selector) => nodeClasses.includes(selector))
if (intersects) {
throw node.error(
`You cannot \`@apply\` the \`${applyCandidate}\` utility here because it creates a circular dependency.`
)
}
let root = postcss.root({ nodes: [node.clone()] })
// Make sure every node in the entire tree points back at the @apply rule that generated it
root.walk((node) => {
node.source = atApplySource
})
let canRewriteSelector =
node.type !== 'atrule' || (node.type === 'atrule' && node.name !== 'keyframes')
if (canRewriteSelector) {
root.walkRules((rule) => {
// Let's imagine you have the following structure:
//
// .foo {
// @apply bar;
// }
//
// @supports (a: b) {
// .bar {
// color: blue
// }
//
// .something-unrelated {}
// }
//
// In this case we want to apply `.bar` but it happens to be in
// an atrule node. We clone that node instead of the nested one
// because we still want that @supports rule to be there once we
// applied everything.
//
// However it happens to be that the `.something-unrelated` is
// also in that same shared @supports atrule. This is not good,
// and this should not be there. The good part is that this is
// a clone already and it can be safely removed. The question is
// how do we know we can remove it. Basically what we can do is
// match it against the applyCandidate that you want to apply. If
// it doesn't match the we can safely delete it.
//
// If we didn't do this, then the `replaceSelector` function
// would have replaced this with something that didn't exist and
// therefore it removed the selector altogether. In this specific
// case it would result in `{}` instead of `.something-unrelated {}`
if (!extractClasses(rule).some((candidate) => candidate === applyCandidate)) {
rule.remove()
return
}
// Strip the important selector from the parent selector if at the beginning
let importantSelector =
typeof context.tailwindConfig.important === 'string'
? context.tailwindConfig.important
: null
// We only want to move the "important" selector if this is a Tailwind-generated utility
// We do *not* want to do this for user CSS that happens to be structured the same
let isGenerated = parent.raws.tailwind !== undefined
let parentSelector =
isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0
? parent.selector.slice(importantSelector.length)
: parent.selector
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate)
// And then re-add it if it was removed
if (importantSelector && parentSelector !== parent.selector) {
rule.selector = `${importantSelector} ${rule.selector}`
}
rule.walkDecls((d) => {
d.important = meta.important || important
})
})
}
// It could be that the node we were inserted was removed because the class didn't match
// If that was the *only* rule in the parent, then we have nothing add so we skip it
if (!root.nodes[0]) {
continue
}
// Insert it
siblings.push([meta.sort, root.nodes[0]])
}
}
// Inject the rules, sorted, correctly
let nodes = context.offsets.sort(siblings).map((s) => s[1])
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
parent.after(nodes)
}
for (let apply of applies) {
// If there are left-over declarations, just remove the @apply
if (apply.parent.nodes.length > 1) {
apply.remove()
} else {
// The node is empty, drop the full node
apply.parent.remove()
}
}
// Do it again, in case we have other `@apply` rules
processApply(root, context, localCache)
}
export default function expandApplyAtRules(context) {
return (root) => {
// Build a cache of the user's CSS so we can use it to resolve classes used by @apply
let localCache = lazyCache(() => buildLocalApplyCache(root, context))
processApply(root, context, localCache)
}
}

View File

@@ -0,0 +1,279 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for csv2json/libs/core/defaultParsers/parser_json.js</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/libs/core/defaultParsers</a> parser_json.js
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Statements</span>
<span class='fraction'>0/39</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/34</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Functions</span>
<span class='fraction'>0/2</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Lines</span>
<span class='fraction'>0/39</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 low'></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></td><td class="line-coverage quiet"><span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">var arrReg = <span class="cstat-no" title="statement not covered" >/\[([0-9]*)\]/;</span>
&nbsp;
&nbsp;
function <span class="fstat-no" title="function not covered" >processHead(</span>pointer, headArr, arrReg, flatKeys) {
var headStr, match, index;
<span class="cstat-no" title="statement not covered" > while (headArr.length &gt; 1) {</span>
<span class="cstat-no" title="statement not covered" > headStr = headArr.shift();</span>
// match = headStr.match(arrReg);
<span class="cstat-no" title="statement not covered" > match = flatKeys ? false : headStr.match(arrReg);</span>
<span class="cstat-no" title="statement not covered" > if (match) { //if its array, we need add an empty json object into specified index.</span>
<span class="cstat-no" title="statement not covered" > if (pointer[headStr.replace(match[0], '')] === undefined) {</span>
<span class="cstat-no" title="statement not covered" > pointer[headStr.replace(match[0], '')] = [];</span>
}
<span class="cstat-no" title="statement not covered" > index = match[1]; </span>//get index where json object should stay
<span class="cstat-no" title="statement not covered" > pointer = pointer[headStr.replace(match[0], '')];</span>
<span class="cstat-no" title="statement not covered" > if (index === '') { //if its dynamic array index, push to the end</span>
<span class="cstat-no" title="statement not covered" > index = pointer.length;</span>
}
<span class="cstat-no" title="statement not covered" > if (!pointer[index]) { //current index in the array is empty. we need create a new json object.</span>
<span class="cstat-no" title="statement not covered" > pointer[index] = {};</span>
}
<span class="cstat-no" title="statement not covered" > pointer = pointer[index];</span>
} else { //not array, just normal JSON object. we get the reference of it
<span class="cstat-no" title="statement not covered" > if (pointer[headStr] === undefined) {</span>
<span class="cstat-no" title="statement not covered" > pointer[headStr] = {};</span>
}
<span class="cstat-no" title="statement not covered" > pointer = pointer[headStr];</span>
}
}
<span class="cstat-no" title="statement not covered" > return pointer;</span>
}
<span class="cstat-no" title="statement not covered" >module.exports = {</span>
"name": "json",
"processSafe": true,
"regExp": /^\*json\*/,
"parserFunc": function <span class="fstat-no" title="function not covered" >parser_json(</span>params) {
var fieldStr = <span class="cstat-no" title="statement not covered" >this.getHeadStr();</span>
var headArr = <span class="cstat-no" title="statement not covered" >(params.config &amp;&amp; params.config.flatKeys) ? [fieldStr] : fieldStr.split('.');</span>
var match, index, key;
//now the pointer is pointing the position to add a key/value pair.
var pointer = <span class="cstat-no" title="statement not covered" >processHead(params.resultRow, headArr, arrReg, params.config &amp;&amp; params.config.flatKeys);</span>
<span class="cstat-no" title="statement not covered" > key = headArr.shift();</span>
<span class="cstat-no" title="statement not covered" > match = (params.config &amp;&amp; params.config.flatKeys) ? false : key.match(arrReg);</span>
<span class="cstat-no" title="statement not covered" > if (match) { // the last element is an array, we need check and treat it as an array.</span>
<span class="cstat-no" title="statement not covered" > try {</span>
<span class="cstat-no" title="statement not covered" > key = key.replace(match[0], '');</span>
<span class="cstat-no" title="statement not covered" > if (!pointer[key] || !(pointer[key] instanceof Array)) {</span>
<span class="cstat-no" title="statement not covered" > pointer[key] = [];</span>
}
<span class="cstat-no" title="statement not covered" > if (pointer[key]) {</span>
<span class="cstat-no" title="statement not covered" > index = match[1];</span>
<span class="cstat-no" title="statement not covered" > if (index === '') {</span>
<span class="cstat-no" title="statement not covered" > index = pointer[key].length;</span>
}
<span class="cstat-no" title="statement not covered" > pointer[key][index] = params.item;</span>
} else {
<span class="cstat-no" title="statement not covered" > params.resultRow[fieldStr] = params.item;</span>
}
} catch (e) {
<span class="cstat-no" title="statement not covered" > params.resultRow[fieldStr] = params.item;</span>
}
} else {
<span class="cstat-no" title="statement not covered" > if (typeof pointer === "string"){</span>
<span class="cstat-no" title="statement not covered" > params.resultRow[fieldStr] = params.item;</span>
}else{
<span class="cstat-no" title="statement not covered" > pointer[key] = params.item;</span>
}
}
}
};
&nbsp;</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:20:20 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>