new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("chai").assert
|
||||
, ensureFunction = require("../../function/ensure");
|
||||
|
||||
describe("function/ensure", function () {
|
||||
it("Should return input value", function () {
|
||||
var value = function () { return true; };
|
||||
assert.equal(ensureFunction(value), value);
|
||||
});
|
||||
it("Should crash on invalid value", function () {
|
||||
try {
|
||||
ensureFunction(null);
|
||||
throw new Error("Unexpected");
|
||||
} catch (error) {
|
||||
assert.equal(error.name, "TypeError");
|
||||
assert(error.message.includes("is not a function"));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/libs/core/defaultParsers/parser_jsonarray.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_jsonarray.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/13</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/4</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/1</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>0/13</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></td><td class="line-coverage quiet"><span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js"><span class="cstat-no" title="statement not covered" >module.exports = {</span>
|
||||
"name": "jsonarray",
|
||||
"processSafe":true,
|
||||
"regExp": /^\*jsonarray\*/,
|
||||
"parserFunc": function <span class="fstat-no" title="function not covered" >parser_jsonarray </span>(params) {
|
||||
var fieldStr = <span class="cstat-no" title="statement not covered" >params.head.replace(this.regExp, "");</span>
|
||||
var headArr = <span class="cstat-no" title="statement not covered" >fieldStr.split('.');</span>
|
||||
var pointer = <span class="cstat-no" title="statement not covered" >params.resultRow;</span>
|
||||
<span class="cstat-no" title="statement not covered" > while (headArr.length > 1) {</span>
|
||||
var headStr = <span class="cstat-no" title="statement not covered" >headArr.shift();</span>
|
||||
<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>
|
||||
}
|
||||
var arrFieldName = <span class="cstat-no" title="statement not covered" >headArr.shift();</span>
|
||||
<span class="cstat-no" title="statement not covered" > if (pointer[arrFieldName] === undefined) {</span>
|
||||
<span class="cstat-no" title="statement not covered" > pointer[arrFieldName] = [];</span>
|
||||
}
|
||||
<span class="cstat-no" title="statement not covered" > pointer[arrFieldName].push(params.item);</span>
|
||||
}
|
||||
};
|
||||
</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>
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.exhaustAll = void 0;
|
||||
var exhaustMap_1 = require("./exhaustMap");
|
||||
var identity_1 = require("../util/identity");
|
||||
function exhaustAll() {
|
||||
return exhaustMap_1.exhaustMap(identity_1.identity);
|
||||
}
|
||||
exports.exhaustAll = exhaustAll;
|
||||
//# sourceMappingURL=exhaustAll.js.map
|
||||
@@ -0,0 +1,39 @@
|
||||
import { __asyncGenerator, __await, __generator } from "tslib";
|
||||
import { isFunction } from './isFunction';
|
||||
export function readableStreamLikeToAsyncGenerator(readableStream) {
|
||||
return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
|
||||
var reader, _a, value, done;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
reader = readableStream.getReader();
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, , 9, 10]);
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
if (!true) return [3, 8];
|
||||
return [4, __await(reader.read())];
|
||||
case 3:
|
||||
_a = _b.sent(), value = _a.value, done = _a.done;
|
||||
if (!done) return [3, 5];
|
||||
return [4, __await(void 0)];
|
||||
case 4: return [2, _b.sent()];
|
||||
case 5: return [4, __await(value)];
|
||||
case 6: return [4, _b.sent()];
|
||||
case 7:
|
||||
_b.sent();
|
||||
return [3, 2];
|
||||
case 8: return [3, 10];
|
||||
case 9:
|
||||
reader.releaseLock();
|
||||
return [7];
|
||||
case 10: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
export function isReadableStreamLike(obj) {
|
||||
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
||||
}
|
||||
//# sourceMappingURL=isReadableStreamLike.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"electron-to-chromium","version":"1.4.299","files":{"LICENSE":{"checkedAt":1678883670265,"integrity":"sha512-bQxy4xOHhcBKtGqn/MGP6sxD+QIzWGej3T/A8NXn1i5xuYFLmNkCNJfebeE3Ox42BU7uKR+NhkERay6YZFE1/g==","mode":420,"size":728},"chromium-versions.js":{"checkedAt":1678883670265,"integrity":"sha512-NN9qn5hNyP9tc6MhjttjvI7cdqjigB04G1kGChGKjmxaxeVPSSyyde3uuQGUtzhtNji0ZjzDrPo+K4yXNLgZ2Q==","mode":420,"size":791},"full-chromium-versions.js":{"checkedAt":1678883670268,"integrity":"sha512-w5/5y24xYa/AmmYhDsJVWdd14RgYB9foqB3Ot/4OWiQEF4zCHIAzI2D9J3iiWXO+6r9aTwxjWsVgMP7+chUvow==","mode":420,"size":43036},"full-versions.js":{"checkedAt":1678883670272,"integrity":"sha512-8so7mQl39TUr1BU9UGdYJgAiHM0f7D8pyd86rWUkw6p2t+VbbdkFZRn9NJGRygHs+BMWuLO9NFSR8LiYAazMWA==","mode":420,"size":62522},"index.js":{"checkedAt":1678883670272,"integrity":"sha512-ovbfk0+3PexBh69SQfeCLAuOSrRECp+jN3icVfVtnTipDEh7zD5OlwSCIibCX9aYnTUsFkDaara28w/3hoaakw==","mode":420,"size":1204},"versions.js":{"checkedAt":1678883670273,"integrity":"sha512-IbET8Qt8XLS7m8lt+71nngGb3LyhbXrYEqDbqT41JcvwEUYBcrlHvJy75JY6+FU2QHZGZ9tWraydfsH32lEskA==","mode":420,"size":1688},"chromium-versions.json":{"checkedAt":1678883670273,"integrity":"sha512-1mTkhheC2w4/FoYRl2DKjuQJaGDnWDCNZI6cFz8EEqpPaHccSiPCI8kGSDPV6I5AzR+p2LgrGrI6d+yFq0RL7Q==","mode":420,"size":616},"full-chromium-versions.json":{"checkedAt":1678883670275,"integrity":"sha512-b6DK3IOZMG9a6a6yetROpMuK2K01zqCRClz8OlvmK44kc4DBqzCzVY+5NoXbcTnZGJuHfFeySsVjP5Dl4zjWvA==","mode":420,"size":36193},"full-versions.json":{"checkedAt":1678883670278,"integrity":"sha512-/f9Oe8mwzExGxBcI3T1YPxwMcwBb+Ca1A5nzp++3y/w3wT0JL+PJtYktuBjjJPihVuMoeEF4bbwrUQ/GXh6+zw==","mode":420,"size":57229},"package.json":{"checkedAt":1678883670279,"integrity":"sha512-iyedPt8ImxNcI9vBtPopXS8LiBzWh2RuOJNl4lu64lpTb2t4wGuyVGMN5sTmbGphaYcEVXVfawqOoTwzLQwsDQ==","mode":420,"size":1054},"versions.json":{"checkedAt":1678883670279,"integrity":"sha512-J+eZPmkYRIekdjzNU0AebPFc0svSt+yFDQuR2tWiQpJOF6NEPqYj2XWRlcod/4OutfgEk/JWuPPXp6zL8+FFgQ==","mode":420,"size":1333},"CHANGELOG.md":{"checkedAt":1678883670279,"integrity":"sha512-bbbnuSJ4WiiZFc94yq+uPfi8erKUgvIz3meMPV7UhvjxTy2pRr4eOlW6IBKDf3L1kZBeYnDNeZkc1Z+jT/ViCQ==","mode":420,"size":296},"README.md":{"checkedAt":1678883670279,"integrity":"sha512-w6zTztX1ejavIkY//V+KqWoBAHjAsHFYhHYUzec/V4ATJpfzTS5HSD/o9zReARo361nzQWBk8s+4KPyEqHG89w==","mode":420,"size":6460}}}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
var split = require('../utils/split');
|
||||
|
||||
var BRACE_PREFIX = /^\(/;
|
||||
var BRACE_SUFFIX = /\)$/;
|
||||
var IMPORT_PREFIX_PATTERN = /^@import/i;
|
||||
var QUOTE_PREFIX_PATTERN = /['"]\s*/;
|
||||
var QUOTE_SUFFIX_PATTERN = /\s*['"]/;
|
||||
var URL_PREFIX_PATTERN = /^url\(\s*/i;
|
||||
var URL_SUFFIX_PATTERN = /\s*\)/i;
|
||||
|
||||
function extractImportUrlAndMedia(atRuleValue) {
|
||||
var uri;
|
||||
var mediaQuery;
|
||||
var stripped;
|
||||
var parts;
|
||||
|
||||
stripped = atRuleValue
|
||||
.replace(IMPORT_PREFIX_PATTERN, '')
|
||||
.trim()
|
||||
.replace(URL_PREFIX_PATTERN, '(')
|
||||
.replace(URL_SUFFIX_PATTERN, ')')
|
||||
.replace(QUOTE_PREFIX_PATTERN, '')
|
||||
.replace(QUOTE_SUFFIX_PATTERN, '');
|
||||
|
||||
parts = split(stripped, ' ');
|
||||
|
||||
uri = parts[0]
|
||||
.replace(BRACE_PREFIX, '')
|
||||
.replace(BRACE_SUFFIX, '');
|
||||
mediaQuery = parts.slice(1).join(' ');
|
||||
|
||||
return [uri, mediaQuery];
|
||||
}
|
||||
|
||||
module.exports = extractImportUrlAndMedia;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { LocaleData } from './core';
|
||||
export declare type ListPatternLocaleData = LocaleData<ListPatternFieldsData>;
|
||||
export interface ListPatternFieldsData {
|
||||
conjunction?: ListPatternData;
|
||||
disjunction?: ListPatternData;
|
||||
unit?: ListPatternData;
|
||||
}
|
||||
export interface ListPattern {
|
||||
start: string;
|
||||
middle: string;
|
||||
end: string;
|
||||
pair: string;
|
||||
}
|
||||
export interface ListPatternData {
|
||||
long: ListPattern;
|
||||
short?: ListPattern;
|
||||
narrow?: ListPattern;
|
||||
}
|
||||
//# sourceMappingURL=list.d.ts.map
|
||||
@@ -0,0 +1,5 @@
|
||||
import assertString from './util/assertString';
|
||||
export default function blacklist(str, chars) {
|
||||
assertString(str);
|
||||
return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import * as nodeCrypto from 'crypto';
|
||||
|
||||
export const crypto: { node?: any; web?: any } = {
|
||||
node: nodeCrypto,
|
||||
web: undefined,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isPromise.d.ts","sourceRoot":"","sources":["../../../../src/internal/util/isPromise.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,CAE/D"}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { EnsureFunction, EnsureBaseOptions, EnsureIsOptional, EnsureDefault } from '../ensure';
|
||||
|
||||
type IterableEnsureOptions = { ensureItem?: EnsureFunction, allowString?: boolean, denyEmpty?: boolean};
|
||||
|
||||
|
||||
declare function ensureIterable<T>(value: any, options?: IterableEnsureOptions & EnsureBaseOptions): T[];
|
||||
declare function ensureIterable<T>(value: any, options?: IterableEnsureOptions & EnsureBaseOptions & EnsureIsOptional): T[] | null;
|
||||
declare function ensureIterable<T>(value: any, options?: IterableEnsureOptions & EnsureBaseOptions & EnsureIsOptional & EnsureDefault<T[]>): T[];
|
||||
|
||||
export default ensureIterable;
|
||||
@@ -0,0 +1,5 @@
|
||||
export { ajax } from '../internal/ajax/ajax';
|
||||
export { AjaxError, AjaxTimeoutError } from '../internal/ajax/errors';
|
||||
export { AjaxResponse } from '../internal/ajax/AjaxResponse';
|
||||
export { AjaxRequest, AjaxConfig, AjaxDirection } from '../internal/ajax/types';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: ()=>isKeyframeRule
|
||||
});
|
||||
function isKeyframeRule(rule) {
|
||||
return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
if(typeof cptable === 'undefined') cptable = {};
|
||||
cptable[20871] = (function(){ var d = "\u0002\u0003\t\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013
\b\u0018\u0019\u001c\u001d\u001e\u001f\n\u0017\u001b\u0005\u0006\u0007\u0016\u0004\u0014\u0015\u001a âäàáãåçñÞ.<(+!&éêëèíîïì߯$*);Ö-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌð:#Ð'=\"Øabcdefghi«»`ý{±°jklmnopqrªº}¸]¤µöstuvwxyz¡¿@Ý[®¢£¥·©§¶¼½¾¬|¯¨\\×þABCDEFGHIô~òóõæJKLMNOPQR¹ûüùúÿ´÷STUVWXYZ²Ô^ÒÓÕ0123456789³ÛÜÙÚ", D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d.charAt(i)] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })();
|
||||
@@ -0,0 +1,126 @@
|
||||
# @nodelib/fs.stat
|
||||
|
||||
> Get the status of a file with some features.
|
||||
|
||||
## :bulb: Highlights
|
||||
|
||||
Wrapper around standard method `fs.lstat` and `fs.stat` with some features.
|
||||
|
||||
* :beginner: Normally follows symbolic link.
|
||||
* :gear: Can safely work with broken symbolic link.
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
npm install @nodelib/fs.stat
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import * as fsStat from '@nodelib/fs.stat';
|
||||
|
||||
fsStat.stat('path', (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .stat(path, [optionsOrSettings], callback)
|
||||
|
||||
Returns an instance of `fs.Stats` class for provided path with standard callback-style.
|
||||
|
||||
```ts
|
||||
fsStat.stat('path', (error, stats) => { /* … */ });
|
||||
fsStat.stat('path', {}, (error, stats) => { /* … */ });
|
||||
fsStat.stat('path', new fsStat.Settings(), (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
### .statSync(path, [optionsOrSettings])
|
||||
|
||||
Returns an instance of `fs.Stats` class for provided path.
|
||||
|
||||
```ts
|
||||
const stats = fsStat.stat('path');
|
||||
const stats = fsStat.stat('path', {});
|
||||
const stats = fsStat.stat('path', new fsStat.Settings());
|
||||
```
|
||||
|
||||
#### path
|
||||
|
||||
* Required: `true`
|
||||
* Type: `string | Buffer | URL`
|
||||
|
||||
A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
|
||||
#### optionsOrSettings
|
||||
|
||||
* Required: `false`
|
||||
* Type: `Options | Settings`
|
||||
* Default: An instance of `Settings` class
|
||||
|
||||
An [`Options`](#options) object or an instance of [`Settings`](#settings) class.
|
||||
|
||||
> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class.
|
||||
|
||||
### Settings([options])
|
||||
|
||||
A class of full settings of the package.
|
||||
|
||||
```ts
|
||||
const settings = new fsStat.Settings({ followSymbolicLink: false });
|
||||
|
||||
const stats = fsStat.stat('path', settings);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### `followSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Follow symbolic link or not. Call `fs.stat` on symbolic link if `true`.
|
||||
|
||||
### `markSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Mark symbolic link by setting the return value of `isSymbolicLink` function to always `true` (even after `fs.stat`).
|
||||
|
||||
> :book: Can be used if you want to know what is hidden behind a symbolic link, but still continue to know that it is a symbolic link.
|
||||
|
||||
### `throwErrorOnBrokenSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`.
|
||||
|
||||
### `fs`
|
||||
|
||||
* Type: [`FileSystemAdapter`](./src/adapters/fs.ts)
|
||||
* Default: A default FS methods
|
||||
|
||||
By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own.
|
||||
|
||||
```ts
|
||||
interface FileSystemAdapter {
|
||||
lstat?: typeof fs.lstat;
|
||||
stat?: typeof fs.stat;
|
||||
lstatSync?: typeof fs.lstatSync;
|
||||
statSync?: typeof fs.statSync;
|
||||
}
|
||||
|
||||
const settings = new fsStat.Settings({
|
||||
fs: { lstat: fakeLstat }
|
||||
});
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version.
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the terms of the MIT license.
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"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","2":"C K L"},C:{"1":"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":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB EC FC"},D:{"1":"RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB","194":"PB","257":"QB"},E:{"1":"K L G 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 0B","513":"B C qB rB"},F:{"1":"EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB PC QC RC SC qB AC TC rB","194":"CB DB"},G:{"1":"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 cC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:6,C:"Brotli Accept-Encoding/Content-Encoding"};
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (childPath, parentPath) => {
|
||||
const relation = path.relative(parentPath, childPath);
|
||||
return Boolean(
|
||||
relation &&
|
||||
relation !== '..' &&
|
||||
!relation.startsWith(`..${path.sep}`) &&
|
||||
relation !== path.resolve(childPath)
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"2":"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:{"33":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB 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","164":"DC tB EC FC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},E:{"2":"I v J D E F A B C K L G HC zB IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB 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 PC QC RC SC qB AC TC rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"2":"tB I f pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"2":"A B C h qB AC rB"},L:{"2":"H"},M:{"33":"H"},N:{"2":"A B"},O:{"2":"vC"},P:{"2":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"2":"1B"},R:{"2":"9C"},S:{"33":"AD BD"}},B:5,C:"CSS element() function"};
|
||||
@@ -0,0 +1,109 @@
|
||||
import {MergeExclusive} from 'type-fest';
|
||||
|
||||
interface BaseOptions {
|
||||
/**
|
||||
Length of the returned string.
|
||||
*/
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface TypeOption {
|
||||
/**
|
||||
Use only characters from a predefined set of allowed characters.
|
||||
|
||||
Cannot be set at the same time as the `characters` option.
|
||||
|
||||
@default 'hex'
|
||||
|
||||
The `distinguishable` set contains only uppercase characters that are not easily confused: `CDEHKMPRTUWXY012458`. It can be useful if you need to print out a short string that you'd like users to read and type back in with minimal errors. For example, reading a code off of a screen that needs to be typed into a phone to connect two devices.
|
||||
|
||||
The `ascii-printable` set contains all [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters): ``!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~`` Useful for generating passwords where all possible ASCII characters should be used.
|
||||
|
||||
The `alphanumeric` set contains uppercase letters, lowercase letters, and digits: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`. Useful for generating [nonce](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/nonce) values.
|
||||
|
||||
@example
|
||||
```
|
||||
cryptoRandomString({length: 10});
|
||||
//=> '87fc70e2b9'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'base64'});
|
||||
//=> 'mhsX7xmIv/'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'url-safe'});
|
||||
//=> 'VEjfNW3Yej'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'numeric'});
|
||||
//=> '8314659141'
|
||||
|
||||
cryptoRandomString({length: 6, type: 'distinguishable'});
|
||||
//=> 'CDEHKM'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'ascii-printable'});
|
||||
//=> '`#Rt8$IK>B'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'alphanumeric'});
|
||||
//=> 'DMuKL8YtE7'
|
||||
```
|
||||
*/
|
||||
type?: 'hex' | 'base64' | 'url-safe' | 'numeric' | 'distinguishable' | 'ascii-printable' | 'alphanumeric';
|
||||
}
|
||||
|
||||
interface CharactersOption {
|
||||
/**
|
||||
Use only characters from a custom set of allowed characters.
|
||||
|
||||
Cannot be set at the same time as the `type` option.
|
||||
|
||||
Minimum length: `1`
|
||||
Maximum length: `65536`
|
||||
|
||||
@example
|
||||
```
|
||||
cryptoRandomString({length: 10, characters: '0123456789'});
|
||||
//=> '8796225811'
|
||||
```
|
||||
*/
|
||||
characters?: string;
|
||||
}
|
||||
|
||||
export type Options = BaseOptions & MergeExclusive<TypeOption, CharactersOption>;
|
||||
|
||||
declare const cryptoRandomString: {
|
||||
/**
|
||||
Generate a [cryptographically strong](https://en.wikipedia.org/wiki/Strong_cryptography) random string.
|
||||
|
||||
@returns A randomized string.
|
||||
|
||||
@example
|
||||
```
|
||||
import cryptoRandomString from 'crypto-random-string';
|
||||
|
||||
cryptoRandomString({length: 10});
|
||||
//=> '2cf05d94db'
|
||||
```
|
||||
*/
|
||||
(options: Options): string;
|
||||
|
||||
/**
|
||||
Asynchronously generate a [cryptographically strong](https://en.wikipedia.org/wiki/Strong_cryptography) random string.
|
||||
|
||||
For most use-cases, there's really no good reason to use this async version. From the Node.js docs:
|
||||
|
||||
> The `crypto.randomBytes()` method will not complete until there is sufficient entropy available. This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy.
|
||||
|
||||
In general, anything async comes with some overhead on it's own.
|
||||
|
||||
@returns A promise which resolves to a randomized string.
|
||||
|
||||
@example
|
||||
```
|
||||
import cryptoRandomString from 'crypto-random-string';
|
||||
|
||||
await cryptoRandomString.async({length: 10});
|
||||
//=> '2cf05d94db'
|
||||
```
|
||||
*/
|
||||
async(options: Options): Promise<string>;
|
||||
};
|
||||
|
||||
export default cryptoRandomString;
|
||||
@@ -0,0 +1,98 @@
|
||||
'use strict';
|
||||
|
||||
function isPromise(obj) {
|
||||
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a function that will run a function asynchronously or synchronously
|
||||
*
|
||||
* example:
|
||||
* runAsync(wrappedFunction, callback)(...args);
|
||||
*
|
||||
* @param {Function} func Function to run
|
||||
* @param {Function} cb Callback function passed the `func` returned value
|
||||
* @return {Function(arguments)} Arguments to pass to `func`. This function will in turn
|
||||
* return a Promise (Node >= 0.12) or call the callbacks.
|
||||
*/
|
||||
|
||||
var runAsync = module.exports = function (func, cb) {
|
||||
cb = cb || function () {};
|
||||
|
||||
return function () {
|
||||
|
||||
var args = arguments;
|
||||
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
var resolved = false;
|
||||
const wrappedResolve = function (value) {
|
||||
if (resolved) {
|
||||
console.warn('Run-async promise already resolved.')
|
||||
}
|
||||
resolved = true;
|
||||
resolve(value);
|
||||
}
|
||||
|
||||
var rejected = false;
|
||||
const wrappedReject = function (value) {
|
||||
if (rejected) {
|
||||
console.warn('Run-async promise already rejected.')
|
||||
}
|
||||
rejected = true;
|
||||
reject(value);
|
||||
}
|
||||
|
||||
var usingCallback = false;
|
||||
var callbackConflict = false;
|
||||
var contextEnded = false;
|
||||
|
||||
var answer = func.apply({
|
||||
async: function () {
|
||||
if (contextEnded) {
|
||||
console.warn('Run-async async() called outside a valid run-async context, callback will be ignored.');
|
||||
return function() {};
|
||||
}
|
||||
if (callbackConflict) {
|
||||
console.warn('Run-async wrapped function (async) returned a promise.\nCalls to async() callback can have unexpected results.');
|
||||
}
|
||||
usingCallback = true;
|
||||
return function (err, value) {
|
||||
if (err) {
|
||||
wrappedReject(err);
|
||||
} else {
|
||||
wrappedResolve(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}, Array.prototype.slice.call(args));
|
||||
|
||||
if (usingCallback) {
|
||||
if (isPromise(answer)) {
|
||||
console.warn('Run-async wrapped function (sync) returned a promise but async() callback must be executed to resolve.');
|
||||
}
|
||||
} else {
|
||||
if (isPromise(answer)) {
|
||||
callbackConflict = true;
|
||||
answer.then(wrappedResolve, wrappedReject);
|
||||
} else {
|
||||
wrappedResolve(answer);
|
||||
}
|
||||
}
|
||||
contextEnded = true;
|
||||
});
|
||||
|
||||
promise.then(cb.bind(null, null), cb);
|
||||
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
|
||||
runAsync.cb = function (func, cb) {
|
||||
return runAsync(function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
if (args.length === func.length - 1) {
|
||||
args.push(this.async());
|
||||
}
|
||||
return func.apply(this, args);
|
||||
}, cb);
|
||||
};
|
||||
@@ -0,0 +1,208 @@
|
||||
import path from 'node:path';
|
||||
import test from 'ava';
|
||||
import sh from 'shelljs';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'sinon';
|
||||
import Log from '../lib/log.js';
|
||||
import Spinner from '../lib/spinner.js';
|
||||
import Prompt from '../lib/prompt.js';
|
||||
import Config from '../lib/config.js';
|
||||
import runTasks from '../lib/index.js';
|
||||
import { mkTmpDir, gitAdd } from './util/helpers.js';
|
||||
import ShellStub from './stub/shell.js';
|
||||
import { interceptPublish as interceptGitLabPublish } from './stub/gitlab.js';
|
||||
import { interceptCreate as interceptGitHubCreate } from './stub/github.js';
|
||||
|
||||
const noop = Promise.resolve();
|
||||
|
||||
const sandbox = sinon.createSandbox();
|
||||
|
||||
const testConfig = {
|
||||
ci: false,
|
||||
config: false
|
||||
};
|
||||
|
||||
const log = sandbox.createStubInstance(Log);
|
||||
const spinner = sandbox.createStubInstance(Spinner);
|
||||
spinner.show.callsFake(({ enabled = true, task }) => (enabled ? task() : noop));
|
||||
|
||||
const defaultInquirer = {
|
||||
prompt: sandbox.stub().callsFake(([options]) => {
|
||||
const answer = options.type === 'list' ? options.choices[0].value : options.name === 'version' ? '0.0.1' : true;
|
||||
return { [options.name]: answer };
|
||||
})
|
||||
};
|
||||
|
||||
const getContainer = (options, inquirer = defaultInquirer) => {
|
||||
const config = new Config(Object.assign({}, testConfig, options));
|
||||
const shell = new ShellStub({ container: { log, config } });
|
||||
const prompt = new Prompt({ container: { inquirer } });
|
||||
return {
|
||||
log,
|
||||
spinner,
|
||||
config,
|
||||
shell,
|
||||
prompt
|
||||
};
|
||||
};
|
||||
|
||||
const getHooks = plugins => {
|
||||
const hooks = {};
|
||||
['before', 'after'].forEach(prefix => {
|
||||
plugins.forEach(ns => {
|
||||
['init', 'beforeBump', 'bump', 'beforeRelease', 'release', 'afterRelease'].forEach(lifecycle => {
|
||||
hooks[`${prefix}:${lifecycle}`] = `echo ${prefix}:${lifecycle}`;
|
||||
hooks[`${prefix}:${ns}:${lifecycle}`] = `echo ${prefix}:${ns}:${lifecycle}`;
|
||||
});
|
||||
});
|
||||
});
|
||||
return hooks;
|
||||
};
|
||||
|
||||
test.before(t => {
|
||||
t.timeout(90 * 1000);
|
||||
});
|
||||
|
||||
test.serial.beforeEach(t => {
|
||||
const bare = mkTmpDir();
|
||||
const target = mkTmpDir();
|
||||
sh.pushd('-q', bare);
|
||||
sh.exec(`git init --bare .`);
|
||||
sh.exec(`git clone ${bare} ${target}`);
|
||||
sh.pushd('-q', target);
|
||||
gitAdd('line', 'file', 'Add file');
|
||||
t.context = { bare, target };
|
||||
});
|
||||
|
||||
test.serial.afterEach(() => {
|
||||
sandbox.resetHistory();
|
||||
});
|
||||
|
||||
test.serial('should run tasks without throwing errors', async t => {
|
||||
sh.mv('.git', 'foo');
|
||||
const { name, latestVersion, version } = await runTasks({}, getContainer());
|
||||
t.is(version, '0.0.1');
|
||||
t.true(log.obtrusive.firstCall.args[0].includes(`release ${name} (currently at ${latestVersion})`));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
});
|
||||
|
||||
test.serial('should not run hooks for disabled release-cycle methods', async t => {
|
||||
const hooks = getHooks(['version', 'git', 'github', 'gitlab', 'npm']);
|
||||
|
||||
const container = getContainer({
|
||||
hooks,
|
||||
git: { push: false },
|
||||
github: { release: false },
|
||||
gitlab: { release: false },
|
||||
npm: { publish: false }
|
||||
});
|
||||
|
||||
const exec = sandbox.spy(container.shell, 'execFormattedCommand');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const commands = _.flatten(exec.args).filter(arg => typeof arg === 'string' && arg.startsWith('echo'));
|
||||
|
||||
t.true(commands.includes('echo before:init'));
|
||||
t.true(commands.includes('echo after:afterRelease'));
|
||||
|
||||
t.false(commands.includes('echo after:git:release'));
|
||||
t.false(commands.includes('echo after:github:release'));
|
||||
t.false(commands.includes('echo after:gitlab:release'));
|
||||
t.false(commands.includes('echo after:npm:release'));
|
||||
});
|
||||
|
||||
test.serial('should not run hooks for cancelled release-cycle methods', async t => {
|
||||
const { target } = t.context;
|
||||
const pkgName = path.basename(target);
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.0.0');
|
||||
|
||||
const hooks = getHooks(['version', 'git', 'github', 'gitlab', 'npm']);
|
||||
const inquirer = { prompt: sandbox.stub().callsFake(([options]) => ({ [options.name]: false })) };
|
||||
|
||||
const container = getContainer(
|
||||
{
|
||||
increment: 'minor',
|
||||
hooks,
|
||||
github: { release: true, skipChecks: true },
|
||||
gitlab: { release: true, skipChecks: true },
|
||||
npm: { publish: true, skipChecks: true }
|
||||
},
|
||||
inquirer
|
||||
);
|
||||
|
||||
const exec = sandbox.stub(container.shell, 'execFormattedCommand').callThrough();
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const commands = _.flatten(exec.args).filter(arg => typeof arg === 'string' && arg.startsWith('echo'));
|
||||
|
||||
t.true(commands.includes('echo before:init'));
|
||||
t.true(commands.includes('echo after:afterRelease'));
|
||||
t.true(commands.includes('echo after:git:bump'));
|
||||
t.true(commands.includes('echo after:npm:bump'));
|
||||
|
||||
t.false(commands.includes('echo after:git:release'));
|
||||
t.false(commands.includes('echo after:github:release'));
|
||||
t.false(commands.includes('echo after:gitlab:release'));
|
||||
t.false(commands.includes('echo after:npm:release'));
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should run "after:*:release" plugin hooks', async t => {
|
||||
const { bare, target } = t.context;
|
||||
const project = path.basename(bare);
|
||||
const pkgName = path.basename(target);
|
||||
const owner = path.basename(path.dirname(bare));
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.0.0');
|
||||
const sha = gitAdd('line', 'file', 'More file');
|
||||
|
||||
interceptGitHubCreate({
|
||||
owner,
|
||||
project,
|
||||
body: { tag_name: '1.1.0', name: 'Release 1.1.0', body: `* More file (${sha})` }
|
||||
});
|
||||
|
||||
interceptGitLabPublish({
|
||||
owner,
|
||||
project,
|
||||
body: {
|
||||
name: 'Release 1.1.0',
|
||||
tag_name: '1.1.0',
|
||||
description: `* More file (${sha})`
|
||||
}
|
||||
});
|
||||
|
||||
const hooks = getHooks(['version', 'git', 'github', 'gitlab', 'npm']);
|
||||
|
||||
const container = getContainer({
|
||||
increment: 'minor',
|
||||
hooks,
|
||||
github: { release: true, pushRepo: `https://github.com/${owner}/${project}`, skipChecks: true },
|
||||
gitlab: { release: true, pushRepo: `https://gitlab.com/${owner}/${project}`, skipChecks: true },
|
||||
npm: { name: pkgName, skipChecks: true }
|
||||
});
|
||||
|
||||
const exec = sandbox.spy(container.shell, 'execFormattedCommand');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const commands = _.flatten(exec.args).filter(arg => typeof arg === 'string' && arg.startsWith('echo'));
|
||||
|
||||
t.true(commands.includes('echo after:git:bump'));
|
||||
t.true(commands.includes('echo after:npm:bump'));
|
||||
t.true(commands.includes('echo after:git:release'));
|
||||
t.true(commands.includes('echo after:github:release'));
|
||||
t.true(commands.includes('echo after:gitlab:release'));
|
||||
t.true(commands.includes('echo after:npm:release'));
|
||||
});
|
||||
|
||||
test.serial('should show only version prompt', async t => {
|
||||
const config = { ci: false, 'only-version': true };
|
||||
await runTasks({}, getContainer(config));
|
||||
t.true(defaultInquirer.prompt.calledOnce);
|
||||
t.is(defaultInquirer.prompt.firstCall.args[0][0].name, 'incrementList');
|
||||
});
|
||||
@@ -0,0 +1,162 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { SocksClientOptions, SocksClientChainOptions, SocksRemoteHost, SocksProxy, SocksClientBoundEvent, SocksClientEstablishedEvent, SocksUDPFrameDetails } from '../common/constants';
|
||||
import { SocksClientError } from '../common/util';
|
||||
import { Duplex } from 'stream';
|
||||
declare interface SocksClient {
|
||||
on(event: 'error', listener: (err: SocksClientError) => void): this;
|
||||
on(event: 'bound', listener: (info: SocksClientBoundEvent) => void): this;
|
||||
on(event: 'established', listener: (info: SocksClientEstablishedEvent) => void): this;
|
||||
once(event: string, listener: (...args: unknown[]) => void): this;
|
||||
once(event: 'error', listener: (err: SocksClientError) => void): this;
|
||||
once(event: 'bound', listener: (info: SocksClientBoundEvent) => void): this;
|
||||
once(event: 'established', listener: (info: SocksClientEstablishedEvent) => void): this;
|
||||
emit(event: string | symbol, ...args: unknown[]): boolean;
|
||||
emit(event: 'error', err: SocksClientError): boolean;
|
||||
emit(event: 'bound', info: SocksClientBoundEvent): boolean;
|
||||
emit(event: 'established', info: SocksClientEstablishedEvent): boolean;
|
||||
}
|
||||
declare class SocksClient extends EventEmitter implements SocksClient {
|
||||
private options;
|
||||
private socket;
|
||||
private state;
|
||||
private receiveBuffer;
|
||||
private nextRequiredPacketBufferSize;
|
||||
private socks5ChosenAuthType;
|
||||
private onDataReceived;
|
||||
private onClose;
|
||||
private onError;
|
||||
private onConnect;
|
||||
constructor(options: SocksClientOptions);
|
||||
/**
|
||||
* Creates a new SOCKS connection.
|
||||
*
|
||||
* Note: Supports callbacks and promises. Only supports the connect command.
|
||||
* @param options { SocksClientOptions } Options.
|
||||
* @param callback { Function } An optional callback function.
|
||||
* @returns { Promise }
|
||||
*/
|
||||
static createConnection(options: SocksClientOptions, callback?: (error: Error | null, info?: SocksClientEstablishedEvent) => void): Promise<SocksClientEstablishedEvent>;
|
||||
/**
|
||||
* Creates a new SOCKS connection chain to a destination host through 2 or more SOCKS proxies.
|
||||
*
|
||||
* Note: Supports callbacks and promises. Only supports the connect method.
|
||||
* Note: Implemented via createConnection() factory function.
|
||||
* @param options { SocksClientChainOptions } Options
|
||||
* @param callback { Function } An optional callback function.
|
||||
* @returns { Promise }
|
||||
*/
|
||||
static createConnectionChain(options: SocksClientChainOptions, callback?: (error: Error | null, socket?: SocksClientEstablishedEvent) => void): Promise<SocksClientEstablishedEvent>;
|
||||
/**
|
||||
* Creates a SOCKS UDP Frame.
|
||||
* @param options
|
||||
*/
|
||||
static createUDPFrame(options: SocksUDPFrameDetails): Buffer;
|
||||
/**
|
||||
* Parses a SOCKS UDP frame.
|
||||
* @param data
|
||||
*/
|
||||
static parseUDPFrame(data: Buffer): SocksUDPFrameDetails;
|
||||
/**
|
||||
* Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state.
|
||||
*/
|
||||
private setState;
|
||||
/**
|
||||
* Starts the connection establishment to the proxy and destination.
|
||||
* @param existingSocket Connected socket to use instead of creating a new one (internal use).
|
||||
*/
|
||||
connect(existingSocket?: Duplex): void;
|
||||
private getSocketOptions;
|
||||
/**
|
||||
* Handles internal Socks timeout callback.
|
||||
* Note: If the Socks client is not BoundWaitingForConnection or Established, the connection will be closed.
|
||||
*/
|
||||
private onEstablishedTimeout;
|
||||
/**
|
||||
* Handles Socket connect event.
|
||||
*/
|
||||
private onConnectHandler;
|
||||
/**
|
||||
* Handles Socket data event.
|
||||
* @param data
|
||||
*/
|
||||
private onDataReceivedHandler;
|
||||
/**
|
||||
* Handles processing of the data we have received.
|
||||
*/
|
||||
private processData;
|
||||
/**
|
||||
* Handles Socket close event.
|
||||
* @param had_error
|
||||
*/
|
||||
private onCloseHandler;
|
||||
/**
|
||||
* Handles Socket error event.
|
||||
* @param err
|
||||
*/
|
||||
private onErrorHandler;
|
||||
/**
|
||||
* Removes internal event listeners on the underlying Socket.
|
||||
*/
|
||||
private removeInternalSocketHandlers;
|
||||
/**
|
||||
* Closes and destroys the underlying Socket. Emits an error event.
|
||||
* @param err { String } An error string to include in error event.
|
||||
*/
|
||||
private closeSocket;
|
||||
/**
|
||||
* Sends initial Socks v4 handshake request.
|
||||
*/
|
||||
private sendSocks4InitialHandshake;
|
||||
/**
|
||||
* Handles Socks v4 handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleSocks4FinalHandshakeResponse;
|
||||
/**
|
||||
* Handles Socks v4 incoming connection request (BIND)
|
||||
* @param data
|
||||
*/
|
||||
private handleSocks4IncomingConnectionResponse;
|
||||
/**
|
||||
* Sends initial Socks v5 handshake request.
|
||||
*/
|
||||
private sendSocks5InitialHandshake;
|
||||
/**
|
||||
* Handles initial Socks v5 handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleInitialSocks5HandshakeResponse;
|
||||
/**
|
||||
* Sends Socks v5 user & password auth handshake.
|
||||
*
|
||||
* Note: No auth and user/pass are currently supported.
|
||||
*/
|
||||
private sendSocks5UserPassAuthentication;
|
||||
private sendSocks5CustomAuthentication;
|
||||
private handleSocks5CustomAuthHandshakeResponse;
|
||||
private handleSocks5AuthenticationNoAuthHandshakeResponse;
|
||||
private handleSocks5AuthenticationUserPassHandshakeResponse;
|
||||
/**
|
||||
* Handles Socks v5 auth handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleInitialSocks5AuthenticationHandshakeResponse;
|
||||
/**
|
||||
* Sends Socks v5 final handshake request.
|
||||
*/
|
||||
private sendSocks5CommandRequest;
|
||||
/**
|
||||
* Handles Socks v5 final handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleSocks5FinalHandshakeResponse;
|
||||
/**
|
||||
* Handles Socks v5 incoming connection request (BIND).
|
||||
*/
|
||||
private handleSocks5IncomingConnectionResponse;
|
||||
get socksClientOptions(): SocksClientOptions;
|
||||
}
|
||||
export { SocksClient, SocksClientOptions, SocksClientChainOptions, SocksClientError, SocksRemoteHost, SocksProxy, SocksUDPFrameDetails, };
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
|
||||
var ToIntegerOrInfinity = require('./ToIntegerOrInfinity');
|
||||
var ToLength = require('./ToLength');
|
||||
var SameValue = require('./SameValue');
|
||||
|
||||
// https://262.ecma-international.org/8.0/#sec-toindex
|
||||
|
||||
module.exports = function ToIndex(value) {
|
||||
if (typeof value === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
var integerIndex = ToIntegerOrInfinity(value);
|
||||
if (integerIndex < 0) {
|
||||
throw new $RangeError('index must be >= 0');
|
||||
}
|
||||
var index = ToLength(integerIndex);
|
||||
if (!SameValue(integerIndex, index)) {
|
||||
throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1');
|
||||
}
|
||||
return index;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00429,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00429,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0.00859,"88":0.00429,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.00859,"103":0,"104":0,"105":0,"106":0,"107":0.00429,"108":0.00859,"109":0.39075,"110":0.2147,"111":0,"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,"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.00859,"48":0,"49":0.00859,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00429,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0.00429,"66":0,"67":0.00429,"68":0.00429,"69":0,"70":0.00859,"71":0,"72":0,"73":0,"74":0.02147,"75":0.01718,"76":0.00859,"77":0.00429,"78":0.00429,"79":0.09017,"80":0.00429,"81":0.03865,"83":0.00859,"84":0.00429,"85":0.00429,"86":0.00429,"87":0.01718,"88":0.00429,"89":0.00429,"90":0.00429,"91":0.00859,"92":0.00859,"93":0.03006,"94":0.00429,"95":0.01718,"96":0.00429,"97":0.00429,"98":0.01718,"99":0.03435,"100":0.00859,"101":0.01288,"102":0.01288,"103":0.24476,"104":0.01288,"105":0.01718,"106":0.04294,"107":0.03865,"108":0.45087,"109":6.06313,"110":3.99342,"111":0.00429,"112":0.00429,"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.01288,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0.00859,"64":0,"65":0,"66":0,"67":0.00859,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.01718,"94":0.25335,"95":0.12453,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0.00429,"16":0,"17":0,"18":0.00429,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00429,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0.00429,"107":0.11594,"108":0.02576,"109":1.21091,"110":1.24955},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.00859,"15":0.00859,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0.00859,"10.1":0,"11.1":0,"12.1":0.00429,"13.1":0.0687,"14.1":0.06012,"15.1":0.00429,"15.2-15.3":0.00429,"15.4":0.02147,"15.5":0.03435,"15.6":0.24476,"16.0":0.03865,"16.1":0.09876,"16.2":0.32205,"16.3":0.15888,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.0117,"6.0-6.1":0,"7.0-7.1":0.06241,"8.1-8.4":0,"9.0-9.2":0.00585,"9.3":0.15018,"10.0-10.2":0,"10.3":0.11703,"11.0-11.2":0.0078,"11.3-11.4":0.00195,"12.0-12.1":0.0156,"12.2-12.5":0.44079,"13.0-13.1":0.0039,"13.2":0,"13.3":0.0156,"13.4-13.7":0.07022,"14.0-14.4":0.16188,"14.5-14.8":0.34327,"15.0-15.1":0.04876,"15.2-15.3":0.13263,"15.4":0.29451,"15.5":0.36863,"15.6":1.67346,"16.0":2.36391,"16.1":3.69019,"16.2":4.79412,"16.3":2.84956,"16.4":0.0117},P:{"4":0.3512,"20":1.77728,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.30863,"8.2":0,"9.2":0.01064,"10.1":0,"11.1-11.2":0.05321,"12.0":0,"13.0":0.04257,"14.0":0.02128,"15.0":0.01064,"16.0":0.04257,"17.0":0.12771,"18.0":0.11707,"19.0":2.6606},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.05336,"4.2-4.3":0.33348,"4.4":0,"4.4.3-4.4.4":0.65361},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0.00859,"11":0.01288,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.03994},H:{"0":0.2485},L:{"0":56.50369},R:{_:"0"},M:{"0":0.16547},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,43 @@
|
||||
var createAggregator = require('./_createAggregator');
|
||||
|
||||
/**
|
||||
* Creates an array of elements split into two groups, the first of which
|
||||
* contains elements `predicate` returns truthy for, the second of which
|
||||
* contains elements `predicate` returns falsey for. The predicate is
|
||||
* invoked with one argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Collection
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||||
* @returns {Array} Returns the array of grouped elements.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'age': 36, 'active': false },
|
||||
* { 'user': 'fred', 'age': 40, 'active': true },
|
||||
* { 'user': 'pebbles', 'age': 1, 'active': false }
|
||||
* ];
|
||||
*
|
||||
* _.partition(users, function(o) { return o.active; });
|
||||
* // => objects for [['fred'], ['barney', 'pebbles']]
|
||||
*
|
||||
* // The `_.matches` iteratee shorthand.
|
||||
* _.partition(users, { 'age': 1, 'active': false });
|
||||
* // => objects for [['pebbles'], ['barney', 'fred']]
|
||||
*
|
||||
* // The `_.matchesProperty` iteratee shorthand.
|
||||
* _.partition(users, ['active', false]);
|
||||
* // => objects for [['barney', 'pebbles'], ['fred']]
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.partition(users, 'active');
|
||||
* // => objects for [['fred'], ['barney', 'pebbles']]
|
||||
*/
|
||||
var partition = createAggregator(function(result, value, key) {
|
||||
result[key ? 0 : 1].push(value);
|
||||
}, function() { return [[], []]; });
|
||||
|
||||
module.exports = partition;
|
||||
@@ -0,0 +1,128 @@
|
||||
# frac
|
||||
|
||||
Rational approximation to a floating point number with bounded denominator.
|
||||
|
||||
Uses the [Mediant Method](https://en.wikipedia.org/wiki/Mediant_method).
|
||||
|
||||
This module also provides an implementation of the continued fraction method as
|
||||
described by Aberth in "A method for exact computation with rational numbers".
|
||||
The algorithm is used in <a href="http://sheetjs.com">SheetJS Libraries</a> to
|
||||
replicate fraction formats.
|
||||
|
||||
## Installation
|
||||
|
||||
### JS
|
||||
|
||||
With [`npm`](https://www.npmjs.org/package/frac):
|
||||
|
||||
```bash
|
||||
$ npm install frac
|
||||
```
|
||||
|
||||
In the browser:
|
||||
|
||||
```html
|
||||
<script src="frac.js"></script>
|
||||
```
|
||||
|
||||
The script will manipulate `module.exports` if available . This is not always
|
||||
desirable. To prevent the behavior, define `DO_NOT_EXPORT_FRAC`
|
||||
|
||||
### Python
|
||||
|
||||
From [`PyPI`](https://pypi.python.org/pypi/frac):
|
||||
|
||||
```bash
|
||||
$ pip install frac
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
In all cases, the relevant function takes 3 arguments:
|
||||
|
||||
- `x` the number we wish to approximate
|
||||
- `D` the maximum denominator
|
||||
- `mixed` if true, return a mixed fraction; if false, improper
|
||||
|
||||
The return value is an array of the form `[quot, num, den]` where `quot==0`
|
||||
for improper fractions. `quot <= x` for mixed fractions, which may lead to some
|
||||
unexpected results when rendering negative numbers.
|
||||
|
||||
### JS
|
||||
|
||||
The exported `frac` function implements the Mediant method.
|
||||
|
||||
`frac.cont` implements the Aberth algorithm
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
> // var frac = require('frac'); // uncomment this line if in node
|
||||
> frac(1.3, 9); // [ 0, 9, 7 ] // 1.3 ~ 9/7
|
||||
> frac(1.3, 9, true); // [ 1, 2, 7 ] // 1.3 ~ 1 + 2/7
|
||||
> frac(-1.3, 9); // [ 0, -9, 7 ] // -1.3 ~ -9/7
|
||||
> frac(-1.3, 9, true); // [ -2, 5, 7 ] // -1.3 ~ -2 + 5/7
|
||||
|
||||
> frac.cont(1.3, 9); // [ 0, 4, 3 ] // 1.3 ~ 4/3
|
||||
> frac.cont(1.3, 9, true); // [ 1, 1, 3 ] // 1.3 ~ 1 + 1/3
|
||||
> frac.cont(-1.3, 9); // [ 0, -4, 3 ] // -1.3 ~ -4/3
|
||||
> frac.cont(-1.3, 9, true); // [ -2, 2, 3 ] // -1.3 ~ -2 + 2/3
|
||||
```
|
||||
|
||||
|
||||
### Python
|
||||
|
||||
`frac.med` implements Mediant method.
|
||||
|
||||
`frac.cont` implements Aberth algorithm.
|
||||
|
||||
For example:
|
||||
|
||||
```py
|
||||
>>> import frac
|
||||
>>> frac.med(1.3, 9) ## [ 0, 9, 7 ] ## 1.3 ~ 9/7
|
||||
>>> frac.med(1.3, 9, True) ## [ 1, 2, 7 ] ## 1.3 ~ 1 + 2/7
|
||||
>>> frac.med(-1.3, 9) ## [ 0, -9, 7 ] ## -1.3 ~ -9/7
|
||||
>>> frac.med(-1.3, 9, True) ## [ -2, 5, 7 ] ## -1.3 ~ -2 + 5/7
|
||||
|
||||
>>> frac.cont(1.3, 9) ## [ 0, 4, 3 ] ## 1.3 ~ 4/3
|
||||
>>> frac.cont(1.3, 9, True) ## [ 1, 1, 3 ] ## 1.3 ~ 1 + 1/3
|
||||
>>> frac.cont(-1.3, 9) ## [ 0, -4, 3 ] ## -1.3 ~ -4/3
|
||||
>>> frac.cont(-1.3, 9, True) ## [ -2, 2, 3 ] ## -1.3 ~ -2 + 2/3
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
The test TSV baselines in the `test_files` directory have four columns:
|
||||
|
||||
- Column A contains the raw values
|
||||
- Column B format "Up to one digit (1/4)" (`denominator = 9`)
|
||||
- Column C format "Up to two digits (21/25)" (`denominator = 99`)
|
||||
- Column D format "Up to three digits (312/943)" (`denominator = 999`)
|
||||
|
||||
`make test` will run the node-based tests.
|
||||
|
||||
`make pytest` will run the python tests against the system Python version.
|
||||
|
||||
`make pypytest` will run the python tests against `pypy` if installed
|
||||
|
||||
## License
|
||||
|
||||
Please consult the attached LICENSE file for details. All rights not explicitly
|
||||
granted by the Apache 2.0 License are reserved by the Original Author.
|
||||
|
||||
## Badges
|
||||
|
||||
[](https://saucelabs.com/u/frac)
|
||||
|
||||
[](https://travis-ci.org/SheetJS/frac)
|
||||
|
||||
[](https://coveralls.io/r/SheetJS/frac?branch=master)
|
||||
|
||||
[](https://npmjs.org/package/frac)
|
||||
|
||||
[](https://david-dm.org/sheetjs/frac)
|
||||
|
||||
[](https://ghit.me/repo/sheetjs/js-xlsx)
|
||||
|
||||
[](https://github.com/SheetJS/frac)
|
||||
@@ -0,0 +1,18 @@
|
||||
var baseGet = require('./_baseGet'),
|
||||
baseSet = require('./_baseSet');
|
||||
|
||||
/**
|
||||
* The base implementation of `_.update`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to update.
|
||||
* @param {Function} updater The function to produce the updated value.
|
||||
* @param {Function} [customizer] The function to customize path creation.
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseUpdate(object, path, updater, customizer) {
|
||||
return baseSet(object, path, updater(baseGet(object, path)), customizer);
|
||||
}
|
||||
|
||||
module.exports = baseUpdate;
|
||||
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $gOPD = require('gopd');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
||||
|
||||
var has = require('has');
|
||||
|
||||
var IsArray = require('./IsArray');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var IsRegExp = require('./IsRegExp');
|
||||
var ToPropertyDescriptor = require('./ToPropertyDescriptor');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty
|
||||
|
||||
module.exports = function OrdinaryGetOwnProperty(O, P) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: O must be an Object');
|
||||
}
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: P must be a Property Key');
|
||||
}
|
||||
if (!has(O, P)) {
|
||||
return void 0;
|
||||
}
|
||||
if (!$gOPD) {
|
||||
// ES3 / IE 8 fallback
|
||||
var arrayLength = IsArray(O) && P === 'length';
|
||||
var regexLastIndex = IsRegExp(O) && P === 'lastIndex';
|
||||
return {
|
||||
'[[Configurable]]': !(arrayLength || regexLastIndex),
|
||||
'[[Enumerable]]': $isEnumerable(O, P),
|
||||
'[[Value]]': O[P],
|
||||
'[[Writable]]': true
|
||||
};
|
||||
}
|
||||
return ToPropertyDescriptor($gOPD(O, P));
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
var apply = require('./_apply'),
|
||||
baseRest = require('./_baseRest'),
|
||||
isError = require('./isError');
|
||||
|
||||
/**
|
||||
* Attempts to invoke `func`, returning either the result or the caught error
|
||||
* object. Any additional arguments are provided to `func` when it's invoked.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Util
|
||||
* @param {Function} func The function to attempt.
|
||||
* @param {...*} [args] The arguments to invoke `func` with.
|
||||
* @returns {*} Returns the `func` result or error object.
|
||||
* @example
|
||||
*
|
||||
* // Avoid throwing errors for invalid selectors.
|
||||
* var elements = _.attempt(function(selector) {
|
||||
* return document.querySelectorAll(selector);
|
||||
* }, '>_>');
|
||||
*
|
||||
* if (_.isError(elements)) {
|
||||
* elements = [];
|
||||
* }
|
||||
*/
|
||||
var attempt = baseRest(function(func, args) {
|
||||
try {
|
||||
return apply(func, undefined, args);
|
||||
} catch (e) {
|
||||
return isError(e) ? e : new Error(e);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = attempt;
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('chunk', require('../chunk'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AnyCatcher.d.ts","sourceRoot":"","sources":["../../../src/internal/AnyCatcher.ts"],"names":[],"mappings":"AAKA,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,MAAM,CAAC;AAE9C;;;;;GAKG;AACH,oBAAY,UAAU,GAAG,OAAO,gBAAgB,CAAC"}
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
var old;
|
||||
if (typeof Promise !== "undefined") old = Promise;
|
||||
function noConflict() {
|
||||
try { if (Promise === bluebird) Promise = old; }
|
||||
catch (e) {}
|
||||
return bluebird;
|
||||
}
|
||||
var bluebird = require("./promise")();
|
||||
bluebird.noConflict = noConflict;
|
||||
module.exports = bluebird;
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"strip-indent","version":"3.0.0","files":{"license":{"checkedAt":1678883669272,"integrity":"sha512-nIst73auX/5NY2Fmv5Y116vWnNrEv4GaIUX3lpZG05rpXJY2S8EX+fpUS5hRjClCM0VdT2Za9DDHXXB5jdSrEw==","mode":420,"size":1109},"package.json":{"checkedAt":1678883672841,"integrity":"sha512-nDQu61gPc7ZHLwnV8m1CGSUyhippFk5Go1fFiaywzSID4jvz6siZ0dzrbuv56lsfn2eL1NE2vlDRYTE/07QVtA==","mode":420,"size":693},"index.js":{"checkedAt":1678883672841,"integrity":"sha512-0uz7NuC1iRKpCAbIAgHlMyn50vD4fQx4icC5TaBb/EFIVrSUZsGpo3uV25oip0xRjMTbDDuST6YHFVX+rt4UfA==","mode":420,"size":257},"readme.md":{"checkedAt":1678883672842,"integrity":"sha512-FaXQBUDgfWl8lqMXezRYtkmR6G61V0byHY+D+KYMukiLSBqM2Cx9PnFykrN2LtL48Xakr+lhIcxvs2R75zKakQ==","mode":420,"size":843},"index.d.ts":{"checkedAt":1678883672842,"integrity":"sha512-u18QT+7UUW96x2vznVQY5fdn81fn54kwTEgM3PJIcztmZ0SOqr3nZI2EzOU0LdxGi8fRW24yU1J3jMUHDDmZBA==","mode":420,"size":410}}}
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jordan Harband
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schedulePromise.d.ts","sourceRoot":"","sources":["../../../../src/internal/scheduled/schedulePromise.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,yCAEjF"}
|
||||
@@ -0,0 +1,38 @@
|
||||
var acorn = require('acorn')
|
||||
var xtend = require('xtend')
|
||||
|
||||
var CJSParser = acorn.Parser
|
||||
.extend(require('./lib/bigint'))
|
||||
.extend(require('./lib/class-fields'))
|
||||
.extend(require('./lib/static-class-features'))
|
||||
.extend(require('./lib/numeric-separator'))
|
||||
.extend(require('./lib/dynamic-import').default)
|
||||
var ESModulesParser = CJSParser
|
||||
.extend(require('./lib/export-ns-from'))
|
||||
.extend(require('./lib/import-meta'))
|
||||
|
||||
function mapOptions (opts) {
|
||||
if (!opts) opts = {}
|
||||
return xtend({
|
||||
ecmaVersion: 2020,
|
||||
allowHashBang: true,
|
||||
allowReturnOutsideFunction: true
|
||||
}, opts)
|
||||
}
|
||||
|
||||
function getParser (opts) {
|
||||
if (!opts) opts = {}
|
||||
return opts.sourceType === 'module' ? ESModulesParser : CJSParser
|
||||
}
|
||||
|
||||
module.exports = exports = xtend(acorn, {
|
||||
parse: function parse (src, opts) {
|
||||
return getParser(opts).parse(src, mapOptions(opts))
|
||||
},
|
||||
parseExpressionAt: function parseExpressionAt (src, offset, opts) {
|
||||
return getParser(opts).parseExpressionAt(src, offset, mapOptions(opts))
|
||||
},
|
||||
tokenizer: function tokenizer (src, opts) {
|
||||
return getParser(opts).tokenizer(src, mapOptions(opts))
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('merge', require('../merge'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { EMPTY } from '../observable/empty';
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function takeLast(count) {
|
||||
return count <= 0
|
||||
? () => EMPTY
|
||||
: operate((source, subscriber) => {
|
||||
let buffer = [];
|
||||
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
|
||||
buffer.push(value);
|
||||
count < buffer.length && buffer.shift();
|
||||
}, () => {
|
||||
for (const value of buffer) {
|
||||
subscriber.next(value);
|
||||
}
|
||||
subscriber.complete();
|
||||
}, undefined, () => {
|
||||
buffer = null;
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=takeLast.js.map
|
||||
@@ -0,0 +1,43 @@
|
||||
var baseClamp = require('./_baseClamp'),
|
||||
baseToString = require('./_baseToString'),
|
||||
toInteger = require('./toInteger'),
|
||||
toString = require('./toString');
|
||||
|
||||
/**
|
||||
* Checks if `string` ends with the given target string.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to inspect.
|
||||
* @param {string} [target] The string to search for.
|
||||
* @param {number} [position=string.length] The position to search up to.
|
||||
* @returns {boolean} Returns `true` if `string` ends with `target`,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.endsWith('abc', 'c');
|
||||
* // => true
|
||||
*
|
||||
* _.endsWith('abc', 'b');
|
||||
* // => false
|
||||
*
|
||||
* _.endsWith('abc', 'b', 2);
|
||||
* // => true
|
||||
*/
|
||||
function endsWith(string, target, position) {
|
||||
string = toString(string);
|
||||
target = baseToString(target);
|
||||
|
||||
var length = string.length;
|
||||
position = position === undefined
|
||||
? length
|
||||
: baseClamp(toInteger(position), 0, length);
|
||||
|
||||
var end = position;
|
||||
position -= target.length;
|
||||
return position >= 0 && string.slice(position, end) == target;
|
||||
}
|
||||
|
||||
module.exports = endsWith;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./overSome');
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-localematcher/abstract/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,QAA4B,CAAA;AAEzE,wBAAgB,SAAS,CACvB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,GAAW,GACf,OAAO,CAAC,SAAS,CAInB"}
|
||||
@@ -0,0 +1,49 @@
|
||||
module.exports = {
|
||||
'assign': require('./assign'),
|
||||
'assignIn': require('./assignIn'),
|
||||
'assignInWith': require('./assignInWith'),
|
||||
'assignWith': require('./assignWith'),
|
||||
'at': require('./at'),
|
||||
'create': require('./create'),
|
||||
'defaults': require('./defaults'),
|
||||
'defaultsDeep': require('./defaultsDeep'),
|
||||
'entries': require('./entries'),
|
||||
'entriesIn': require('./entriesIn'),
|
||||
'extend': require('./extend'),
|
||||
'extendWith': require('./extendWith'),
|
||||
'findKey': require('./findKey'),
|
||||
'findLastKey': require('./findLastKey'),
|
||||
'forIn': require('./forIn'),
|
||||
'forInRight': require('./forInRight'),
|
||||
'forOwn': require('./forOwn'),
|
||||
'forOwnRight': require('./forOwnRight'),
|
||||
'functions': require('./functions'),
|
||||
'functionsIn': require('./functionsIn'),
|
||||
'get': require('./get'),
|
||||
'has': require('./has'),
|
||||
'hasIn': require('./hasIn'),
|
||||
'invert': require('./invert'),
|
||||
'invertBy': require('./invertBy'),
|
||||
'invoke': require('./invoke'),
|
||||
'keys': require('./keys'),
|
||||
'keysIn': require('./keysIn'),
|
||||
'mapKeys': require('./mapKeys'),
|
||||
'mapValues': require('./mapValues'),
|
||||
'merge': require('./merge'),
|
||||
'mergeWith': require('./mergeWith'),
|
||||
'omit': require('./omit'),
|
||||
'omitBy': require('./omitBy'),
|
||||
'pick': require('./pick'),
|
||||
'pickBy': require('./pickBy'),
|
||||
'result': require('./result'),
|
||||
'set': require('./set'),
|
||||
'setWith': require('./setWith'),
|
||||
'toPairs': require('./toPairs'),
|
||||
'toPairsIn': require('./toPairsIn'),
|
||||
'transform': require('./transform'),
|
||||
'unset': require('./unset'),
|
||||
'update': require('./update'),
|
||||
'updateWith': require('./updateWith'),
|
||||
'values': require('./values'),
|
||||
'valuesIn': require('./valuesIn')
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export default ["preflight","container","accessibility","pointerEvents","visibility","position","inset","isolation","zIndex","order","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","float","clear","margin","boxSizing","display","aspectRatio","height","maxHeight","minHeight","width","minWidth","maxWidth","flex","flexShrink","flexGrow","flexBasis","tableLayout","borderCollapse","borderSpacing","transformOrigin","translate","rotate","skew","scale","transform","animation","cursor","touchAction","userSelect","resize","scrollSnapType","scrollSnapAlign","scrollSnapStop","scrollMargin","scrollPadding","listStylePosition","listStyleType","appearance","columns","breakBefore","breakInside","breakAfter","gridAutoColumns","gridAutoFlow","gridAutoRows","gridTemplateColumns","gridTemplateRows","flexDirection","flexWrap","placeContent","placeItems","alignContent","alignItems","justifyContent","justifyItems","gap","space","divideWidth","divideStyle","divideColor","divideOpacity","placeSelf","alignSelf","justifySelf","overflow","overscrollBehavior","scrollBehavior","textOverflow","whitespace","wordBreak","borderRadius","borderWidth","borderStyle","borderColor","borderOpacity","backgroundColor","backgroundOpacity","backgroundImage","gradientColorStops","boxDecorationBreak","backgroundSize","backgroundAttachment","backgroundClip","backgroundPosition","backgroundRepeat","backgroundOrigin","fill","stroke","strokeWidth","objectFit","objectPosition","padding","textAlign","textIndent","verticalAlign","fontFamily","fontSize","fontWeight","textTransform","fontStyle","fontVariantNumeric","lineHeight","letterSpacing","textColor","textOpacity","textDecoration","textDecorationColor","textDecorationStyle","textDecorationThickness","textUnderlineOffset","fontSmoothing","placeholderColor","placeholderOpacity","caretColor","accentColor","opacity","backgroundBlendMode","mixBlendMode","boxShadow","boxShadowColor","outlineStyle","outlineWidth","outlineOffset","outlineColor","ringWidth","ringColor","ringOpacity","ringOffsetWidth","ringOffsetColor","blur","brightness","contrast","dropShadow","grayscale","hueRotate","invert","saturate","sepia","filter","backdropBlur","backdropBrightness","backdropContrast","backdropGrayscale","backdropHueRotate","backdropInvert","backdropOpacity","backdropSaturate","backdropSepia","backdropFilter","transitionProperty","transitionDelay","transitionDuration","transitionTimingFunction","willChange","content"]
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var isSticky = require("../is-sticky");
|
||||
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(RegExp.prototype, "sticky", {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
get: isSticky
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"innerFrom.js","sourceRoot":"","sources":["../../../../src/internal/observable/innerFrom.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAExG,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,UAAU,SAAS,CAAI,KAAyB;IACpD,IAAI,KAAK,YAAY,UAAU,EAAE;QAC/B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;YAC9B,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;YACtB,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACpB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;SAC3B;QACD,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;SACjC;QACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;YACrB,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;SAC5B;QACD,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE;YAC/B,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;SACtC;KACF;IAED,MAAM,gCAAgC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAMD,MAAM,UAAU,qBAAqB,CAAI,GAAQ;IAC/C,OAAO,IAAI,UAAU,CAAC,CAAC,UAAyB,EAAE,EAAE;QAClD,MAAM,GAAG,GAAG,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;SAClC;QAED,MAAM,IAAI,SAAS,CAAC,gEAAgE,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC;AASD,MAAM,UAAU,aAAa,CAAI,KAAmB;IAClD,OAAO,IAAI,UAAU,CAAC,CAAC,UAAyB,EAAE,EAAE;QAUlD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3D,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;QACD,UAAU,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,OAAuB;IACpD,OAAO,IAAI,UAAU,CAAC,CAAC,UAAyB,EAAE,EAAE;QAClD,OAAO;aACJ,IAAI,CACH,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBACtB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvB;QACH,CAAC,EACD,CAAC,GAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CACpC;aACA,IAAI,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,QAAqB;IACnD,OAAO,IAAI,UAAU,CAAC,CAAC,UAAyB,EAAE,EAAE;QAClD,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;YAC5B,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,IAAI,UAAU,CAAC,MAAM,EAAE;gBACrB,OAAO;aACR;SACF;QACD,UAAU,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,aAA+B;IAClE,OAAO,IAAI,UAAU,CAAC,CAAC,UAAyB,EAAE,EAAE;QAClD,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAI,cAAqC;IAC7E,OAAO,iBAAiB,CAAC,kCAAkC,CAAC,cAAc,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAe,OAAO,CAAI,aAA+B,EAAE,UAAyB;;;;;YAClF,KAA0B,kBAAA,cAAA,aAAa,CAAA;gBAA5B,MAAM,KAAK,0BAAA,CAAA;gBACpB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAGvB,IAAI,UAAU,CAAC,MAAM,EAAE;oBACrB,OAAO;iBACR;aACF;;;;;;;;;QACD,UAAU,CAAC,QAAQ,EAAE,CAAC;;CACvB"}
|
||||
@@ -0,0 +1,21 @@
|
||||
var baseEach = require('./_baseEach');
|
||||
|
||||
/**
|
||||
* The base implementation of `_.filter` without support for iteratee shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {Array} Returns the new filtered array.
|
||||
*/
|
||||
function baseFilter(collection, predicate) {
|
||||
var result = [];
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
if (predicate(value, index, collection)) {
|
||||
result.push(value);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = baseFilter;
|
||||
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL, debug) {
|
||||
var util = require("./util");
|
||||
var TimeoutError = Promise.TimeoutError;
|
||||
|
||||
function HandleWrapper(handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
HandleWrapper.prototype._resultCancelled = function() {
|
||||
clearTimeout(this.handle);
|
||||
};
|
||||
|
||||
var afterValue = function(value) { return delay(+this).thenReturn(value); };
|
||||
var delay = Promise.delay = function (ms, value) {
|
||||
var ret;
|
||||
var handle;
|
||||
if (value !== undefined) {
|
||||
ret = Promise.resolve(value)
|
||||
._then(afterValue, null, null, ms, undefined);
|
||||
if (debug.cancellation() && value instanceof Promise) {
|
||||
ret._setOnCancel(value);
|
||||
}
|
||||
} else {
|
||||
ret = new Promise(INTERNAL);
|
||||
handle = setTimeout(function() { ret._fulfill(); }, +ms);
|
||||
if (debug.cancellation()) {
|
||||
ret._setOnCancel(new HandleWrapper(handle));
|
||||
}
|
||||
ret._captureStackTrace();
|
||||
}
|
||||
ret._setAsyncGuaranteed();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype.delay = function (ms) {
|
||||
return delay(ms, this);
|
||||
};
|
||||
|
||||
var afterTimeout = function (promise, message, parent) {
|
||||
var err;
|
||||
if (typeof message !== "string") {
|
||||
if (message instanceof Error) {
|
||||
err = message;
|
||||
} else {
|
||||
err = new TimeoutError("operation timed out");
|
||||
}
|
||||
} else {
|
||||
err = new TimeoutError(message);
|
||||
}
|
||||
util.markAsOriginatingFromRejection(err);
|
||||
promise._attachExtraTrace(err);
|
||||
promise._reject(err);
|
||||
|
||||
if (parent != null) {
|
||||
parent.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
function successClear(value) {
|
||||
clearTimeout(this.handle);
|
||||
return value;
|
||||
}
|
||||
|
||||
function failureClear(reason) {
|
||||
clearTimeout(this.handle);
|
||||
throw reason;
|
||||
}
|
||||
|
||||
Promise.prototype.timeout = function (ms, message) {
|
||||
ms = +ms;
|
||||
var ret, parent;
|
||||
|
||||
var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() {
|
||||
if (ret.isPending()) {
|
||||
afterTimeout(ret, message, parent);
|
||||
}
|
||||
}, ms));
|
||||
|
||||
if (debug.cancellation()) {
|
||||
parent = this.then();
|
||||
ret = parent._then(successClear, failureClear,
|
||||
undefined, handleWrapper, undefined);
|
||||
ret._setOnCancel(handleWrapper);
|
||||
} else {
|
||||
ret = this._then(successClear, failureClear,
|
||||
undefined, handleWrapper, undefined);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
import { __values } from "tslib";
|
||||
import { EMPTY } from '../observable/empty';
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function takeLast(count) {
|
||||
return count <= 0
|
||||
? function () { return EMPTY; }
|
||||
: operate(function (source, subscriber) {
|
||||
var buffer = [];
|
||||
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
||||
buffer.push(value);
|
||||
count < buffer.length && buffer.shift();
|
||||
}, function () {
|
||||
var e_1, _a;
|
||||
try {
|
||||
for (var buffer_1 = __values(buffer), buffer_1_1 = buffer_1.next(); !buffer_1_1.done; buffer_1_1 = buffer_1.next()) {
|
||||
var value = buffer_1_1.value;
|
||||
subscriber.next(value);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (buffer_1_1 && !buffer_1_1.done && (_a = buffer_1.return)) _a.call(buffer_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
subscriber.complete();
|
||||
}, undefined, function () {
|
||||
buffer = null;
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=takeLast.js.map
|
||||
Reference in New Issue
Block a user