new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/libs/core/workerMgr.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</a> workerMgr.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/79</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/18</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/18</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>0/79</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></td><td class="line-coverage quiet"><span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span></td><td class="text"><pre class="prettyprint lang-js">Unable to lookup source: /Users/kxiang/work/projects/csv2json/libs/core/workerMgr.js(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/libs/core/workerMgr.js')
|
||||
Error: Unable to lookup source: /Users/kxiang/work/projects/csv2json/libs/core/workerMgr.js(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/libs/core/workerMgr.js')
|
||||
at Context.defaultSourceLookup [as sourceFinder] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:15:15)
|
||||
at Context.getSource (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:74:17)
|
||||
at Object.annotateSourceCode (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/annotator.js:172:38)
|
||||
at HtmlReport.onDetail (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/index.js:237:39)
|
||||
at Visitor.(anonymous function) [as onDetail] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:34:30)
|
||||
at ReportNode.Node.visit (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:123:17)
|
||||
at /Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:116:23
|
||||
at Array.forEach (native)
|
||||
at visitChildren (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:115:32)
|
||||
at ReportNode.Node.visit (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:126:5)</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri May 11 2018 21:36:07 GMT+0100 (IST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../../sorter.js"></script>
|
||||
<script src="../../../block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $String = GetIntrinsic('%String%');
|
||||
|
||||
var ToPrimitive = require('./ToPrimitive');
|
||||
var ToString = require('./ToString');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-topropertykey
|
||||
|
||||
module.exports = function ToPropertyKey(argument) {
|
||||
var key = ToPrimitive(argument, $String);
|
||||
return typeof key === 'symbol' ? key : ToString(key);
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scheduleIterable.js","sourceRoot":"","sources":["../../../../src/internal/scheduled/scheduleIterable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAO1D,MAAM,UAAU,gBAAgB,CAAI,KAAkB,EAAE,SAAwB;IAC9E,OAAO,IAAI,UAAU,CAAI,CAAC,UAAU,EAAE,EAAE;QACtC,IAAI,QAAwB,CAAC;QAK7B,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE;YAE1C,QAAQ,GAAI,KAAa,CAAC,eAAe,CAAC,EAAE,CAAC;YAE7C,eAAe,CACb,UAAU,EACV,SAAS,EACT,GAAG,EAAE;gBACH,IAAI,KAAQ,CAAC;gBACb,IAAI,IAAyB,CAAC;gBAC9B,IAAI;oBAEF,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;iBACrC;gBAAC,OAAO,GAAG,EAAE;oBAEZ,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACtB,OAAO;iBACR;gBAED,IAAI,IAAI,EAAE;oBAKR,UAAU,CAAC,QAAQ,EAAE,CAAC;iBACvB;qBAAM;oBAEL,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACxB;YACH,CAAC,EACD,CAAC,EACD,IAAI,CACL,CAAC;QACJ,CAAC,CAAC,CAAC;QAMH,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "strip-bom",
|
||||
"version": "2.0.0",
|
||||
"description": "Strip UTF-8 byte order mark (BOM) from a string/buffer",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/strip-bom",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"bom",
|
||||
"strip",
|
||||
"byte",
|
||||
"mark",
|
||||
"unicode",
|
||||
"utf8",
|
||||
"utf-8",
|
||||
"remove",
|
||||
"delete",
|
||||
"trim",
|
||||
"text",
|
||||
"buffer",
|
||||
"string"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-utf8": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"has-flag","version":"4.0.0","files":{"license":{"checkedAt":1678883669272,"integrity":"sha512-nIst73auX/5NY2Fmv5Y116vWnNrEv4GaIUX3lpZG05rpXJY2S8EX+fpUS5hRjClCM0VdT2Za9DDHXXB5jdSrEw==","mode":420,"size":1109},"package.json":{"checkedAt":1678883669472,"integrity":"sha512-/TELmRloOCqI8M0EkO5tsiwhmaATO2kmly7mIOG2LqRWBqEMgtDCwDZ+cy8mHZ8m97v8rnHW5yyA2Sc3Bsr+wQ==","mode":420,"size":696},"index.js":{"checkedAt":1678883669472,"integrity":"sha512-F0tdfsQQj5Kb/igBJQPvUKVugjo92BM9WLn1+hiHDQ+LiQ7bmrTWVOJ89s9lmgn/SwBe4e31v+GvvInye8TiwA==","mode":420,"size":330},"index.d.ts":{"checkedAt":1678883669472,"integrity":"sha512-ABvTGLTw6BbJ3tKAkdJWrn/307Dp/zsmI3Y3eFfggB5TtZ0+pDTC4DLNdG7RNcZVsUecr+XkRzx/uyJK429K6A==","mode":420,"size":684},"readme.md":{"checkedAt":1678883669472,"integrity":"sha512-AN63OKtj0IHTIDR1suGAggSkyEBVpH3uxCaGolTwVukTtnT5NCHSnREPOPRM7GjaxxGlzDSwsjUzgbFtn9gEXQ==","mode":420,"size":1600}}}
|
||||
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/has-symbols
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -0,0 +1,17 @@
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function every(predicate, thisArg) {
|
||||
return operate(function (source, subscriber) {
|
||||
var index = 0;
|
||||
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
||||
if (!predicate.call(thisArg, value, index++, source)) {
|
||||
subscriber.next(false);
|
||||
subscriber.complete();
|
||||
}
|
||||
}, function () {
|
||||
subscriber.next(true);
|
||||
subscriber.complete();
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=every.js.map
|
||||
@@ -0,0 +1,59 @@
|
||||
export interface Options {
|
||||
/**
|
||||
Throw an error when called more than once.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly throw?: boolean;
|
||||
}
|
||||
|
||||
declare const onetime: {
|
||||
/**
|
||||
Ensure a function is only called once. When called multiple times it will return the return value from the first call.
|
||||
|
||||
@param fn - Function that should only be called once.
|
||||
@returns A function that only calls `fn` once.
|
||||
|
||||
@example
|
||||
```
|
||||
import onetime from 'onetime';
|
||||
|
||||
let index = 0;
|
||||
|
||||
const foo = onetime(() => ++index);
|
||||
|
||||
foo(); //=> 1
|
||||
foo(); //=> 1
|
||||
foo(); //=> 1
|
||||
|
||||
onetime.callCount(foo); //=> 3
|
||||
```
|
||||
*/
|
||||
<ArgumentsType extends unknown[], ReturnType>(
|
||||
fn: (...arguments: ArgumentsType) => ReturnType,
|
||||
options?: Options
|
||||
): (...arguments: ArgumentsType) => ReturnType;
|
||||
|
||||
/**
|
||||
Get the number of times `fn` has been called.
|
||||
|
||||
@param fn - Function to get call count from.
|
||||
@returns A number representing how many times `fn` has been called.
|
||||
|
||||
@example
|
||||
```
|
||||
import onetime from 'onetime';
|
||||
|
||||
const foo = onetime(() => {});
|
||||
foo();
|
||||
foo();
|
||||
foo();
|
||||
|
||||
console.log(onetime.callCount(foo));
|
||||
//=> 3
|
||||
```
|
||||
*/
|
||||
callCount(fn: (...arguments: any[]) => unknown): number;
|
||||
};
|
||||
|
||||
export default onetime;
|
||||
@@ -0,0 +1,53 @@
|
||||
import { reduce } from './reduce';
|
||||
import { MonoTypeOperatorFunction } from '../types';
|
||||
import { isFunction } from '../util/isFunction';
|
||||
|
||||
/**
|
||||
* The Min operator operates on an Observable that emits numbers (or items that can be compared with a provided function),
|
||||
* and when source Observable completes it emits a single item: the item with the smallest value.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Get the minimal value of a series of numbers
|
||||
*
|
||||
* ```ts
|
||||
* import { of, min } from 'rxjs';
|
||||
*
|
||||
* of(5, 4, 7, 2, 8)
|
||||
* .pipe(min())
|
||||
* .subscribe(x => console.log(x));
|
||||
*
|
||||
* // Outputs
|
||||
* // 2
|
||||
* ```
|
||||
*
|
||||
* Use a comparer function to get the minimal item
|
||||
*
|
||||
* ```ts
|
||||
* import { of, min } from 'rxjs';
|
||||
*
|
||||
* of(
|
||||
* { age: 7, name: 'Foo' },
|
||||
* { age: 5, name: 'Bar' },
|
||||
* { age: 9, name: 'Beer' }
|
||||
* ).pipe(
|
||||
* min((a, b) => a.age < b.age ? -1 : 1)
|
||||
* )
|
||||
* .subscribe(x => console.log(x.name));
|
||||
*
|
||||
* // Outputs
|
||||
* // 'Bar'
|
||||
* ```
|
||||
*
|
||||
* @see {@link max}
|
||||
*
|
||||
* @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the
|
||||
* value of two items.
|
||||
* @return A function that returns an Observable that emits item with the
|
||||
* smallest value.
|
||||
*/
|
||||
export function min<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T> {
|
||||
return reduce(isFunction(comparer) ? (x, y) => (comparer(x, y) < 0 ? x : y) : (x, y) => (x < y ? x : y));
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AsapScheduler.js","sourceRoot":"","sources":["../../../../src/internal/scheduler/AsapScheduler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,aAAc,SAAQ,cAAc;IACxC,KAAK,CAAC,MAAyB;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAUpB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,IAAI,KAAU,CAAC;QACf,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,EAAG,CAAC;QAEpC,GAAG;YACD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBACxD,MAAM;aACP;SACF,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE;QAE5E,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE;gBACxE,MAAM,CAAC,WAAW,EAAE,CAAC;aACtB;YACD,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF"}
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.zipAll = void 0;
|
||||
var zip_1 = require("../observable/zip");
|
||||
var joinAllInternals_1 = require("./joinAllInternals");
|
||||
function zipAll(project) {
|
||||
return joinAllInternals_1.joinAllInternals(zip_1.zip, project);
|
||||
}
|
||||
exports.zipAll = zipAll;
|
||||
//# sourceMappingURL=zipAll.js.map
|
||||
@@ -0,0 +1,43 @@
|
||||
# es-set-tostringtag <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![github actions][actions-image]][actions-url]
|
||||
[![coverage][codecov-image]][codecov-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
A helper to optimistically set Symbol.toStringTag, when possible.
|
||||
|
||||
Most common usage:
|
||||
```js
|
||||
var assert = require('assert');
|
||||
var setToStringTag = require('es-set-tostringtag');
|
||||
|
||||
var obj = {};
|
||||
|
||||
assert.equal(Object.prototype.toString.call(obj), '[object Object]');
|
||||
|
||||
setToStringTag(obj, 'tagged!');
|
||||
|
||||
assert.equal(Object.prototype.toString.call(obj), '[object tagged!]');
|
||||
```
|
||||
|
||||
## Tests
|
||||
Simply clone the repo, `npm install`, and run `npm test`
|
||||
|
||||
[package-url]: https://npmjs.com/package/es-set-tostringtag
|
||||
[npm-version-svg]: https://versionbadg.es/es-shims/es-set-tostringtag.svg
|
||||
[deps-svg]: https://david-dm.org/es-shims/es-set-tostringtag.svg
|
||||
[deps-url]: https://david-dm.org/es-shims/es-set-tostringtag
|
||||
[dev-deps-svg]: https://david-dm.org/es-shims/es-set-tostringtag/dev-status.svg
|
||||
[dev-deps-url]: https://david-dm.org/es-shims/es-set-tostringtag#info=devDependencies
|
||||
[npm-badge-png]: https://nodei.co/npm/es-set-tostringtag.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/es-set-tostringtag.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/es-set-tostringtag.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=es-set-tostringtag
|
||||
[codecov-image]: https://codecov.io/gh/es-shims/es-set-tostringtag/branch/main/graphs/badge.svg
|
||||
[codecov-url]: https://app.codecov.io/gh/es-shims/es-set-tostringtag/
|
||||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/es-set-tostringtag
|
||||
[actions-url]: https://github.com/es-shims/es-set-tostringtag/actions
|
||||
@@ -0,0 +1,16 @@
|
||||
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
||||
|
||||
if (!globalThis.DOMException) {
|
||||
try {
|
||||
const { MessageChannel } = require('worker_threads'),
|
||||
port = new MessageChannel().port1,
|
||||
ab = new ArrayBuffer()
|
||||
port.postMessage(ab, [ab, ab])
|
||||
} catch (err) {
|
||||
err.constructor.name === 'DOMException' && (
|
||||
globalThis.DOMException = err.constructor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = globalThis.DOMException
|
||||
@@ -0,0 +1,529 @@
|
||||
var functionNoVendorRegexStr = '[A-Z]+(\\-|[A-Z]|[0-9])+\\(.*?\\)';
|
||||
var functionVendorRegexStr = '\\-(\\-|[A-Z]|[0-9])+\\(.*?\\)';
|
||||
var variableRegexStr = 'var\\(\\-\\-[^\\)]+\\)';
|
||||
var functionAnyRegexStr = '(' + variableRegexStr + '|' + functionNoVendorRegexStr + '|' + functionVendorRegexStr + ')';
|
||||
|
||||
var calcRegex = new RegExp('^(\\-moz\\-|\\-webkit\\-)?calc\\([^\\)]+\\)$', 'i');
|
||||
var decimalRegex = /[0-9]/;
|
||||
var functionAnyRegex = new RegExp('^' + functionAnyRegexStr + '$', 'i');
|
||||
var hslColorRegex = /^hsl\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+\s{0,31}\)$/i;
|
||||
var identifierRegex = /^(\-[a-z0-9_][a-z0-9\-_]*|[a-z][a-z0-9\-_]*)$/i;
|
||||
var namedEntityRegex = /^[a-z]+$/i;
|
||||
var prefixRegex = /^-([a-z0-9]|-)*$/i;
|
||||
var rgbColorRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\.\d]+\s{0,31}\)$/i;
|
||||
var timingFunctionRegex = /^(cubic\-bezier|steps)\([^\)]+\)$/;
|
||||
var validTimeUnits = ['ms', 's'];
|
||||
var urlRegex = /^url\([\s\S]+\)$/i;
|
||||
var variableRegex = new RegExp('^' + variableRegexStr + '$', 'i');
|
||||
|
||||
var eightValueColorRegex = /^#[0-9a-f]{8}$/i;
|
||||
var fourValueColorRegex = /^#[0-9a-f]{4}$/i;
|
||||
var sixValueColorRegex = /^#[0-9a-f]{6}$/i;
|
||||
var threeValueColorRegex = /^#[0-9a-f]{3}$/i;
|
||||
|
||||
var DECIMAL_DOT = '.';
|
||||
var MINUS_SIGN = '-';
|
||||
var PLUS_SIGN = '+';
|
||||
|
||||
var Keywords = {
|
||||
'^': [
|
||||
'inherit',
|
||||
'initial',
|
||||
'unset'
|
||||
],
|
||||
'*-style': [
|
||||
'auto',
|
||||
'dashed',
|
||||
'dotted',
|
||||
'double',
|
||||
'groove',
|
||||
'hidden',
|
||||
'inset',
|
||||
'none',
|
||||
'outset',
|
||||
'ridge',
|
||||
'solid'
|
||||
],
|
||||
'*-timing-function': [
|
||||
'ease',
|
||||
'ease-in',
|
||||
'ease-in-out',
|
||||
'ease-out',
|
||||
'linear',
|
||||
'step-end',
|
||||
'step-start'
|
||||
],
|
||||
'animation-direction': [
|
||||
'alternate',
|
||||
'alternate-reverse',
|
||||
'normal',
|
||||
'reverse'
|
||||
],
|
||||
'animation-fill-mode': [
|
||||
'backwards',
|
||||
'both',
|
||||
'forwards',
|
||||
'none'
|
||||
],
|
||||
'animation-iteration-count': [
|
||||
'infinite'
|
||||
],
|
||||
'animation-name': [
|
||||
'none'
|
||||
],
|
||||
'animation-play-state': [
|
||||
'paused',
|
||||
'running'
|
||||
],
|
||||
'background-attachment': [
|
||||
'fixed',
|
||||
'inherit',
|
||||
'local',
|
||||
'scroll'
|
||||
],
|
||||
'background-clip': [
|
||||
'border-box',
|
||||
'content-box',
|
||||
'inherit',
|
||||
'padding-box',
|
||||
'text'
|
||||
],
|
||||
'background-origin': [
|
||||
'border-box',
|
||||
'content-box',
|
||||
'inherit',
|
||||
'padding-box'
|
||||
],
|
||||
'background-position': [
|
||||
'bottom',
|
||||
'center',
|
||||
'left',
|
||||
'right',
|
||||
'top'
|
||||
],
|
||||
'background-repeat': [
|
||||
'no-repeat',
|
||||
'inherit',
|
||||
'repeat',
|
||||
'repeat-x',
|
||||
'repeat-y',
|
||||
'round',
|
||||
'space'
|
||||
],
|
||||
'background-size': [
|
||||
'auto',
|
||||
'cover',
|
||||
'contain'
|
||||
],
|
||||
'border-collapse': [
|
||||
'collapse',
|
||||
'inherit',
|
||||
'separate'
|
||||
],
|
||||
'bottom': [
|
||||
'auto'
|
||||
],
|
||||
'clear': [
|
||||
'both',
|
||||
'left',
|
||||
'none',
|
||||
'right'
|
||||
],
|
||||
'color': [
|
||||
'transparent'
|
||||
],
|
||||
'cursor': [
|
||||
'all-scroll',
|
||||
'auto',
|
||||
'col-resize',
|
||||
'crosshair',
|
||||
'default',
|
||||
'e-resize',
|
||||
'help',
|
||||
'move',
|
||||
'n-resize',
|
||||
'ne-resize',
|
||||
'no-drop',
|
||||
'not-allowed',
|
||||
'nw-resize',
|
||||
'pointer',
|
||||
'progress',
|
||||
'row-resize',
|
||||
's-resize',
|
||||
'se-resize',
|
||||
'sw-resize',
|
||||
'text',
|
||||
'vertical-text',
|
||||
'w-resize',
|
||||
'wait'
|
||||
],
|
||||
'display': [
|
||||
'block',
|
||||
'inline',
|
||||
'inline-block',
|
||||
'inline-table',
|
||||
'list-item',
|
||||
'none',
|
||||
'table',
|
||||
'table-caption',
|
||||
'table-cell',
|
||||
'table-column',
|
||||
'table-column-group',
|
||||
'table-footer-group',
|
||||
'table-header-group',
|
||||
'table-row',
|
||||
'table-row-group'
|
||||
],
|
||||
'float': [
|
||||
'left',
|
||||
'none',
|
||||
'right'
|
||||
],
|
||||
'left': [
|
||||
'auto'
|
||||
],
|
||||
'font': [
|
||||
'caption',
|
||||
'icon',
|
||||
'menu',
|
||||
'message-box',
|
||||
'small-caption',
|
||||
'status-bar',
|
||||
'unset'
|
||||
],
|
||||
'font-size': [
|
||||
'large',
|
||||
'larger',
|
||||
'medium',
|
||||
'small',
|
||||
'smaller',
|
||||
'x-large',
|
||||
'x-small',
|
||||
'xx-large',
|
||||
'xx-small'
|
||||
],
|
||||
'font-stretch': [
|
||||
'condensed',
|
||||
'expanded',
|
||||
'extra-condensed',
|
||||
'extra-expanded',
|
||||
'normal',
|
||||
'semi-condensed',
|
||||
'semi-expanded',
|
||||
'ultra-condensed',
|
||||
'ultra-expanded'
|
||||
],
|
||||
'font-style': [
|
||||
'italic',
|
||||
'normal',
|
||||
'oblique'
|
||||
],
|
||||
'font-variant': [
|
||||
'normal',
|
||||
'small-caps'
|
||||
],
|
||||
'font-weight': [
|
||||
'100',
|
||||
'200',
|
||||
'300',
|
||||
'400',
|
||||
'500',
|
||||
'600',
|
||||
'700',
|
||||
'800',
|
||||
'900',
|
||||
'bold',
|
||||
'bolder',
|
||||
'lighter',
|
||||
'normal'
|
||||
],
|
||||
'line-height': [
|
||||
'normal'
|
||||
],
|
||||
'list-style-position': [
|
||||
'inside',
|
||||
'outside'
|
||||
],
|
||||
'list-style-type': [
|
||||
'armenian',
|
||||
'circle',
|
||||
'decimal',
|
||||
'decimal-leading-zero',
|
||||
'disc',
|
||||
'decimal|disc', // this is the default value of list-style-type, see comment in compactable.js
|
||||
'georgian',
|
||||
'lower-alpha',
|
||||
'lower-greek',
|
||||
'lower-latin',
|
||||
'lower-roman',
|
||||
'none',
|
||||
'square',
|
||||
'upper-alpha',
|
||||
'upper-latin',
|
||||
'upper-roman'
|
||||
],
|
||||
'overflow': [
|
||||
'auto',
|
||||
'hidden',
|
||||
'scroll',
|
||||
'visible'
|
||||
],
|
||||
'position': [
|
||||
'absolute',
|
||||
'fixed',
|
||||
'relative',
|
||||
'static'
|
||||
],
|
||||
'right': [
|
||||
'auto'
|
||||
],
|
||||
'text-align': [
|
||||
'center',
|
||||
'justify',
|
||||
'left',
|
||||
'left|right', // this is the default value of list-style-type, see comment in compactable.js
|
||||
'right'
|
||||
],
|
||||
'text-decoration': [
|
||||
'line-through',
|
||||
'none',
|
||||
'overline',
|
||||
'underline'
|
||||
],
|
||||
'text-overflow': [
|
||||
'clip',
|
||||
'ellipsis'
|
||||
],
|
||||
'top': [
|
||||
'auto'
|
||||
],
|
||||
'vertical-align': [
|
||||
'baseline',
|
||||
'bottom',
|
||||
'middle',
|
||||
'sub',
|
||||
'super',
|
||||
'text-bottom',
|
||||
'text-top',
|
||||
'top'
|
||||
],
|
||||
'visibility': [
|
||||
'collapse',
|
||||
'hidden',
|
||||
'visible'
|
||||
],
|
||||
'white-space': [
|
||||
'normal',
|
||||
'nowrap',
|
||||
'pre'
|
||||
],
|
||||
'width': [
|
||||
'inherit',
|
||||
'initial',
|
||||
'medium',
|
||||
'thick',
|
||||
'thin'
|
||||
]
|
||||
};
|
||||
|
||||
var Units = [
|
||||
'%',
|
||||
'ch',
|
||||
'cm',
|
||||
'em',
|
||||
'ex',
|
||||
'in',
|
||||
'mm',
|
||||
'pc',
|
||||
'pt',
|
||||
'px',
|
||||
'rem',
|
||||
'vh',
|
||||
'vm',
|
||||
'vmax',
|
||||
'vmin',
|
||||
'vw'
|
||||
];
|
||||
|
||||
function isColor(value) {
|
||||
return value != 'auto' &&
|
||||
(
|
||||
isKeyword('color')(value) ||
|
||||
isHexColor(value) ||
|
||||
isColorFunction(value) ||
|
||||
isNamedEntity(value)
|
||||
);
|
||||
}
|
||||
|
||||
function isColorFunction(value) {
|
||||
return isRgbColor(value) || isHslColor(value);
|
||||
}
|
||||
|
||||
function isDynamicUnit(value) {
|
||||
return calcRegex.test(value);
|
||||
}
|
||||
|
||||
function isFunction(value) {
|
||||
return functionAnyRegex.test(value);
|
||||
}
|
||||
|
||||
function isHexColor(value) {
|
||||
return threeValueColorRegex.test(value) || fourValueColorRegex.test(value) || sixValueColorRegex.test(value) || eightValueColorRegex.test(value);
|
||||
}
|
||||
|
||||
function isHslColor(value) {
|
||||
return hslColorRegex.test(value);
|
||||
}
|
||||
|
||||
function isIdentifier(value) {
|
||||
return identifierRegex.test(value);
|
||||
}
|
||||
|
||||
function isImage(value) {
|
||||
return value == 'none' || value == 'inherit' || isUrl(value);
|
||||
}
|
||||
|
||||
function isKeyword(propertyName) {
|
||||
return function(value) {
|
||||
return Keywords[propertyName].indexOf(value) > -1;
|
||||
};
|
||||
}
|
||||
|
||||
function isNamedEntity(value) {
|
||||
return namedEntityRegex.test(value);
|
||||
}
|
||||
|
||||
function isNumber(value) {
|
||||
return scanForNumber(value) == value.length;
|
||||
}
|
||||
|
||||
function isRgbColor(value) {
|
||||
return rgbColorRegex.test(value);
|
||||
}
|
||||
|
||||
function isPrefixed(value) {
|
||||
return prefixRegex.test(value);
|
||||
}
|
||||
|
||||
function isPositiveNumber(value) {
|
||||
return isNumber(value) &&
|
||||
parseFloat(value) >= 0;
|
||||
}
|
||||
|
||||
function isVariable(value) {
|
||||
return variableRegex.test(value);
|
||||
}
|
||||
|
||||
function isTime(value) {
|
||||
var numberUpTo = scanForNumber(value);
|
||||
|
||||
return numberUpTo == value.length && parseInt(value) === 0 ||
|
||||
numberUpTo > -1 && validTimeUnits.indexOf(value.slice(numberUpTo + 1)) > -1;
|
||||
}
|
||||
|
||||
function isTimingFunction() {
|
||||
var isTimingFunctionKeyword = isKeyword('*-timing-function');
|
||||
|
||||
return function (value) {
|
||||
return isTimingFunctionKeyword(value) || timingFunctionRegex.test(value);
|
||||
};
|
||||
}
|
||||
|
||||
function isUnit(validUnits, value) {
|
||||
var numberUpTo = scanForNumber(value);
|
||||
|
||||
return numberUpTo == value.length && parseInt(value) === 0 ||
|
||||
numberUpTo > -1 && validUnits.indexOf(value.slice(numberUpTo + 1)) > -1 ||
|
||||
value == 'auto' ||
|
||||
value == 'inherit';
|
||||
}
|
||||
|
||||
function isUrl(value) {
|
||||
return urlRegex.test(value);
|
||||
}
|
||||
|
||||
function isZIndex(value) {
|
||||
return value == 'auto' ||
|
||||
isNumber(value) ||
|
||||
isKeyword('^')(value);
|
||||
}
|
||||
|
||||
function scanForNumber(value) {
|
||||
var hasDot = false;
|
||||
var hasSign = false;
|
||||
var character;
|
||||
var i, l;
|
||||
|
||||
for (i = 0, l = value.length; i < l; i++) {
|
||||
character = value[i];
|
||||
|
||||
if (i === 0 && (character == PLUS_SIGN || character == MINUS_SIGN)) {
|
||||
hasSign = true;
|
||||
} else if (i > 0 && hasSign && (character == PLUS_SIGN || character == MINUS_SIGN)) {
|
||||
return i - 1;
|
||||
} else if (character == DECIMAL_DOT && !hasDot) {
|
||||
hasDot = true;
|
||||
} else if (character == DECIMAL_DOT && hasDot) {
|
||||
return i - 1;
|
||||
} else if (decimalRegex.test(character)) {
|
||||
continue;
|
||||
} else {
|
||||
return i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
function validator(compatibility) {
|
||||
var validUnits = Units.slice(0).filter(function (value) {
|
||||
return !(value in compatibility.units) || compatibility.units[value] === true;
|
||||
});
|
||||
|
||||
return {
|
||||
colorOpacity: compatibility.colors.opacity,
|
||||
isAnimationDirectionKeyword: isKeyword('animation-direction'),
|
||||
isAnimationFillModeKeyword: isKeyword('animation-fill-mode'),
|
||||
isAnimationIterationCountKeyword: isKeyword('animation-iteration-count'),
|
||||
isAnimationNameKeyword: isKeyword('animation-name'),
|
||||
isAnimationPlayStateKeyword: isKeyword('animation-play-state'),
|
||||
isTimingFunction: isTimingFunction(),
|
||||
isBackgroundAttachmentKeyword: isKeyword('background-attachment'),
|
||||
isBackgroundClipKeyword: isKeyword('background-clip'),
|
||||
isBackgroundOriginKeyword: isKeyword('background-origin'),
|
||||
isBackgroundPositionKeyword: isKeyword('background-position'),
|
||||
isBackgroundRepeatKeyword: isKeyword('background-repeat'),
|
||||
isBackgroundSizeKeyword: isKeyword('background-size'),
|
||||
isColor: isColor,
|
||||
isColorFunction: isColorFunction,
|
||||
isDynamicUnit: isDynamicUnit,
|
||||
isFontKeyword: isKeyword('font'),
|
||||
isFontSizeKeyword: isKeyword('font-size'),
|
||||
isFontStretchKeyword: isKeyword('font-stretch'),
|
||||
isFontStyleKeyword: isKeyword('font-style'),
|
||||
isFontVariantKeyword: isKeyword('font-variant'),
|
||||
isFontWeightKeyword: isKeyword('font-weight'),
|
||||
isFunction: isFunction,
|
||||
isGlobal: isKeyword('^'),
|
||||
isHslColor: isHslColor,
|
||||
isIdentifier: isIdentifier,
|
||||
isImage: isImage,
|
||||
isKeyword: isKeyword,
|
||||
isLineHeightKeyword: isKeyword('line-height'),
|
||||
isListStylePositionKeyword: isKeyword('list-style-position'),
|
||||
isListStyleTypeKeyword: isKeyword('list-style-type'),
|
||||
isNumber: isNumber,
|
||||
isPrefixed: isPrefixed,
|
||||
isPositiveNumber: isPositiveNumber,
|
||||
isRgbColor: isRgbColor,
|
||||
isStyleKeyword: isKeyword('*-style'),
|
||||
isTime: isTime,
|
||||
isUnit: isUnit.bind(null, validUnits),
|
||||
isUrl: isUrl,
|
||||
isVariable: isVariable,
|
||||
isWidth: isKeyword('width'),
|
||||
isZIndex: isZIndex
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = validator;
|
||||
@@ -0,0 +1,876 @@
|
||||
'use strict';
|
||||
|
||||
const Char = {
|
||||
ANCHOR: '&',
|
||||
COMMENT: '#',
|
||||
TAG: '!',
|
||||
DIRECTIVES_END: '-',
|
||||
DOCUMENT_END: '.'
|
||||
};
|
||||
const Type = {
|
||||
ALIAS: 'ALIAS',
|
||||
BLANK_LINE: 'BLANK_LINE',
|
||||
BLOCK_FOLDED: 'BLOCK_FOLDED',
|
||||
BLOCK_LITERAL: 'BLOCK_LITERAL',
|
||||
COMMENT: 'COMMENT',
|
||||
DIRECTIVE: 'DIRECTIVE',
|
||||
DOCUMENT: 'DOCUMENT',
|
||||
FLOW_MAP: 'FLOW_MAP',
|
||||
FLOW_SEQ: 'FLOW_SEQ',
|
||||
MAP: 'MAP',
|
||||
MAP_KEY: 'MAP_KEY',
|
||||
MAP_VALUE: 'MAP_VALUE',
|
||||
PLAIN: 'PLAIN',
|
||||
QUOTE_DOUBLE: 'QUOTE_DOUBLE',
|
||||
QUOTE_SINGLE: 'QUOTE_SINGLE',
|
||||
SEQ: 'SEQ',
|
||||
SEQ_ITEM: 'SEQ_ITEM'
|
||||
};
|
||||
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
||||
const defaultTags = {
|
||||
MAP: 'tag:yaml.org,2002:map',
|
||||
SEQ: 'tag:yaml.org,2002:seq',
|
||||
STR: 'tag:yaml.org,2002:str'
|
||||
};
|
||||
|
||||
function findLineStarts(src) {
|
||||
const ls = [0];
|
||||
let offset = src.indexOf('\n');
|
||||
|
||||
while (offset !== -1) {
|
||||
offset += 1;
|
||||
ls.push(offset);
|
||||
offset = src.indexOf('\n', offset);
|
||||
}
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
function getSrcInfo(cst) {
|
||||
let lineStarts, src;
|
||||
|
||||
if (typeof cst === 'string') {
|
||||
lineStarts = findLineStarts(cst);
|
||||
src = cst;
|
||||
} else {
|
||||
if (Array.isArray(cst)) cst = cst[0];
|
||||
|
||||
if (cst && cst.context) {
|
||||
if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
|
||||
lineStarts = cst.lineStarts;
|
||||
src = cst.context.src;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
lineStarts,
|
||||
src
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @typedef {Object} LinePos - One-indexed position in the source
|
||||
* @property {number} line
|
||||
* @property {number} col
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determine the line/col position matching a character offset.
|
||||
*
|
||||
* Accepts a source string or a CST document as the second parameter. With
|
||||
* the latter, starting indices for lines are cached in the document as
|
||||
* `lineStarts: number[]`.
|
||||
*
|
||||
* Returns a one-indexed `{ line, col }` location if found, or
|
||||
* `undefined` otherwise.
|
||||
*
|
||||
* @param {number} offset
|
||||
* @param {string|Document|Document[]} cst
|
||||
* @returns {?LinePos}
|
||||
*/
|
||||
|
||||
|
||||
function getLinePos(offset, cst) {
|
||||
if (typeof offset !== 'number' || offset < 0) return null;
|
||||
const {
|
||||
lineStarts,
|
||||
src
|
||||
} = getSrcInfo(cst);
|
||||
if (!lineStarts || !src || offset > src.length) return null;
|
||||
|
||||
for (let i = 0; i < lineStarts.length; ++i) {
|
||||
const start = lineStarts[i];
|
||||
|
||||
if (offset < start) {
|
||||
return {
|
||||
line: i,
|
||||
col: offset - lineStarts[i - 1] + 1
|
||||
};
|
||||
}
|
||||
|
||||
if (offset === start) return {
|
||||
line: i + 1,
|
||||
col: 1
|
||||
};
|
||||
}
|
||||
|
||||
const line = lineStarts.length;
|
||||
return {
|
||||
line,
|
||||
col: offset - lineStarts[line - 1] + 1
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Get a specified line from the source.
|
||||
*
|
||||
* Accepts a source string or a CST document as the second parameter. With
|
||||
* the latter, starting indices for lines are cached in the document as
|
||||
* `lineStarts: number[]`.
|
||||
*
|
||||
* Returns the line as a string if found, or `null` otherwise.
|
||||
*
|
||||
* @param {number} line One-indexed line number
|
||||
* @param {string|Document|Document[]} cst
|
||||
* @returns {?string}
|
||||
*/
|
||||
|
||||
function getLine(line, cst) {
|
||||
const {
|
||||
lineStarts,
|
||||
src
|
||||
} = getSrcInfo(cst);
|
||||
if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null;
|
||||
const start = lineStarts[line - 1];
|
||||
let end = lineStarts[line]; // undefined for last line; that's ok for slice()
|
||||
|
||||
while (end && end > start && src[end - 1] === '\n') --end;
|
||||
|
||||
return src.slice(start, end);
|
||||
}
|
||||
/**
|
||||
* Pretty-print the starting line from the source indicated by the range `pos`
|
||||
*
|
||||
* Trims output to `maxWidth` chars while keeping the starting column visible,
|
||||
* using `…` at either end to indicate dropped characters.
|
||||
*
|
||||
* Returns a two-line string (or `null`) with `\n` as separator; the second line
|
||||
* will hold appropriately indented `^` marks indicating the column range.
|
||||
*
|
||||
* @param {Object} pos
|
||||
* @param {LinePos} pos.start
|
||||
* @param {LinePos} [pos.end]
|
||||
* @param {string|Document|Document[]*} cst
|
||||
* @param {number} [maxWidth=80]
|
||||
* @returns {?string}
|
||||
*/
|
||||
|
||||
function getPrettyContext({
|
||||
start,
|
||||
end
|
||||
}, cst, maxWidth = 80) {
|
||||
let src = getLine(start.line, cst);
|
||||
if (!src) return null;
|
||||
let {
|
||||
col
|
||||
} = start;
|
||||
|
||||
if (src.length > maxWidth) {
|
||||
if (col <= maxWidth - 10) {
|
||||
src = src.substr(0, maxWidth - 1) + '…';
|
||||
} else {
|
||||
const halfWidth = Math.round(maxWidth / 2);
|
||||
if (src.length > col + halfWidth) src = src.substr(0, col + halfWidth - 1) + '…';
|
||||
col -= src.length - maxWidth;
|
||||
src = '…' + src.substr(1 - maxWidth);
|
||||
}
|
||||
}
|
||||
|
||||
let errLen = 1;
|
||||
let errEnd = '';
|
||||
|
||||
if (end) {
|
||||
if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) {
|
||||
errLen = end.col - start.col;
|
||||
} else {
|
||||
errLen = Math.min(src.length + 1, maxWidth) - col;
|
||||
errEnd = '…';
|
||||
}
|
||||
}
|
||||
|
||||
const offset = col > 1 ? ' '.repeat(col - 1) : '';
|
||||
const err = '^'.repeat(errLen);
|
||||
return `${src}\n${offset}${err}${errEnd}`;
|
||||
}
|
||||
|
||||
class Range {
|
||||
static copy(orig) {
|
||||
return new Range(orig.start, orig.end);
|
||||
}
|
||||
|
||||
constructor(start, end) {
|
||||
this.start = start;
|
||||
this.end = end || start;
|
||||
}
|
||||
|
||||
isEmpty() {
|
||||
return typeof this.start !== 'number' || !this.end || this.end <= this.start;
|
||||
}
|
||||
/**
|
||||
* Set `origStart` and `origEnd` to point to the original source range for
|
||||
* this node, which may differ due to dropped CR characters.
|
||||
*
|
||||
* @param {number[]} cr - Positions of dropped CR characters
|
||||
* @param {number} offset - Starting index of `cr` from the last call
|
||||
* @returns {number} - The next offset, matching the one found for `origStart`
|
||||
*/
|
||||
|
||||
|
||||
setOrigRange(cr, offset) {
|
||||
const {
|
||||
start,
|
||||
end
|
||||
} = this;
|
||||
|
||||
if (cr.length === 0 || end <= cr[0]) {
|
||||
this.origStart = start;
|
||||
this.origEnd = end;
|
||||
return offset;
|
||||
}
|
||||
|
||||
let i = offset;
|
||||
|
||||
while (i < cr.length) {
|
||||
if (cr[i] > start) break;else ++i;
|
||||
}
|
||||
|
||||
this.origStart = start + i;
|
||||
const nextOffset = i;
|
||||
|
||||
while (i < cr.length) {
|
||||
// if end was at \n, it should now be at \r
|
||||
if (cr[i] >= end) break;else ++i;
|
||||
}
|
||||
|
||||
this.origEnd = end + i;
|
||||
return nextOffset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Root class of all nodes */
|
||||
|
||||
class Node {
|
||||
static addStringTerminator(src, offset, str) {
|
||||
if (str[str.length - 1] === '\n') return str;
|
||||
const next = Node.endOfWhiteSpace(src, offset);
|
||||
return next >= src.length || src[next] === '\n' ? str + '\n' : str;
|
||||
} // ^(---|...)
|
||||
|
||||
|
||||
static atDocumentBoundary(src, offset, sep) {
|
||||
const ch0 = src[offset];
|
||||
if (!ch0) return true;
|
||||
const prev = src[offset - 1];
|
||||
if (prev && prev !== '\n') return false;
|
||||
|
||||
if (sep) {
|
||||
if (ch0 !== sep) return false;
|
||||
} else {
|
||||
if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false;
|
||||
}
|
||||
|
||||
const ch1 = src[offset + 1];
|
||||
const ch2 = src[offset + 2];
|
||||
if (ch1 !== ch0 || ch2 !== ch0) return false;
|
||||
const ch3 = src[offset + 3];
|
||||
return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' ';
|
||||
}
|
||||
|
||||
static endOfIdentifier(src, offset) {
|
||||
let ch = src[offset];
|
||||
const isVerbatim = ch === '<';
|
||||
const notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ','];
|
||||
|
||||
while (ch && notOk.indexOf(ch) === -1) ch = src[offset += 1];
|
||||
|
||||
if (isVerbatim && ch === '>') offset += 1;
|
||||
return offset;
|
||||
}
|
||||
|
||||
static endOfIndent(src, offset) {
|
||||
let ch = src[offset];
|
||||
|
||||
while (ch === ' ') ch = src[offset += 1];
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static endOfLine(src, offset) {
|
||||
let ch = src[offset];
|
||||
|
||||
while (ch && ch !== '\n') ch = src[offset += 1];
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static endOfWhiteSpace(src, offset) {
|
||||
let ch = src[offset];
|
||||
|
||||
while (ch === '\t' || ch === ' ') ch = src[offset += 1];
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static startOfLine(src, offset) {
|
||||
let ch = src[offset - 1];
|
||||
if (ch === '\n') return offset;
|
||||
|
||||
while (ch && ch !== '\n') ch = src[offset -= 1];
|
||||
|
||||
return offset + 1;
|
||||
}
|
||||
/**
|
||||
* End of indentation, or null if the line's indent level is not more
|
||||
* than `indent`
|
||||
*
|
||||
* @param {string} src
|
||||
* @param {number} indent
|
||||
* @param {number} lineStart
|
||||
* @returns {?number}
|
||||
*/
|
||||
|
||||
|
||||
static endOfBlockIndent(src, indent, lineStart) {
|
||||
const inEnd = Node.endOfIndent(src, lineStart);
|
||||
|
||||
if (inEnd > lineStart + indent) {
|
||||
return inEnd;
|
||||
} else {
|
||||
const wsEnd = Node.endOfWhiteSpace(src, inEnd);
|
||||
const ch = src[wsEnd];
|
||||
if (!ch || ch === '\n') return wsEnd;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static atBlank(src, offset, endAsBlank) {
|
||||
const ch = src[offset];
|
||||
return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch;
|
||||
}
|
||||
|
||||
static nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) {
|
||||
if (!ch || indentDiff < 0) return false;
|
||||
if (indentDiff > 0) return true;
|
||||
return indicatorAsIndent && ch === '-';
|
||||
} // should be at line or string end, or at next non-whitespace char
|
||||
|
||||
|
||||
static normalizeOffset(src, offset) {
|
||||
const ch = src[offset];
|
||||
return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset);
|
||||
} // fold single newline into space, multiple newlines to N - 1 newlines
|
||||
// presumes src[offset] === '\n'
|
||||
|
||||
|
||||
static foldNewline(src, offset, indent) {
|
||||
let inCount = 0;
|
||||
let error = false;
|
||||
let fold = '';
|
||||
let ch = src[offset + 1];
|
||||
|
||||
while (ch === ' ' || ch === '\t' || ch === '\n') {
|
||||
switch (ch) {
|
||||
case '\n':
|
||||
inCount = 0;
|
||||
offset += 1;
|
||||
fold += '\n';
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
if (inCount <= indent) error = true;
|
||||
offset = Node.endOfWhiteSpace(src, offset + 2) - 1;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
inCount += 1;
|
||||
offset += 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ch = src[offset + 1];
|
||||
}
|
||||
|
||||
if (!fold) fold = ' ';
|
||||
if (ch && inCount <= indent) error = true;
|
||||
return {
|
||||
fold,
|
||||
offset,
|
||||
error
|
||||
};
|
||||
}
|
||||
|
||||
constructor(type, props, context) {
|
||||
Object.defineProperty(this, 'context', {
|
||||
value: context || null,
|
||||
writable: true
|
||||
});
|
||||
this.error = null;
|
||||
this.range = null;
|
||||
this.valueRange = null;
|
||||
this.props = props || [];
|
||||
this.type = type;
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
getPropValue(idx, key, skipKey) {
|
||||
if (!this.context) return null;
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
const prop = this.props[idx];
|
||||
return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null;
|
||||
}
|
||||
|
||||
get anchor() {
|
||||
for (let i = 0; i < this.props.length; ++i) {
|
||||
const anchor = this.getPropValue(i, Char.ANCHOR, true);
|
||||
if (anchor != null) return anchor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
get comment() {
|
||||
const comments = [];
|
||||
|
||||
for (let i = 0; i < this.props.length; ++i) {
|
||||
const comment = this.getPropValue(i, Char.COMMENT, true);
|
||||
if (comment != null) comments.push(comment);
|
||||
}
|
||||
|
||||
return comments.length > 0 ? comments.join('\n') : null;
|
||||
}
|
||||
|
||||
commentHasRequiredWhitespace(start) {
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
if (this.header && start === this.header.end) return false;
|
||||
if (!this.valueRange) return false;
|
||||
const {
|
||||
end
|
||||
} = this.valueRange;
|
||||
return start !== end || Node.atBlank(src, end - 1);
|
||||
}
|
||||
|
||||
get hasComment() {
|
||||
if (this.context) {
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
|
||||
for (let i = 0; i < this.props.length; ++i) {
|
||||
if (src[this.props[i].start] === Char.COMMENT) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
get hasProps() {
|
||||
if (this.context) {
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
|
||||
for (let i = 0; i < this.props.length; ++i) {
|
||||
if (src[this.props[i].start] !== Char.COMMENT) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
get includesTrailingLines() {
|
||||
return false;
|
||||
}
|
||||
|
||||
get jsonLike() {
|
||||
const jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE];
|
||||
return jsonLikeTypes.indexOf(this.type) !== -1;
|
||||
}
|
||||
|
||||
get rangeAsLinePos() {
|
||||
if (!this.range || !this.context) return undefined;
|
||||
const start = getLinePos(this.range.start, this.context.root);
|
||||
if (!start) return undefined;
|
||||
const end = getLinePos(this.range.end, this.context.root);
|
||||
return {
|
||||
start,
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
get rawValue() {
|
||||
if (!this.valueRange || !this.context) return null;
|
||||
const {
|
||||
start,
|
||||
end
|
||||
} = this.valueRange;
|
||||
return this.context.src.slice(start, end);
|
||||
}
|
||||
|
||||
get tag() {
|
||||
for (let i = 0; i < this.props.length; ++i) {
|
||||
const tag = this.getPropValue(i, Char.TAG, false);
|
||||
|
||||
if (tag != null) {
|
||||
if (tag[1] === '<') {
|
||||
return {
|
||||
verbatim: tag.slice(2, -1)
|
||||
};
|
||||
} else {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [_, handle, suffix] = tag.match(/^(.*!)([^!]*)$/);
|
||||
return {
|
||||
handle,
|
||||
suffix
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
get valueRangeContainsNewline() {
|
||||
if (!this.valueRange || !this.context) return false;
|
||||
const {
|
||||
start,
|
||||
end
|
||||
} = this.valueRange;
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
|
||||
for (let i = start; i < end; ++i) {
|
||||
if (src[i] === '\n') return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
parseComment(start) {
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
|
||||
if (src[start] === Char.COMMENT) {
|
||||
const end = Node.endOfLine(src, start + 1);
|
||||
const commentRange = new Range(start, end);
|
||||
this.props.push(commentRange);
|
||||
return end;
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
/**
|
||||
* Populates the `origStart` and `origEnd` values of all ranges for this
|
||||
* node. Extended by child classes to handle descendant nodes.
|
||||
*
|
||||
* @param {number[]} cr - Positions of dropped CR characters
|
||||
* @param {number} offset - Starting index of `cr` from the last call
|
||||
* @returns {number} - The next offset, matching the one found for `origStart`
|
||||
*/
|
||||
|
||||
|
||||
setOrigRanges(cr, offset) {
|
||||
if (this.range) offset = this.range.setOrigRange(cr, offset);
|
||||
if (this.valueRange) this.valueRange.setOrigRange(cr, offset);
|
||||
this.props.forEach(prop => prop.setOrigRange(cr, offset));
|
||||
return offset;
|
||||
}
|
||||
|
||||
toString() {
|
||||
const {
|
||||
context: {
|
||||
src
|
||||
},
|
||||
range,
|
||||
value
|
||||
} = this;
|
||||
if (value != null) return value;
|
||||
const str = src.slice(range.start, range.end);
|
||||
return Node.addStringTerminator(src, range.end, str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class YAMLError extends Error {
|
||||
constructor(name, source, message) {
|
||||
if (!message || !(source instanceof Node)) throw new Error(`Invalid arguments for new ${name}`);
|
||||
super();
|
||||
this.name = name;
|
||||
this.message = message;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
makePretty() {
|
||||
if (!this.source) return;
|
||||
this.nodeType = this.source.type;
|
||||
const cst = this.source.context && this.source.context.root;
|
||||
|
||||
if (typeof this.offset === 'number') {
|
||||
this.range = new Range(this.offset, this.offset + 1);
|
||||
const start = cst && getLinePos(this.offset, cst);
|
||||
|
||||
if (start) {
|
||||
const end = {
|
||||
line: start.line,
|
||||
col: start.col + 1
|
||||
};
|
||||
this.linePos = {
|
||||
start,
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
delete this.offset;
|
||||
} else {
|
||||
this.range = this.source.range;
|
||||
this.linePos = this.source.rangeAsLinePos;
|
||||
}
|
||||
|
||||
if (this.linePos) {
|
||||
const {
|
||||
line,
|
||||
col
|
||||
} = this.linePos.start;
|
||||
this.message += ` at line ${line}, column ${col}`;
|
||||
const ctx = cst && getPrettyContext(this.linePos, cst);
|
||||
if (ctx) this.message += `:\n\n${ctx}\n`;
|
||||
}
|
||||
|
||||
delete this.source;
|
||||
}
|
||||
|
||||
}
|
||||
class YAMLReferenceError extends YAMLError {
|
||||
constructor(source, message) {
|
||||
super('YAMLReferenceError', source, message);
|
||||
}
|
||||
|
||||
}
|
||||
class YAMLSemanticError extends YAMLError {
|
||||
constructor(source, message) {
|
||||
super('YAMLSemanticError', source, message);
|
||||
}
|
||||
|
||||
}
|
||||
class YAMLSyntaxError extends YAMLError {
|
||||
constructor(source, message) {
|
||||
super('YAMLSyntaxError', source, message);
|
||||
}
|
||||
|
||||
}
|
||||
class YAMLWarning extends YAMLError {
|
||||
constructor(source, message) {
|
||||
super('YAMLWarning', source, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
class PlainValue extends Node {
|
||||
static endOfLine(src, start, inFlow) {
|
||||
let ch = src[start];
|
||||
let offset = start;
|
||||
|
||||
while (ch && ch !== '\n') {
|
||||
if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
|
||||
const next = src[offset + 1];
|
||||
if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break;
|
||||
if ((ch === ' ' || ch === '\t') && next === '#') break;
|
||||
offset += 1;
|
||||
ch = next;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
get strValue() {
|
||||
if (!this.valueRange || !this.context) return null;
|
||||
let {
|
||||
start,
|
||||
end
|
||||
} = this.valueRange;
|
||||
const {
|
||||
src
|
||||
} = this.context;
|
||||
let ch = src[end - 1];
|
||||
|
||||
while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) ch = src[--end - 1];
|
||||
|
||||
let str = '';
|
||||
|
||||
for (let i = start; i < end; ++i) {
|
||||
const ch = src[i];
|
||||
|
||||
if (ch === '\n') {
|
||||
const {
|
||||
fold,
|
||||
offset
|
||||
} = Node.foldNewline(src, i, -1);
|
||||
str += fold;
|
||||
i = offset;
|
||||
} else if (ch === ' ' || ch === '\t') {
|
||||
// trim trailing whitespace
|
||||
const wsStart = i;
|
||||
let next = src[i + 1];
|
||||
|
||||
while (i < end && (next === ' ' || next === '\t')) {
|
||||
i += 1;
|
||||
next = src[i + 1];
|
||||
}
|
||||
|
||||
if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
|
||||
} else {
|
||||
str += ch;
|
||||
}
|
||||
}
|
||||
|
||||
const ch0 = src[start];
|
||||
|
||||
switch (ch0) {
|
||||
case '\t':
|
||||
{
|
||||
const msg = 'Plain value cannot start with a tab character';
|
||||
const errors = [new YAMLSemanticError(this, msg)];
|
||||
return {
|
||||
errors,
|
||||
str
|
||||
};
|
||||
}
|
||||
|
||||
case '@':
|
||||
case '`':
|
||||
{
|
||||
const msg = `Plain value cannot start with reserved character ${ch0}`;
|
||||
const errors = [new YAMLSemanticError(this, msg)];
|
||||
return {
|
||||
errors,
|
||||
str
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
parseBlockValue(start) {
|
||||
const {
|
||||
indent,
|
||||
inFlow,
|
||||
src
|
||||
} = this.context;
|
||||
let offset = start;
|
||||
let valueEnd = start;
|
||||
|
||||
for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
|
||||
if (Node.atDocumentBoundary(src, offset + 1)) break;
|
||||
const end = Node.endOfBlockIndent(src, indent, offset + 1);
|
||||
if (end === null || src[end] === '#') break;
|
||||
|
||||
if (src[end] === '\n') {
|
||||
offset = end;
|
||||
} else {
|
||||
valueEnd = PlainValue.endOfLine(src, end, inFlow);
|
||||
offset = valueEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.valueRange.isEmpty()) this.valueRange.start = start;
|
||||
this.valueRange.end = valueEnd;
|
||||
return valueEnd;
|
||||
}
|
||||
/**
|
||||
* Parses a plain value from the source
|
||||
*
|
||||
* Accepted forms are:
|
||||
* ```
|
||||
* #comment
|
||||
*
|
||||
* first line
|
||||
*
|
||||
* first line #comment
|
||||
*
|
||||
* first line
|
||||
* block
|
||||
* lines
|
||||
*
|
||||
* #comment
|
||||
* block
|
||||
* lines
|
||||
* ```
|
||||
* where block lines are empty or have an indent level greater than `indent`.
|
||||
*
|
||||
* @param {ParseContext} context
|
||||
* @param {number} start - Index of first character
|
||||
* @returns {number} - Index of the character after this scalar, may be `\n`
|
||||
*/
|
||||
|
||||
|
||||
parse(context, start) {
|
||||
this.context = context;
|
||||
const {
|
||||
inFlow,
|
||||
src
|
||||
} = context;
|
||||
let offset = start;
|
||||
const ch = src[offset];
|
||||
|
||||
if (ch && ch !== '#' && ch !== '\n') {
|
||||
offset = PlainValue.endOfLine(src, start, inFlow);
|
||||
}
|
||||
|
||||
this.valueRange = new Range(start, offset);
|
||||
offset = Node.endOfWhiteSpace(src, offset);
|
||||
offset = this.parseComment(offset);
|
||||
|
||||
if (!this.hasComment || this.valueRange.isEmpty()) {
|
||||
offset = this.parseBlockValue(offset);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.Char = Char;
|
||||
exports.Node = Node;
|
||||
exports.PlainValue = PlainValue;
|
||||
exports.Range = Range;
|
||||
exports.Type = Type;
|
||||
exports.YAMLError = YAMLError;
|
||||
exports.YAMLReferenceError = YAMLReferenceError;
|
||||
exports.YAMLSemanticError = YAMLSemanticError;
|
||||
exports.YAMLSyntaxError = YAMLSyntaxError;
|
||||
exports.YAMLWarning = YAMLWarning;
|
||||
exports._defineProperty = _defineProperty;
|
||||
exports.defaultTagPrefix = defaultTagPrefix;
|
||||
exports.defaultTags = defaultTags;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"2":"C K L G M N O","2052":"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 tB I v EC FC","1028":"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","1060":"0 1 2 3 4 5 6 7 8 9 J D E F A B C K L G M N O w g x y z AB BB"},D:{"2":"0 1 I v J D E F A B C K L G M N O w g x y z","226":"2 3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB","2052":"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 HC zB IC JC","772":"K L G rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","804":"E F A B C LC 0B qB","1316":"KC"},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 PC QC RC SC qB AC TC rB","226":"BB CB DB EB FB GB HB IB JB","2052":"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"},G:{"2":"zB UC BC VC WC XC","292":"E YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"2":"A B C qB AC rB","2052":"h"},L:{"2052":"H"},M:{"1028":"H"},N:{"2":"A B"},O:{"2052":"vC"},P:{"2":"I wC xC","2052":"g yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"2052":"1B"},R:{"2052":"9C"},S:{"1028":"AD BD"}},B:4,C:"text-decoration styling"};
|
||||
@@ -0,0 +1,5 @@
|
||||
Year,Make,Model,Description,Price
|
||||
1997,Ford,E350,"ac, abs, moon",3000.00
|
||||
1999,Chevy,"Venture ""Extended Edition""","",4900.00
|
||||
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
|
||||
1996,Jeep,Grand Cherokee,"MUST SELL!air, moon roof, loaded",4799.00
|
||||
@@ -0,0 +1,212 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import path from 'path'
|
||||
import arg from 'arg'
|
||||
import fs from 'fs'
|
||||
|
||||
import { build } from './build'
|
||||
import { help } from './help'
|
||||
import { init } from './init'
|
||||
|
||||
function isESM() {
|
||||
const pkgPath = path.resolve('./package.json')
|
||||
|
||||
try {
|
||||
let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
||||
return pkg.type && pkg.type === 'module'
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
let configs = isESM() ? { tailwind: 'tailwind.config.cjs' } : { tailwind: 'tailwind.config.js' }
|
||||
|
||||
// ---
|
||||
|
||||
function oneOf(...options) {
|
||||
return Object.assign(
|
||||
(value = true) => {
|
||||
for (let option of options) {
|
||||
let parsed = option(value)
|
||||
if (parsed === value) {
|
||||
return parsed
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('...')
|
||||
},
|
||||
{ manualParsing: true }
|
||||
)
|
||||
}
|
||||
|
||||
let commands = {
|
||||
init: {
|
||||
run: init,
|
||||
args: {
|
||||
'--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
|
||||
'-f': '--full',
|
||||
},
|
||||
},
|
||||
build: {
|
||||
run: build,
|
||||
args: {
|
||||
'--input': { type: String, description: 'Input file' },
|
||||
'--output': { type: String, description: 'Output file' },
|
||||
'--watch': {
|
||||
type: oneOf(String, Boolean),
|
||||
description: 'Watch for changes and rebuild as needed',
|
||||
},
|
||||
'--poll': {
|
||||
type: Boolean,
|
||||
description: 'Use polling instead of filesystem events when watching',
|
||||
},
|
||||
'--content': {
|
||||
type: String,
|
||||
description: 'Content paths to use for removing unused classes',
|
||||
},
|
||||
'--minify': { type: Boolean, description: 'Minify the output' },
|
||||
'--config': {
|
||||
type: String,
|
||||
description: 'Path to a custom config file',
|
||||
},
|
||||
'-c': '--config',
|
||||
'-i': '--input',
|
||||
'-o': '--output',
|
||||
'-m': '--minify',
|
||||
'-w': '--watch',
|
||||
'-p': '--poll',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
let sharedFlags = {
|
||||
'--help': { type: Boolean, description: 'Display usage information' },
|
||||
'-h': '--help',
|
||||
}
|
||||
|
||||
if (
|
||||
process.stdout.isTTY /* Detect redirecting output to a file */ &&
|
||||
(process.argv[2] === undefined ||
|
||||
process.argv.slice(2).every((flag) => sharedFlags[flag] !== undefined))
|
||||
) {
|
||||
help({
|
||||
usage: [
|
||||
'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
|
||||
'tailwindcss init [--full] [options...]',
|
||||
],
|
||||
commands: Object.keys(commands)
|
||||
.filter((command) => command !== 'build')
|
||||
.map((command) => `${command} [options]`),
|
||||
options: { ...commands.build.args, ...sharedFlags },
|
||||
})
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
let command = ((arg = '') => (arg.startsWith('-') ? undefined : arg))(process.argv[2]) || 'build'
|
||||
|
||||
if (commands[command] === undefined) {
|
||||
if (fs.existsSync(path.resolve(command))) {
|
||||
// TODO: Deprecate this in future versions
|
||||
// Check if non-existing command, might be a file.
|
||||
command = 'build'
|
||||
} else {
|
||||
help({
|
||||
message: `Invalid command: ${command}`,
|
||||
usage: ['tailwindcss <command> [options]'],
|
||||
commands: Object.keys(commands)
|
||||
.filter((command) => command !== 'build')
|
||||
.map((command) => `${command} [options]`),
|
||||
options: sharedFlags,
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Execute command
|
||||
let { args: flags, run } = commands[command]
|
||||
let args = (() => {
|
||||
try {
|
||||
let result = arg(
|
||||
Object.fromEntries(
|
||||
Object.entries({ ...flags, ...sharedFlags })
|
||||
.filter(([_key, value]) => !value?.type?.manualParsing)
|
||||
.map(([key, value]) => [key, typeof value === 'object' ? value.type : value])
|
||||
),
|
||||
{ permissive: true }
|
||||
)
|
||||
|
||||
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
||||
for (let i = result['_'].length - 1; i >= 0; --i) {
|
||||
let flag = result['_'][i]
|
||||
if (!flag.startsWith('-')) continue
|
||||
|
||||
let [flagName, flagValue] = flag.split('=')
|
||||
let handler = flags[flagName]
|
||||
|
||||
// Resolve flagName & handler
|
||||
while (typeof handler === 'string') {
|
||||
flagName = handler
|
||||
handler = flags[handler]
|
||||
}
|
||||
|
||||
if (!handler) continue
|
||||
|
||||
let args = []
|
||||
let offset = i + 1
|
||||
|
||||
// --flag value syntax was used so we need to pull `value` from `args`
|
||||
if (flagValue === undefined) {
|
||||
// Parse args for current flag
|
||||
while (result['_'][offset] && !result['_'][offset].startsWith('-')) {
|
||||
args.push(result['_'][offset++])
|
||||
}
|
||||
|
||||
// Cleanup manually parsed flags + args
|
||||
result['_'].splice(i, 1 + args.length)
|
||||
|
||||
// No args were provided, use default value defined in handler
|
||||
// One arg was provided, use that directly
|
||||
// Multiple args were provided so pass them all in an array
|
||||
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args
|
||||
} else {
|
||||
// Remove the whole flag from the args array
|
||||
result['_'].splice(i, 1)
|
||||
}
|
||||
|
||||
// Set the resolved value in the `result` object
|
||||
result[flagName] = handler.type(flagValue, flagName)
|
||||
}
|
||||
|
||||
// Ensure that the `command` is always the first argument in the `args`.
|
||||
// This is important so that we don't have to check if a default command
|
||||
// (build) was used or not from within each plugin.
|
||||
//
|
||||
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
||||
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
||||
if (result['_'][0] !== command) {
|
||||
result['_'].unshift(command)
|
||||
}
|
||||
|
||||
return result
|
||||
} catch (err) {
|
||||
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
||||
help({
|
||||
message: err.message,
|
||||
usage: ['tailwindcss <command> [options]'],
|
||||
options: sharedFlags,
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
throw err
|
||||
}
|
||||
})()
|
||||
|
||||
if (args['--help']) {
|
||||
help({
|
||||
options: { ...flags, ...sharedFlags },
|
||||
usage: [`tailwindcss ${command} [options]`],
|
||||
})
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
run(args, configs)
|
||||
@@ -0,0 +1,31 @@
|
||||
# `String.random(options = { ... })` _(ext/string/random)_
|
||||
|
||||
Returns generated random string, contained only of ascii cars `a-z` and `0-1`.
|
||||
By default returns string of length `10`.
|
||||
|
||||
```javascript
|
||||
const random = require("ext/string/random");
|
||||
|
||||
random(); // "upcfns0i4t"
|
||||
random({ length: 3 }); // "5tw"
|
||||
```
|
||||
|
||||
## Supported options:
|
||||
|
||||
### `isUnique: false`
|
||||
|
||||
Ensures generated string is unique among ones already returned.
|
||||
|
||||
_Note: When not applying this setting, accidental generation of same string is still highly unlikely. Provided option is just to provide a mean to eliminate possibility of an edge case of duplicate string being returned_
|
||||
|
||||
### `length: 10`
|
||||
|
||||
Desired length of result string
|
||||
|
||||
### `charset: null`
|
||||
|
||||
Fixed list of possible characters
|
||||
|
||||
```javascript
|
||||
random({ charset: "abc" }); // "bacbccbbac"
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
'use strict'
|
||||
|
||||
class Warning {
|
||||
constructor(text, opts = {}) {
|
||||
this.type = 'warning'
|
||||
this.text = text
|
||||
|
||||
if (opts.node && opts.node.source) {
|
||||
let range = opts.node.rangeBy(opts)
|
||||
this.line = range.start.line
|
||||
this.column = range.start.column
|
||||
this.endLine = range.end.line
|
||||
this.endColumn = range.end.column
|
||||
}
|
||||
|
||||
for (let opt in opts) this[opt] = opts[opt]
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.node) {
|
||||
return this.node.error(this.text, {
|
||||
plugin: this.plugin,
|
||||
index: this.index,
|
||||
word: this.word
|
||||
}).message
|
||||
}
|
||||
|
||||
if (this.plugin) {
|
||||
return this.plugin + ': ' + this.text
|
||||
}
|
||||
|
||||
return this.text
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Warning
|
||||
Warning.default = Warning
|
||||
@@ -0,0 +1,83 @@
|
||||
const fs = require('fs');
|
||||
const globrex = require('globrex');
|
||||
const { promisify } = require('util');
|
||||
const globalyzer = require('globalyzer');
|
||||
const { join, resolve, relative } = require('path');
|
||||
const isHidden = /(^|[\\\/])\.[^\\\/\.]/g;
|
||||
const readdir = promisify(fs.readdir);
|
||||
const stat = promisify(fs.stat);
|
||||
let CACHE = {};
|
||||
|
||||
async function walk(output, prefix, lexer, opts, dirname='', level=0) {
|
||||
const rgx = lexer.segments[level];
|
||||
const dir = resolve(opts.cwd, prefix, dirname);
|
||||
const files = await readdir(dir);
|
||||
const { dot, filesOnly } = opts;
|
||||
|
||||
let i=0, len=files.length, file;
|
||||
let fullpath, relpath, stats, isMatch;
|
||||
|
||||
for (; i < len; i++) {
|
||||
fullpath = join(dir, file=files[i]);
|
||||
relpath = dirname ? join(dirname, file) : file;
|
||||
if (!dot && isHidden.test(relpath)) continue;
|
||||
isMatch = lexer.regex.test(relpath);
|
||||
|
||||
if ((stats=CACHE[relpath]) === void 0) {
|
||||
CACHE[relpath] = stats = fs.lstatSync(fullpath);
|
||||
}
|
||||
|
||||
if (!stats.isDirectory()) {
|
||||
isMatch && output.push(relative(opts.cwd, fullpath));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rgx && !rgx.test(file)) continue;
|
||||
!filesOnly && isMatch && output.push(join(prefix, relpath));
|
||||
|
||||
await walk(output, prefix, lexer, opts, relpath, rgx && rgx.toString() !== lexer.globstar && level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find files using bash-like globbing.
|
||||
* All paths are normalized compared to node-glob.
|
||||
* @param {String} str Glob string
|
||||
* @param {String} [options.cwd='.'] Current working directory
|
||||
* @param {Boolean} [options.dot=false] Include dotfile matches
|
||||
* @param {Boolean} [options.absolute=false] Return absolute paths
|
||||
* @param {Boolean} [options.filesOnly=false] Do not include folders if true
|
||||
* @param {Boolean} [options.flush=false] Reset cache object
|
||||
* @returns {Array} array containing matching files
|
||||
*/
|
||||
module.exports = async function (str, opts={}) {
|
||||
if (!str) return [];
|
||||
|
||||
let glob = globalyzer(str);
|
||||
|
||||
opts.cwd = opts.cwd || '.';
|
||||
|
||||
if (!glob.isGlob) {
|
||||
try {
|
||||
let resolved = resolve(opts.cwd, str);
|
||||
let dirent = await stat(resolved);
|
||||
if (opts.filesOnly && !dirent.isFile()) return [];
|
||||
|
||||
return opts.absolute ? [resolved] : [str];
|
||||
} catch (err) {
|
||||
if (err.code != 'ENOENT') throw err;
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.flush) CACHE = {};
|
||||
|
||||
let matches = [];
|
||||
const { path } = globrex(glob.glob, { filepath:true, globstar:true, extended:true });
|
||||
|
||||
path.globstar = path.globstar.toString();
|
||||
await walk(matches, glob.base, path, opts, '.', 0);
|
||||
|
||||
return opts.absolute ? matches.map(x => resolve(opts.cwd, x)) : matches;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var hasProto = require('../');
|
||||
|
||||
test('hasProto', function (t) {
|
||||
var result = hasProto();
|
||||
t.equal(typeof result, 'boolean', 'returns a boolean (' + result + ')');
|
||||
|
||||
var obj = { __proto__: null };
|
||||
if (result) {
|
||||
t.notOk('toString' in obj, 'null object lacks toString');
|
||||
} else {
|
||||
t.ok('toString' in obj, 'without proto, null object has toString');
|
||||
t.equal(obj.__proto__, null); // eslint-disable-line no-proto
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').asyncify;
|
||||
@@ -0,0 +1,5 @@
|
||||
import { AsyncAction } from './AsyncAction';
|
||||
import { AsyncScheduler } from './AsyncScheduler';
|
||||
export var asyncScheduler = new AsyncScheduler(AsyncAction);
|
||||
export var async = asyncScheduler;
|
||||
//# sourceMappingURL=async.js.map
|
||||
@@ -0,0 +1,301 @@
|
||||
# @iarna/toml
|
||||
|
||||
Better TOML parsing and stringifying all in that familiar JSON interface.
|
||||
|
||||
[](https://coveralls.io/github/iarna/iarna-toml)
|
||||
|
||||
# ** TOML 0.5.0 **
|
||||
|
||||
### TOML Spec Support
|
||||
|
||||
The most recent version as of 2018-07-26: [v0.5.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.5.0.md)
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
const TOML = require('@iarna/toml')
|
||||
const obj = TOML.parse(`[abc]
|
||||
foo = 123
|
||||
bar = [1,2,3]`)
|
||||
/* obj =
|
||||
{abc: {foo: 123, bar: [1,2,3]}}
|
||||
*/
|
||||
const str = TOML.stringify(obj)
|
||||
/* str =
|
||||
[abc]
|
||||
foo = 123
|
||||
bar = [ 1, 2, 3 ]
|
||||
*/
|
||||
```
|
||||
|
||||
Visit the project github [for more examples](https://github.com/iarna/iarna-toml/tree/latest/examples)!
|
||||
|
||||
|
||||
## Why @iarna/toml
|
||||
|
||||
* See [TOML-SPEC-SUPPORT](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html)
|
||||
for a comparison of which TOML features are supported by the various
|
||||
Node.js TOML parsers.
|
||||
* BigInt support on Node 10!
|
||||
* 100% test coverage.
|
||||
* Fast parsing. It's as much as 100 times
|
||||
faster than `toml` and 3 times faster than `toml-j0.4`. However a recent
|
||||
newcomer [`@ltd/j-toml`](https://www.npmjs.com/package/@ltd/j-toml) has
|
||||
appeared with 0.5 support and astoundingly fast parsing speeds for large
|
||||
text blocks. All I can say is you'll have to test your specific work loads
|
||||
if you want to know which of @iarna/toml and @ltd/j-toml is faster for
|
||||
you, as we currently excell in different areas.
|
||||
* Careful adherence to spec. Tests go beyond simple coverage.
|
||||
* Smallest parser bundle (if you use `@iarna/toml/parse-string`).
|
||||
* No deps.
|
||||
* Detailed and easy to read error messages‼
|
||||
|
||||
```console
|
||||
> TOML.parse(src)
|
||||
Error: Unexpected character, expecting string, number, datetime, boolean, inline array or inline table at row 6, col 5, pos 87:
|
||||
5: "abc\"" = { abc=123,def="abc" }
|
||||
6> foo=sdkfj
|
||||
^
|
||||
7:
|
||||
```
|
||||
|
||||
## TOML.parse(str) → Object [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-string')`
|
||||
|
||||
Synchronously parse a TOML string and return an object.
|
||||
|
||||
|
||||
## TOML.stringify(obj) → String [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/stringify.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/stringify)`
|
||||
|
||||
Serialize an object as TOML.
|
||||
|
||||
## [your-object].toJSON
|
||||
|
||||
If an object `TOML.stringify` is serializing has a `toJSON` method then it
|
||||
will call it to transform the object before serializing it. This matches
|
||||
the behavior of `JSON.stringify`.
|
||||
|
||||
The one exception to this is that `toJSON` is not called for `Date` objects
|
||||
because `JSON` represents dates as strings and TOML can represent them natively.
|
||||
|
||||
[`moment`](https://www.npmjs.com/package/moment) objects are treated the
|
||||
same as native `Date` objects, in this respect.
|
||||
|
||||
## TOML.stringify.value(obj) -> String
|
||||
|
||||
Also available with: `require('@iarna/toml/stringify').value`
|
||||
|
||||
Serialize a value as TOML would. This is a fragment and not a complete
|
||||
valid TOML document.
|
||||
|
||||
## Promises and Streaming
|
||||
|
||||
The parser provides alternative async and streaming interfaces, for times
|
||||
that you're working with really absurdly big TOML files and don't want to
|
||||
tie-up the event loop while it parses.
|
||||
|
||||
### TOML.parse.async(str[, opts]) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-async.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-async')`
|
||||
|
||||
`opts.blocksize` is the amount text to parser per pass through the event loop. Defaults to 40kb.
|
||||
|
||||
Asynchronously parse a TOML string and return a promise of the resulting object.
|
||||
|
||||
### TOML.parse.stream(readable) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-readable.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-stream')`
|
||||
|
||||
Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
|
||||
|
||||
### readable.pipe(TOML.parse.stream()) → Transform [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-through.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-stream')`
|
||||
|
||||
Returns a transform stream in object mode. When it completes, emit the
|
||||
resulting object. Only one object will ever be emitted.
|
||||
|
||||
## Lowlevel Interface [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel.js) [(example w/ parser debugging)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel-debug.js)
|
||||
|
||||
You construct a parser object, per TOML file you want to process:
|
||||
|
||||
```js
|
||||
const TOMLParser = require('@iarna/toml/lib/toml-parser.js')
|
||||
const parser = new TOMLParser()
|
||||
```
|
||||
|
||||
Then you call the `parse` method for each chunk as you read them, or in a
|
||||
single call:
|
||||
|
||||
```js
|
||||
parser.parse(`hello = 'world'`)
|
||||
```
|
||||
|
||||
And finally, you call the `finish` method to complete parsing and retrieve
|
||||
the resulting object.
|
||||
|
||||
```js
|
||||
const data = parser.finish()
|
||||
```
|
||||
|
||||
Both the `parse` method and `finish` method will throw if they find a
|
||||
problem with the string they were given. Error objects thrown from the
|
||||
parser have `pos`, `line` and `col` attributes. `TOML.parse` adds a visual
|
||||
summary of where in the source string there were issues using
|
||||
`parse-pretty-error` and you can too:
|
||||
|
||||
```js
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
const newErr = prettyError(err, sourceString)
|
||||
```
|
||||
|
||||
## What's Different
|
||||
|
||||
Version 2 of this module supports TOML 0.5.0. Other modules currently
|
||||
published to the npm registry support 0.4.0. 0.5.0 is mostly backwards
|
||||
compatible with 0.4.0, but if you have need, you can install @iarna/toml@1
|
||||
to get a version of this module that supports 0.4.0. Please see the
|
||||
[CHANGELOG](CHANGELOG.md#2.0.0) for details on exactly whats changed.
|
||||
|
||||
## TOML we can't do
|
||||
|
||||
* `-nan` is a valid TOML value and is converted into `NaN`. There is no way to
|
||||
produce `-nan` when stringifying. Stringification will produce positive `nan`.
|
||||
* Detecting and erroring on invalid utf8 documents: This is because Node's
|
||||
UTF8 processing converts invalid sequences into the placeholder character
|
||||
and does not have facilities for reporting these as errors instead. We
|
||||
_can_ detect the placeholder character, but it's valid to intentionally
|
||||
include them in documents, so erroring on them is not great.
|
||||
* On versions of Node < 10, very large Integer values will lose precision.
|
||||
On Node >=10, bigints are used.
|
||||
* Floating/local dates and times are still represented by JavaScript Date
|
||||
objects, which don't actually support these concepts. The objects
|
||||
returned have been modified so that you can determine what kind of thing
|
||||
they are (with `isFloating`, `isDate`, `isTime` properties) and that
|
||||
their ISO representation (via `toISOString`) is representative of their
|
||||
TOML value. They will correctly round trip if you pass them to
|
||||
`TOML.stringify`.
|
||||
* Binary, hexadecimal and octal values are converted to ordinary integers and
|
||||
will be decimal if you stringify them.
|
||||
|
||||
## Changes
|
||||
|
||||
I write a by hand, honest-to-god,
|
||||
[CHANGELOG](https://github.com/iarna/iarna-toml/blob/latest/CHANGELOG.md)
|
||||
for this project. It's a description of what went into a release that you
|
||||
the consumer of the module could care about, not a list of git commits, so
|
||||
please check it out!
|
||||
|
||||
## Benchmarks
|
||||
|
||||
You can run them yourself with:
|
||||
|
||||
```console
|
||||
$ npm run benchmark
|
||||
```
|
||||
|
||||
The results below are from my desktop using Node 13.13.0. The library
|
||||
versions tested were `@iarna/toml@2.2.4`, `toml-j0.4@1.1.1`, `toml@3.0.0`,
|
||||
`@sgarciac/bombadil@2.3.0`, `@ltd/j-toml@0.5.107`, and `fast-toml@0.5.4`. The speed value is
|
||||
megabytes-per-second that the parser can process of that document type.
|
||||
Bigger is better. The percentage after average results is the margin of error.
|
||||
|
||||
New here is fast-toml. fast-toml is very fast, for some datatypes, but it
|
||||
also is missing most error checking demanded by the spec. For 0.4, it is
|
||||
complete except for detail of multiline strings caught by the compliance
|
||||
tests. Its support for 0.5 is incomplete. Check out the
|
||||
[spec compliance](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html) doc
|
||||
for details.
|
||||
|
||||
As this table is getting a little wide, with how npm and github display it,
|
||||
you can also view it seperately in the
|
||||
[BENCHMARK](https://shared.by.re-becca.org/misc/BENCHMARK.html) document.
|
||||
|
||||
| | @iarna/<wbr>toml | toml-j0.4 | toml | @sgarciac/<wbr>bombadil | @ltd/<wbr>j-toml | fast-toml |
|
||||
| - | :---------: | :-------: | :--: | :----------------: | :---------: | :-------: |
|
||||
| **Overall** | 28MB/sec<br><small>0.35%</small> | 6.5MB/sec<br><small>0.25%</small> | 0.2MB/sec<br><small>0.70%</small> | - | 35MB/sec<br><small>0.23%</small> | - |
|
||||
| **Spec Example: v0.4.0** | 26MB/sec<br><small>0.37%</small> | 10MB/sec<br><small>0.27%</small> | 1MB/sec<br><small>0.42%</small> | 1.2MB/sec<br><small>0.95%</small> | 28MB/sec<br><small>0.31%</small> | - |
|
||||
| **Spec Example: Hard Unicode** | 64MB/sec<br><small>0.59%</small> | 18MB/sec<br><small>0.12%</small> | 2MB/sec<br><small>0.20%</small> | 0.6MB/sec<br><small>0.53%</small> | 68MB/sec<br><small>0.31%</small> | 78MB/sec<br><small>0.28%</small> |
|
||||
| **Types: Array, Inline** | 7.3MB/sec<br><small>0.60%</small> | 4MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>0.91%</small> | 1.3MB/sec<br><small>0.81%</small> | 10MB/sec<br><small>0.35%</small> | 9MB/sec<br><small>0.16%</small> |
|
||||
| **Types: Array** | 6.8MB/sec<br><small>0.19%</small> | 6.7MB/sec<br><small>0.15%</small> | 0.2MB/sec<br><small>0.79%</small> | 1.2MB/sec<br><small>0.93%</small> | 8.8MB/sec<br><small>0.47%</small> | 27MB/sec<br><small>0.21%</small> |
|
||||
| **Types: Boolean,** | 21MB/sec<br><small>0.20%</small> | 9.4MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>0.96%</small> | 1.8MB/sec<br><small>0.70%</small> | 16MB/sec<br><small>0.20%</small> | 8.4MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Datetime** | 18MB/sec<br><small>0.14%</small> | 11MB/sec<br><small>0.15%</small> | 0.3MB/sec<br><small>0.85%</small> | 1.6MB/sec<br><small>0.45%</small> | 9.8MB/sec<br><small>0.48%</small> | 6.5MB/sec<br><small>0.23%</small> |
|
||||
| **Types: Float** | 8.8MB/sec<br><small>0.09%</small> | 5.9MB/sec<br><small>0.14%</small> | 0.2MB/sec<br><small>0.51%</small> | 2.1MB/sec<br><small>0.82%</small> | 14MB/sec<br><small>0.15%</small> | 7.9MB/sec<br><small>0.14%</small> |
|
||||
| **Types: Int** | 5.9MB/sec<br><small>0.11%</small> | 4.5MB/sec<br><small>0.28%</small> | 0.1MB/sec<br><small>0.78%</small> | 1.5MB/sec<br><small>0.64%</small> | 10MB/sec<br><small>0.14%</small> | 8MB/sec<br><small>0.17%</small> |
|
||||
| **Types: Literal String, 7 char** | 26MB/sec<br><small>0.29%</small> | 8.5MB/sec<br><small>0.32%</small> | 0.3MB/sec<br><small>0.84%</small> | 2.3MB/sec<br><small>1.02%</small> | 23MB/sec<br><small>0.15%</small> | 13MB/sec<br><small>0.15%</small> |
|
||||
| **Types: Literal String, 92 char** | 46MB/sec<br><small>0.19%</small> | 11MB/sec<br><small>0.20%</small> | 0.3MB/sec<br><small>0.56%</small> | 12MB/sec<br><small>0.92%</small> | 101MB/sec<br><small>0.17%</small> | 75MB/sec<br><small>0.29%</small> |
|
||||
| **Types: Literal String, Multiline, 1079 char** | 22MB/sec<br><small>0.42%</small> | 6.7MB/sec<br><small>0.55%</small> | 0.9MB/sec<br><small>0.78%</small> | 44MB/sec<br><small>1.00%</small> | 350MB/sec<br><small>0.16%</small> | 636MB/sec<br><small>0.16%</small> |
|
||||
| **Types: Basic String, 7 char** | 25MB/sec<br><small>0.15%</small> | 7.3MB/sec<br><small>0.18%</small> | 0.2MB/sec<br><small>0.96%</small> | 2.2MB/sec<br><small>1.09%</small> | 14MB/sec<br><small>0.16%</small> | 12MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Basic String, 92 char** | 43MB/sec<br><small>0.30%</small> | 7.2MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>4.04%</small> | 12MB/sec<br><small>1.33%</small> | 71MB/sec<br><small>0.19%</small> | 70MB/sec<br><small>0.23%</small> |
|
||||
| **Types: Basic String, 1079 char** | 24MB/sec<br><small>0.45%</small> | 5.8MB/sec<br><small>0.17%</small> | 0.1MB/sec<br><small>3.64%</small> | 44MB/sec<br><small>1.05%</small> | 93MB/sec<br><small>0.29%</small> | 635MB/sec<br><small>0.28%</small> |
|
||||
| **Types: Table, Inline** | 9.7MB/sec<br><small>0.10%</small> | 5.5MB/sec<br><small>0.22%</small> | 0.1MB/sec<br><small>0.87%</small> | 1.4MB/sec<br><small>1.18%</small> | 8.7MB/sec<br><small>0.60%</small> | 8.7MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Table** | 7.1MB/sec<br><small>0.14%</small> | 5.6MB/sec<br><small>0.42%</small> | 0.1MB/sec<br><small>0.65%</small> | 1.4MB/sec<br><small>1.11%</small> | 7.4MB/sec<br><small>0.70%</small> | 18MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Array, Inline, 1000 elements** | 40MB/sec<br><small>0.21%</small> | 2.4MB/sec<br><small>0.19%</small> | 0.1MB/sec<br><small>0.35%</small> | 1.6MB/sec<br><small>1.02%</small> | 17MB/sec<br><small>0.15%</small> | 32MB/sec<br><small>0.16%</small> |
|
||||
| **Scaling: Array, Nested, 1000 deep** | 2MB/sec<br><small>0.15%</small> | 1.7MB/sec<br><small>0.26%</small> | 0.3MB/sec<br><small>0.58%</small> | - | 1.8MB/sec<br><small>0.74%</small> | 13MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Literal String, 40kb** | 61MB/sec<br><small>0.18%</small> | 10MB/sec<br><small>0.15%</small> | 3MB/sec<br><small>0.84%</small> | 12MB/sec<br><small>0.51%</small> | 551MB/sec<br><small>0.44%</small> | 19kMB/sec<br><small>0.19%</small> |
|
||||
| **Scaling: Literal String, Multiline, 40kb** | 62MB/sec<br><small>0.16%</small> | 5MB/sec<br><small>0.45%</small> | 0.2MB/sec<br><small>1.70%</small> | 11MB/sec<br><small>0.74%</small> | 291MB/sec<br><small>0.24%</small> | 21kMB/sec<br><small>0.22%</small> |
|
||||
| **Scaling: Basic String, Multiline, 40kb** | 62MB/sec<br><small>0.18%</small> | 5.8MB/sec<br><small>0.38%</small> | 2.9MB/sec<br><small>0.86%</small> | 11MB/sec<br><small>0.41%</small> | 949MB/sec<br><small>0.44%</small> | 26kMB/sec<br><small>0.16%</small> |
|
||||
| **Scaling: Basic String, 40kb** | 59MB/sec<br><small>0.20%</small> | 6.3MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>1.95%</small> | 12MB/sec<br><small>0.44%</small> | 508MB/sec<br><small>0.35%</small> | 18kMB/sec<br><small>0.15%</small> |
|
||||
| **Scaling: Table, Inline, 1000 elements** | 28MB/sec<br><small>0.12%</small> | 8.2MB/sec<br><small>0.19%</small> | 0.3MB/sec<br><small>0.89%</small> | 2.3MB/sec<br><small>1.14%</small> | 5.3MB/sec<br><small>0.24%</small> | 13MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Table, Inline, Nested, 1000 deep** | 7.8MB/sec<br><small>0.28%</small> | 5MB/sec<br><small>0.20%</small> | 0.1MB/sec<br><small>0.84%</small> | - | 3.2MB/sec<br><small>0.52%</small> | 10MB/sec<br><small>0.23%</small> |
|
||||
|
||||
## Tests
|
||||
|
||||
The test suite is maintained at 100% coverage: [](https://coveralls.io/github/iarna/iarna-toml)
|
||||
|
||||
The spec was carefully hand converted into a series of test framework
|
||||
independent (and mostly language independent) assertions, as pairs of TOML
|
||||
and YAML files. You can find those files here:
|
||||
[spec-test](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test/).
|
||||
A number of examples of invalid Unicode were also written, but are difficult
|
||||
to make use of in Node.js where Unicode errors are silently hidden. You can
|
||||
find those here: [spec-test-disabled](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test-disabled/).
|
||||
|
||||
Further tests were written to increase coverage to 100%, these may be more
|
||||
implementation specific, but they can be found in [coverage](https://github.com/iarna/iarna-toml/blob/latest/test/coverage.js) and
|
||||
[coverage-error](https://github.com/iarna/iarna-toml/blob/latest/test/coverage-error.js).
|
||||
|
||||
I've also written some quality assurance style tests, which don't contribute
|
||||
to coverage but do cover scenarios that could easily be problematic for some
|
||||
implementations can be found in:
|
||||
[test/qa.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa.js) and
|
||||
[test/qa-error.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa-error.js).
|
||||
|
||||
All of the official example files from the TOML spec are run through this
|
||||
parser and compared to the official YAML files when available. These files are from the TOML spec as of:
|
||||
[357a4ba6](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc)
|
||||
and specifically are:
|
||||
|
||||
* [github.com/toml-lang/toml/tree/357a4ba6/examples](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/examples)
|
||||
* [github.com/toml-lang/toml/tree/357a4ba6/tests](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/tests)
|
||||
|
||||
The stringifier is tested by round-tripping these same files, asserting that
|
||||
`TOML.parse(sourcefile)` deepEqual
|
||||
`TOML.parse(TOML.stringify(TOML.parse(sourcefile))`. This is done in
|
||||
[test/roundtrip-examples.js](https://github.com/iarna/iarna-toml/blob/latest/test/round-tripping.js)
|
||||
There are also some tests written to complete coverage from stringification in:
|
||||
[test/stringify.js](https://github.com/iarna/iarna-toml/blob/latest/test/stringify.js)
|
||||
|
||||
Tests for the async and streaming interfaces are in [test/async.js](https://github.com/iarna/iarna-toml/blob/latest/test/async.js) and [test/stream.js](https://github.com/iarna/iarna-toml/blob/latest/test/stream.js) respectively.
|
||||
|
||||
Tests for the parsers debugging mode live in [test/devel.js](https://github.com/iarna/iarna-toml/blob/latest/test/devel.js).
|
||||
|
||||
And finally, many more stringification tests were borrowed from [@othiym23](https://github.com/othiym23)'s
|
||||
[toml-stream](https://npmjs.com/package/toml-stream) module. They were fetched as of
|
||||
[b6f1e26b572d49742d49fa6a6d11524d003441fa](https://github.com/othiym23/toml-stream/tree/b6f1e26b572d49742d49fa6a6d11524d003441fa/test) and live in
|
||||
[test/toml-stream](https://github.com/iarna/iarna-toml/blob/latest/test/toml-stream/).
|
||||
|
||||
## Improvements to make
|
||||
|
||||
* In stringify:
|
||||
* Any way to produce comments. As a JSON stand-in I'm not too worried
|
||||
about this. That said, a document orientated fork is something I'd like
|
||||
to look at eventually…
|
||||
* Stringification could use some work on its error reporting. It reports
|
||||
_what's_ wrong, but not where in your data structure it was.
|
||||
* Further optimize the parser:
|
||||
* There are some debugging assertions left in the main parser, these should be moved to a subclass.
|
||||
* Make the whole debugging parser thing work as a mixin instead of as a superclass.
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "ansi-styles",
|
||||
"version": "6.2.1",
|
||||
"description": "ANSI escape codes for styling strings in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-styles",
|
||||
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"svg-term-cli": "^2.1.1",
|
||||
"tsd": "^0.19.0",
|
||||
"xo": "^0.47.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
/**
|
||||
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
||||
* separate module.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js)
|
||||
*/
|
||||
declare module 'https' {
|
||||
import { Duplex } from 'node:stream';
|
||||
import * as tls from 'node:tls';
|
||||
import * as http from 'node:http';
|
||||
import { URL } from 'node:url';
|
||||
type ServerOptions<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
||||
type RequestOptions = http.RequestOptions &
|
||||
tls.SecureContextOptions & {
|
||||
checkServerIdentity?: typeof tls.checkServerIdentity | undefined;
|
||||
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
||||
servername?: string | undefined; // SNI TLS Extension
|
||||
};
|
||||
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
||||
rejectUnauthorized?: boolean | undefined;
|
||||
maxCachedSessions?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
|
||||
* @since v0.4.5
|
||||
*/
|
||||
class Agent extends http.Agent {
|
||||
constructor(options?: AgentOptions);
|
||||
options: AgentOptions;
|
||||
}
|
||||
interface Server<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
> extends http.Server<Request, Response> {}
|
||||
/**
|
||||
* See `http.Server` for more information.
|
||||
* @since v0.3.4
|
||||
*/
|
||||
class Server<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
> extends tls.Server {
|
||||
constructor(requestListener?: http.RequestListener<Request, Response>);
|
||||
constructor(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: http.RequestListener<Request, Response>,
|
||||
);
|
||||
/**
|
||||
* Closes all connections connected to this server.
|
||||
* @since v18.2.0
|
||||
*/
|
||||
closeAllConnections(): void;
|
||||
/**
|
||||
* Closes all connections connected to this server which are not sending a request or waiting for a response.
|
||||
* @since v18.2.0
|
||||
*/
|
||||
closeIdleConnections(): void;
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(
|
||||
event: 'newSession',
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
addListener(
|
||||
event: 'OCSPRequest',
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
addListener(
|
||||
event: 'resumeSession',
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'listening', listener: () => void): this;
|
||||
addListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
||||
addListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
||||
addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
addListener(
|
||||
event: 'connect',
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
addListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
||||
addListener(
|
||||
event: 'upgrade',
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(
|
||||
event: 'newSession',
|
||||
sessionId: Buffer,
|
||||
sessionData: Buffer,
|
||||
callback: (err: Error, resp: Buffer) => void,
|
||||
): boolean;
|
||||
emit(
|
||||
event: 'OCSPRequest',
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
): boolean;
|
||||
emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
|
||||
emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'connection', socket: Duplex): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(
|
||||
event: 'checkContinue',
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & { req: InstanceType<Request> },
|
||||
): boolean;
|
||||
emit(
|
||||
event: 'checkExpectation',
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & { req: InstanceType<Request> },
|
||||
): boolean;
|
||||
emit(event: 'clientError', err: Error, socket: Duplex): boolean;
|
||||
emit(event: 'connect', req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||
emit(
|
||||
event: 'request',
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & { req: InstanceType<Request> },
|
||||
): boolean;
|
||||
emit(event: 'upgrade', req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(
|
||||
event: 'newSession',
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
on(
|
||||
event: 'OCSPRequest',
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
on(
|
||||
event: 'resumeSession',
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'listening', listener: () => void): this;
|
||||
on(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
||||
on(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
||||
on(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
on(event: 'connect', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
on(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
||||
on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(
|
||||
event: 'newSession',
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
once(
|
||||
event: 'OCSPRequest',
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
once(
|
||||
event: 'resumeSession',
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'listening', listener: () => void): this;
|
||||
once(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
||||
once(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
||||
once(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
once(event: 'connect', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
||||
once(event: 'upgrade', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(
|
||||
event: 'newSession',
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
prependListener(
|
||||
event: 'OCSPRequest',
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
prependListener(
|
||||
event: 'resumeSession',
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'listening', listener: () => void): this;
|
||||
prependListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
||||
prependListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
||||
prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
prependListener(
|
||||
event: 'connect',
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
prependListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
||||
prependListener(
|
||||
event: 'upgrade',
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(
|
||||
event: 'newSession',
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: 'OCSPRequest',
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: 'resumeSession',
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
||||
prependOnceListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
prependOnceListener(
|
||||
event: 'connect',
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
prependOnceListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
||||
prependOnceListener(
|
||||
event: 'upgrade',
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
}
|
||||
/**
|
||||
* ```js
|
||||
* // curl -k https://localhost:8000/
|
||||
* const https = require('https');
|
||||
* const fs = require('fs');
|
||||
*
|
||||
* const options = {
|
||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
||||
* };
|
||||
*
|
||||
* https.createServer(options, (req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end('hello world\n');
|
||||
* }).listen(8000);
|
||||
* ```
|
||||
*
|
||||
* Or
|
||||
*
|
||||
* ```js
|
||||
* const https = require('https');
|
||||
* const fs = require('fs');
|
||||
*
|
||||
* const options = {
|
||||
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
||||
* passphrase: 'sample'
|
||||
* };
|
||||
*
|
||||
* https.createServer(options, (req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end('hello world\n');
|
||||
* }).listen(8000);
|
||||
* ```
|
||||
* @since v0.3.4
|
||||
* @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
|
||||
* @param requestListener A listener to be added to the `'request'` event.
|
||||
*/
|
||||
function createServer<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
|
||||
function createServer<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
>(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: http.RequestListener<Request, Response>,
|
||||
): Server<Request, Response>;
|
||||
/**
|
||||
* Makes a request to a secure web server.
|
||||
*
|
||||
* The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`,
|
||||
* `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`.
|
||||
*
|
||||
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
||||
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
||||
*
|
||||
* `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
|
||||
* upload a file with a POST request, then write to the `ClientRequest` object.
|
||||
*
|
||||
* ```js
|
||||
* const https = require('https');
|
||||
*
|
||||
* const options = {
|
||||
* hostname: 'encrypted.google.com',
|
||||
* port: 443,
|
||||
* path: '/',
|
||||
* method: 'GET'
|
||||
* };
|
||||
*
|
||||
* const req = https.request(options, (res) => {
|
||||
* console.log('statusCode:', res.statusCode);
|
||||
* console.log('headers:', res.headers);
|
||||
*
|
||||
* res.on('data', (d) => {
|
||||
* process.stdout.write(d);
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* req.on('error', (e) => {
|
||||
* console.error(e);
|
||||
* });
|
||||
* req.end();
|
||||
* ```
|
||||
*
|
||||
* Example using options from `tls.connect()`:
|
||||
*
|
||||
* ```js
|
||||
* const options = {
|
||||
* hostname: 'encrypted.google.com',
|
||||
* port: 443,
|
||||
* path: '/',
|
||||
* method: 'GET',
|
||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
||||
* };
|
||||
* options.agent = new https.Agent(options);
|
||||
*
|
||||
* const req = https.request(options, (res) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Alternatively, opt out of connection pooling by not using an `Agent`.
|
||||
*
|
||||
* ```js
|
||||
* const options = {
|
||||
* hostname: 'encrypted.google.com',
|
||||
* port: 443,
|
||||
* path: '/',
|
||||
* method: 'GET',
|
||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||
* agent: false
|
||||
* };
|
||||
*
|
||||
* const req = https.request(options, (res) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Example using a `URL` as `options`:
|
||||
*
|
||||
* ```js
|
||||
* const options = new URL('https://abc:xyz@example.com');
|
||||
*
|
||||
* const req = https.request(options, (res) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('tls');
|
||||
* const https = require('https');
|
||||
* const crypto = require('crypto');
|
||||
*
|
||||
* function sha256(s) {
|
||||
* return crypto.createHash('sha256').update(s).digest('base64');
|
||||
* }
|
||||
* const options = {
|
||||
* hostname: 'github.com',
|
||||
* port: 443,
|
||||
* path: '/',
|
||||
* method: 'GET',
|
||||
* checkServerIdentity: function(host, cert) {
|
||||
* // Make sure the certificate is issued to the host we are connected to
|
||||
* const err = tls.checkServerIdentity(host, cert);
|
||||
* if (err) {
|
||||
* return err;
|
||||
* }
|
||||
*
|
||||
* // Pin the public key, similar to HPKP pin-sha25 pinning
|
||||
* const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
|
||||
* if (sha256(cert.pubkey) !== pubkey256) {
|
||||
* const msg = 'Certificate verification error: ' +
|
||||
* `The public key of '${cert.subject.CN}' ` +
|
||||
* 'does not match our pinned fingerprint';
|
||||
* return new Error(msg);
|
||||
* }
|
||||
*
|
||||
* // Pin the exact certificate, rather than the pub key
|
||||
* const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
|
||||
* 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
|
||||
* if (cert.fingerprint256 !== cert256) {
|
||||
* const msg = 'Certificate verification error: ' +
|
||||
* `The certificate of '${cert.subject.CN}' ` +
|
||||
* 'does not match our pinned fingerprint';
|
||||
* return new Error(msg);
|
||||
* }
|
||||
*
|
||||
* // This loop is informational only.
|
||||
* // Print the certificate and public key fingerprints of all certs in the
|
||||
* // chain. Its common to pin the public key of the issuer on the public
|
||||
* // internet, while pinning the public key of the service in sensitive
|
||||
* // environments.
|
||||
* do {
|
||||
* console.log('Subject Common Name:', cert.subject.CN);
|
||||
* console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
|
||||
*
|
||||
* hash = crypto.createHash('sha256');
|
||||
* console.log(' Public key ping-sha256:', sha256(cert.pubkey));
|
||||
*
|
||||
* lastprint256 = cert.fingerprint256;
|
||||
* cert = cert.issuerCertificate;
|
||||
* } while (cert.fingerprint256 !== lastprint256);
|
||||
*
|
||||
* },
|
||||
* };
|
||||
*
|
||||
* options.agent = new https.Agent(options);
|
||||
* const req = https.request(options, (res) => {
|
||||
* console.log('All OK. Server matched our pinned cert or public key');
|
||||
* console.log('statusCode:', res.statusCode);
|
||||
* // Print the HPKP values
|
||||
* console.log('headers:', res.headers['public-key-pins']);
|
||||
*
|
||||
* res.on('data', (d) => {});
|
||||
* });
|
||||
*
|
||||
* req.on('error', (e) => {
|
||||
* console.error(e.message);
|
||||
* });
|
||||
* req.end();
|
||||
* ```
|
||||
*
|
||||
* Outputs for example:
|
||||
*
|
||||
* ```text
|
||||
* Subject Common Name: github.com
|
||||
* Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
|
||||
* Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
|
||||
* Subject Common Name: DigiCert SHA2 Extended Validation Server CA
|
||||
* Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
|
||||
* Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
|
||||
* Subject Common Name: DigiCert High Assurance EV Root CA
|
||||
* Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
|
||||
* Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
|
||||
* All OK. Server matched our pinned cert or public key
|
||||
* statusCode: 200
|
||||
* headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
|
||||
* pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
|
||||
* pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
|
||||
* ```
|
||||
* @since v0.3.6
|
||||
* @param options Accepts all `options` from `request`, with some differences in default values:
|
||||
*/
|
||||
function request(
|
||||
options: RequestOptions | string | URL,
|
||||
callback?: (res: http.IncomingMessage) => void,
|
||||
): http.ClientRequest;
|
||||
function request(
|
||||
url: string | URL,
|
||||
options: RequestOptions,
|
||||
callback?: (res: http.IncomingMessage) => void,
|
||||
): http.ClientRequest;
|
||||
/**
|
||||
* Like `http.get()` but for HTTPS.
|
||||
*
|
||||
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
||||
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
||||
*
|
||||
* ```js
|
||||
* const https = require('https');
|
||||
*
|
||||
* https.get('https://encrypted.google.com/', (res) => {
|
||||
* console.log('statusCode:', res.statusCode);
|
||||
* console.log('headers:', res.headers);
|
||||
*
|
||||
* res.on('data', (d) => {
|
||||
* process.stdout.write(d);
|
||||
* });
|
||||
*
|
||||
* }).on('error', (e) => {
|
||||
* console.error(e);
|
||||
* });
|
||||
* ```
|
||||
* @since v0.3.6
|
||||
* @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
|
||||
*/
|
||||
function get(
|
||||
options: RequestOptions | string | URL,
|
||||
callback?: (res: http.IncomingMessage) => void,
|
||||
): http.ClientRequest;
|
||||
function get(
|
||||
url: string | URL,
|
||||
options: RequestOptions,
|
||||
callback?: (res: http.IncomingMessage) => void,
|
||||
): http.ClientRequest;
|
||||
let globalAgent: Agent;
|
||||
}
|
||||
declare module 'node:https' {
|
||||
export * from 'https';
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? String.prototype.repeat : require("./shim");
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "color-name",
|
||||
"version": "1.1.4",
|
||||
"description": "A list of color names and its values",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:colorjs/color-name.git"
|
||||
},
|
||||
"keywords": [
|
||||
"color-name",
|
||||
"color",
|
||||
"color-keyword",
|
||||
"keyword"
|
||||
],
|
||||
"author": "DY <dfcreative@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/colorjs/color-name/issues"
|
||||
},
|
||||
"homepage": "https://github.com/colorjs/color-name"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"setprototypeof","version":"1.2.0","files":{"package.json":{"checkedAt":1678883672270,"integrity":"sha512-bZuVvGYqCbU2T2+5Q+IImEzVDCPM1TYb2GJh/O6tmXsgO7OXIfDYLbLTXU/MZL5w5ItxJE2qUW3sfsCbYdravA==","mode":420,"size":1264},"index.d.ts":{"checkedAt":1678883672270,"integrity":"sha512-DS8yCXKYh/pZjbbttyDyJ66N+0/buJ34BR7eaaA45Hkl7qadfzE2VQAZzG5xP9sta9zRvoKTGBJHro7eHXD+cA==","mode":420,"size":93},"index.js":{"checkedAt":1678883672270,"integrity":"sha512-PpSmz/Avu7KWcB+Xn3m2Wu/WTFGnYZvUfcoht6Q2HiCao9HV19FL6G72EEOh3NpQcZWfBP6RlKat/fr9ytNkMg==","mode":420,"size":407},"LICENSE":{"checkedAt":1678883672270,"integrity":"sha512-VjzuMZnrO+c+8UVnuezGZlEM8Ae3aLTlPsK1+EuOCRUAclhQEsvBhuKCr0nf6OKxTTAf0OPGcFoBV2ItQ4ChbA==","mode":420,"size":727},"README.md":{"checkedAt":1678883672270,"integrity":"sha512-TOLBxqD6UCNFMwZ66MoSBy01P6PtYwLQwARS0xhxO8V2BBFJM8t3wa/3ek1B8z2rHHLkU67BxUCNAzXxdjJEmQ==","mode":420,"size":844},"test/index.js":{"checkedAt":1678883672270,"integrity":"sha512-SVCtTGyBr+EKHFaWpf2wVvgmGVotu6lY62Etw6cn5QFWkB+V5GeBk29bi4S7+4qSZOwiEPvcl4wJ76ELO4wZPQ==","mode":420,"size":690}}}
|
||||
@@ -0,0 +1,195 @@
|
||||
Description
|
||||
===========
|
||||
|
||||
node-ftp is an FTP client module for [node.js](http://nodejs.org/) that provides an asynchronous interface for communicating with an FTP server.
|
||||
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
* [node.js](http://nodejs.org/) -- v0.8.0 or newer
|
||||
|
||||
|
||||
Install
|
||||
=======
|
||||
|
||||
npm install ftp
|
||||
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
* Get a directory listing of the current (remote) working directory:
|
||||
|
||||
```javascript
|
||||
var Client = require('ftp');
|
||||
|
||||
var c = new Client();
|
||||
c.on('ready', function() {
|
||||
c.list(function(err, list) {
|
||||
if (err) throw err;
|
||||
console.dir(list);
|
||||
c.end();
|
||||
});
|
||||
});
|
||||
// connect to localhost:21 as anonymous
|
||||
c.connect();
|
||||
```
|
||||
|
||||
* Download remote file 'foo.txt' and save it to the local file system:
|
||||
|
||||
```javascript
|
||||
var Client = require('ftp');
|
||||
var fs = require('fs');
|
||||
|
||||
var c = new Client();
|
||||
c.on('ready', function() {
|
||||
c.get('foo.txt', function(err, stream) {
|
||||
if (err) throw err;
|
||||
stream.once('close', function() { c.end(); });
|
||||
stream.pipe(fs.createWriteStream('foo.local-copy.txt'));
|
||||
});
|
||||
});
|
||||
// connect to localhost:21 as anonymous
|
||||
c.connect();
|
||||
```
|
||||
|
||||
* Upload local file 'foo.txt' to the server:
|
||||
|
||||
```javascript
|
||||
var Client = require('ftp');
|
||||
var fs = require('fs');
|
||||
|
||||
var c = new Client();
|
||||
c.on('ready', function() {
|
||||
c.put('foo.txt', 'foo.remote-copy.txt', function(err) {
|
||||
if (err) throw err;
|
||||
c.end();
|
||||
});
|
||||
});
|
||||
// connect to localhost:21 as anonymous
|
||||
c.connect();
|
||||
```
|
||||
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
Events
|
||||
------
|
||||
|
||||
* **greeting**(< _string_ >msg) - Emitted after connection. `msg` is the text the server sent upon connection.
|
||||
|
||||
* **ready**() - Emitted when connection and authentication were sucessful.
|
||||
|
||||
* **close**(< _boolean_ >hadErr) - Emitted when the connection has fully closed.
|
||||
|
||||
* **end**() - Emitted when the connection has ended.
|
||||
|
||||
* **error**(< _Error_ >err) - Emitted when an error occurs. In case of protocol-level errors, `err` contains a 'code' property that references the related 3-digit FTP response code.
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
**\* Note: As with the 'error' event, any error objects passed to callbacks will have a 'code' property for protocol-level errors.**
|
||||
|
||||
* **(constructor)**() - Creates and returns a new FTP client instance.
|
||||
|
||||
* **connect**(< _object_ >config) - _(void)_ - Connects to an FTP server. Valid config properties:
|
||||
|
||||
* host - _string_ - The hostname or IP address of the FTP server. **Default:** 'localhost'
|
||||
|
||||
* port - _integer_ - The port of the FTP server. **Default:** 21
|
||||
|
||||
* secure - _mixed_ - Set to true for both control and data connection encryption, 'control' for control connection encryption only, or 'implicit' for implicitly encrypted control connection (this mode is deprecated in modern times, but usually uses port 990) **Default:** false
|
||||
|
||||
* secureOptions - _object_ - Additional options to be passed to `tls.connect()`. **Default:** (none)
|
||||
|
||||
* user - _string_ - Username for authentication. **Default:** 'anonymous'
|
||||
|
||||
* password - _string_ - Password for authentication. **Default:** 'anonymous@'
|
||||
|
||||
* connTimeout - _integer_ - How long (in milliseconds) to wait for the control connection to be established. **Default:** 10000
|
||||
|
||||
* pasvTimeout - _integer_ - How long (in milliseconds) to wait for a PASV data connection to be established. **Default:** 10000
|
||||
|
||||
* keepalive - _integer_ - How often (in milliseconds) to send a 'dummy' (NOOP) command to keep the connection alive. **Default:** 10000
|
||||
|
||||
* **end**() - _(void)_ - Closes the connection to the server after any/all enqueued commands have been executed.
|
||||
|
||||
* **destroy**() - _(void)_ - Closes the connection to the server immediately.
|
||||
|
||||
### Required "standard" commands (RFC 959)
|
||||
|
||||
* **list**([< _string_ >path, ][< _boolean_ >useCompression, ]< _function_ >callback) - _(void)_ - Retrieves the directory listing of `path`. `path` defaults to the current working directory. `useCompression` defaults to false. `callback` has 2 parameters: < _Error_ >err, < _array_ >list. `list` is an array of objects with these properties:
|
||||
|
||||
* type - _string_ - A single character denoting the entry type: 'd' for directory, '-' for file (or 'l' for symlink on **\*NIX only**).
|
||||
|
||||
* name - _string_ - The name of the entry.
|
||||
|
||||
* size - _string_ - The size of the entry in bytes.
|
||||
|
||||
* date - _Date_ - The last modified date of the entry.
|
||||
|
||||
* rights - _object_ - The various permissions for this entry **(*NIX only)**.
|
||||
|
||||
* user - _string_ - An empty string or any combination of 'r', 'w', 'x'.
|
||||
|
||||
* group - _string_ - An empty string or any combination of 'r', 'w', 'x'.
|
||||
|
||||
* other - _string_ - An empty string or any combination of 'r', 'w', 'x'.
|
||||
|
||||
* owner - _string_ - The user name or ID that this entry belongs to **(*NIX only)**.
|
||||
|
||||
* group - _string_ - The group name or ID that this entry belongs to **(*NIX only)**.
|
||||
|
||||
* target - _string_ - For symlink entries, this is the symlink's target **(*NIX only)**.
|
||||
|
||||
* sticky - _boolean_ - True if the sticky bit is set for this entry **(*NIX only)**.
|
||||
|
||||
* **get**(< _string_ >path, [< _boolean_ >useCompression, ]< _function_ >callback) - _(void)_ - Retrieves a file at `path` from the server. `useCompression` defaults to false. `callback` has 2 parameters: < _Error_ >err, < _ReadableStream_ >fileStream.
|
||||
|
||||
* **put**(< _mixed_ >input, < _string_ >destPath, [< _boolean_ >useCompression, ]< _function_ >callback) - _(void)_ - Sends data to the server to be stored as `destPath`. `input` can be a ReadableStream, a Buffer, or a path to a local file. `useCompression` defaults to false. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **append**(< _mixed_ >input, < _string_ >destPath, [< _boolean_ >useCompression, ]< _function_ >callback) - _(void)_ - Same as **put()**, except if `destPath` already exists, it will be appended to instead of overwritten.
|
||||
|
||||
* **rename**(< _string_ >oldPath, < _string_ >newPath, < _function_ >callback) - _(void)_ - Renames `oldPath` to `newPath` on the server. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **logout**(< _function_ >callback) - _(void)_ - Logout the user from the server. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **delete**(< _string_ >path, < _function_ >callback) - _(void)_ - Deletes a file, `path`, on the server. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **cwd**(< _string_ >path, < _function_ >callback) - _(void)_ - Changes the current working directory to `path`. `callback` has 2 parameters: < _Error_ >err, < _string_ >currentDir. Note: `currentDir` is only given if the server replies with the path in the response text.
|
||||
|
||||
* **abort**(< _function_ >callback) - _(void)_ - Aborts the current data transfer (e.g. from get(), put(), or list()). `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **site**(< _string_ >command, < _function_ >callback) - _(void)_ - Sends `command` (e.g. 'CHMOD 755 foo', 'QUOTA') using SITE. `callback` has 3 parameters: < _Error_ >err, < _string >responseText, < _integer_ >responseCode.
|
||||
|
||||
* **status**(< _function_ >callback) - _(void)_ - Retrieves human-readable information about the server's status. `callback` has 2 parameters: < _Error_ >err, < _string_ >status.
|
||||
|
||||
* **ascii**(< _function_ >callback) - _(void)_ - Sets the transfer data type to ASCII. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **binary**(< _function_ >callback) - _(void)_ - Sets the transfer data type to binary (default at time of connection). `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
### Optional "standard" commands (RFC 959)
|
||||
|
||||
* **mkdir**(< _string_ >path, [< _boolean_ >recursive, ]< _function_ >callback) - _(void)_ - Creates a new directory, `path`, on the server. `recursive` is for enabling a 'mkdir -p' algorithm and defaults to false. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **rmdir**(< _string_ >path, [< _boolean_ >recursive, ]< _function_ >callback) - _(void)_ - Removes a directory, `path`, on the server. If `recursive`, this call will delete the contents of the directory if it is not empty. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **cdup**(< _function_ >callback) - _(void)_ - Changes the working directory to the parent of the current directory. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **pwd**(< _function_ >callback) - _(void)_ - Retrieves the current working directory. `callback` has 2 parameters: < _Error_ >err, < _string_ >cwd.
|
||||
|
||||
* **system**(< _function_ >callback) - _(void)_ - Retrieves the server's operating system. `callback` has 2 parameters: < _Error_ >err, < _string_ >OS.
|
||||
|
||||
* **listSafe**([< _string_ >path, ][< _boolean_ >useCompression, ]< _function_ >callback) - _(void)_ - Similar to list(), except the directory is temporarily changed to `path` to retrieve the directory listing. This is useful for servers that do not handle characters like spaces and quotes in directory names well for the LIST command. This function is "optional" because it relies on pwd() being available.
|
||||
|
||||
### Extended commands (RFC 3659)
|
||||
|
||||
* **size**(< _string_ >path, < _function_ >callback) - _(void)_ - Retrieves the size of `path`. `callback` has 2 parameters: < _Error_ >err, < _integer_ >numBytes.
|
||||
|
||||
* **lastMod**(< _string_ >path, < _function_ >callback) - _(void)_ - Retrieves the last modified date and time for `path`. `callback` has 2 parameters: < _Error_ >err, < _Date_ >lastModified.
|
||||
|
||||
* **restart**(< _integer_ >byteOffset, < _function_ >callback) - _(void)_ - Sets the file byte offset for the next file transfer action (get/put) to `byteOffset`. `callback` has 1 parameter: < _Error_ >err.
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').sortByLimit;
|
||||
@@ -0,0 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v1.0.0 - 2022-04-14
|
||||
|
||||
### Commits
|
||||
|
||||
- Initial implementation, tests [`303559f`](https://github.com/inspect-js/has-property-descriptors/commit/303559f2a72dfe7111573a1aec475ed4a184c35a)
|
||||
- Initial commit [`3a7ca2d`](https://github.com/inspect-js/has-property-descriptors/commit/3a7ca2dc49f1fff0279a28bb16265e7615e14749)
|
||||
- read me [`dd73dce`](https://github.com/inspect-js/has-property-descriptors/commit/dd73dce09d89d0f7a4a6e3b1e562a506f979a767)
|
||||
- npm init [`c1e6557`](https://github.com/inspect-js/has-property-descriptors/commit/c1e655779de632d68cb944c50da6b71bcb7b8c85)
|
||||
- Only apps should have lockfiles [`e72f7c6`](https://github.com/inspect-js/has-property-descriptors/commit/e72f7c68de534b2d273ee665f8b18d4ecc7f70b0)
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"skipUntil.js","sourceRoot":"","sources":["../../../../src/internal/operators/skipUntil.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AA+CpC,MAAM,UAAU,SAAS,CAAI,QAA8B;IACzD,OAAO,OAAO,CAAC,UAAC,MAAM,EAAE,UAAU;QAChC,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAM,cAAc,GAAG,wBAAwB,CAC7C,UAAU,EACV;YACE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,EAAE,CAAC;YAC9B,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC,EACD,IAAI,CACL,CAAC;QAEF,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAE9C,MAAM,CAAC,SAAS,CAAC,wBAAwB,CAAC,UAAU,EAAE,UAAC,KAAK,IAAK,OAAA,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAhC,CAAgC,CAAC,CAAC,CAAC;IACtG,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,59 @@
|
||||
import {ArrayEntry, MapEntry, ObjectEntry, SetEntry} from './entry';
|
||||
|
||||
type ArrayEntries<BaseType extends readonly unknown[]> = Array<ArrayEntry<BaseType>>;
|
||||
type MapEntries<BaseType> = Array<MapEntry<BaseType>>;
|
||||
type ObjectEntries<BaseType> = Array<ObjectEntry<BaseType>>;
|
||||
type SetEntries<BaseType extends Set<unknown>> = Array<SetEntry<BaseType>>;
|
||||
|
||||
/**
|
||||
Many collections have an `entries` method which returns an array of a given object's own enumerable string-keyed property [key, value] pairs. The `Entries` type will return the type of that collection's entries.
|
||||
|
||||
For example the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries|`Object`}, {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries|`Map`}, {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries|`Array`}, and {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries|`Set`} collections all have this method. Note that `WeakMap` and `WeakSet` do not have this method since their entries are not enumerable.
|
||||
|
||||
@see `Entry` if you want to just access the type of a single entry.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Entries} from 'type-fest';
|
||||
|
||||
interface Example {
|
||||
someKey: number;
|
||||
}
|
||||
|
||||
const manipulatesEntries = (examples: Entries<Example>) => examples.map(example => [
|
||||
// Does some arbitrary processing on the key (with type information available)
|
||||
example[0].toUpperCase(),
|
||||
|
||||
// Does some arbitrary processing on the value (with type information available)
|
||||
example[1].toFixed()
|
||||
]);
|
||||
|
||||
const example: Example = {someKey: 1};
|
||||
const entries = Object.entries(example) as Entries<Example>;
|
||||
const output = manipulatesEntries(entries);
|
||||
|
||||
// Objects
|
||||
const objectExample = {a: 1};
|
||||
const objectEntries: Entries<typeof objectExample> = [['a', 1]];
|
||||
|
||||
// Arrays
|
||||
const arrayExample = ['a', 1];
|
||||
const arrayEntries: Entries<typeof arrayExample> = [[0, 'a'], [1, 1]];
|
||||
|
||||
// Maps
|
||||
const mapExample = new Map([['a', 1]]);
|
||||
const mapEntries: Entries<typeof map> = [['a', 1]];
|
||||
|
||||
// Sets
|
||||
const setExample = new Set(['a', 1]);
|
||||
const setEntries: Entries<typeof setExample> = [['a', 'a'], [1, 1]];
|
||||
```
|
||||
|
||||
@category Utilities
|
||||
*/
|
||||
export type Entries<BaseType> =
|
||||
BaseType extends Map<unknown, unknown> ? MapEntries<BaseType>
|
||||
: BaseType extends Set<unknown> ? SetEntries<BaseType>
|
||||
: BaseType extends unknown[] ? ArrayEntries<BaseType>
|
||||
: BaseType extends object ? ObjectEntries<BaseType>
|
||||
: never;
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.endWith = void 0;
|
||||
var concat_1 = require("../observable/concat");
|
||||
var of_1 = require("../observable/of");
|
||||
function endWith() {
|
||||
var values = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
values[_i] = arguments[_i];
|
||||
}
|
||||
return function (source) { return concat_1.concat(source, of_1.of.apply(void 0, __spreadArray([], __read(values)))); };
|
||||
}
|
||||
exports.endWith = endWith;
|
||||
//# sourceMappingURL=endWith.js.map
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('ceil', require('../ceil'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,44 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f',
|
||||
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
|
||||
/**
|
||||
* Gets the size of a Unicode `string`.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string inspect.
|
||||
* @returns {number} Returns the string size.
|
||||
*/
|
||||
function unicodeSize(string) {
|
||||
var result = reUnicode.lastIndex = 0;
|
||||
while (reUnicode.test(string)) {
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = unicodeSize;
|
||||
@@ -0,0 +1,6 @@
|
||||
import { y18n as _y18n } from './index.js';
|
||||
import nodePlatformShim from './platform-shims/node.js';
|
||||
const y18n = (opts) => {
|
||||
return _y18n(opts, nodePlatformShim);
|
||||
};
|
||||
export default y18n;
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Overwrites default Mousetrap.bind method to optionally accept
|
||||
* an object to bind multiple key events in a single call
|
||||
*
|
||||
* You can pass it in like:
|
||||
*
|
||||
* Mousetrap.bind({
|
||||
* 'a': function() { console.log('a'); },
|
||||
* 'b': function() { console.log('b'); }
|
||||
* });
|
||||
*
|
||||
* And can optionally pass in 'keypress', 'keydown', or 'keyup'
|
||||
* as a second argument
|
||||
*
|
||||
*/
|
||||
/* global Mousetrap:true */
|
||||
(function(Mousetrap) {
|
||||
var _oldBind = Mousetrap.prototype.bind;
|
||||
var args;
|
||||
|
||||
Mousetrap.prototype.bind = function() {
|
||||
var self = this;
|
||||
args = arguments;
|
||||
|
||||
// normal call
|
||||
if (typeof args[0] == 'string' || args[0] instanceof Array) {
|
||||
return _oldBind.call(self, args[0], args[1], args[2]);
|
||||
}
|
||||
|
||||
// object passed in
|
||||
for (var key in args[0]) {
|
||||
if (args[0].hasOwnProperty(key)) {
|
||||
_oldBind.call(self, key, args[0][key], args[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Mousetrap.init();
|
||||
}) (Mousetrap);
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var isRegExp = require("./is-reg-exp");
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isRegExp(value)) throw new TypeError(value + " is not a RegExp object");
|
||||
return value;
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var getEol_1 = __importDefault(require("./getEol"));
|
||||
// const getEol = require("./getEol");
|
||||
/**
|
||||
* convert data chunk to file lines array
|
||||
* @param {string} data data chunk as utf8 string
|
||||
* @param {object} param Converter param object
|
||||
* @return {Object} {lines:[line1,line2...],partial:String}
|
||||
*/
|
||||
function stringToLines(data, param) {
|
||||
var eol = getEol_1.default(data, param);
|
||||
var lines = data.split(eol);
|
||||
var partial = lines.pop() || "";
|
||||
return { lines: lines, partial: partial };
|
||||
}
|
||||
exports.stringToLines = stringToLines;
|
||||
;
|
||||
//# sourceMappingURL=fileline.js.map
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var semver = require('semver');
|
||||
|
||||
var supportsPreserveSymlinks = require('../');
|
||||
var browser = require('../browser');
|
||||
|
||||
test('supportsPreserveSymlinks', function (t) {
|
||||
t.equal(typeof supportsPreserveSymlinks, 'boolean', 'is a boolean');
|
||||
|
||||
t.equal(browser, null, 'browser file is `null`');
|
||||
t.equal(
|
||||
supportsPreserveSymlinks,
|
||||
null,
|
||||
'in a browser, is null',
|
||||
{ skip: typeof window === 'undefined' }
|
||||
);
|
||||
|
||||
var expected = semver.satisfies(process.version, '>= 6.2');
|
||||
t.equal(
|
||||
supportsPreserveSymlinks,
|
||||
expected,
|
||||
'is true in node v6.2+, false otherwise (actual: ' + supportsPreserveSymlinks + ', expected ' + expected + ')',
|
||||
{ skip: typeof window !== 'undefined' }
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,20 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 120
|
||||
|
||||
[CHANGELOG.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
max_line_length = off
|
||||
|
||||
[Makefile]
|
||||
max_line_length = off
|
||||
@@ -0,0 +1,5 @@
|
||||
export type CreateScanStation = {
|
||||
description?: string;
|
||||
track: number;
|
||||
enabled?: boolean;
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
var current = (process.versions && process.versions.node && process.versions.node.split('.')) || [];
|
||||
|
||||
function specifierIncluded(specifier) {
|
||||
var parts = specifier.split(' ');
|
||||
var op = parts.length > 1 ? parts[0] : '=';
|
||||
var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
|
||||
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var cur = parseInt(current[i] || 0, 10);
|
||||
var ver = parseInt(versionParts[i] || 0, 10);
|
||||
if (cur === ver) {
|
||||
continue; // eslint-disable-line no-restricted-syntax, no-continue
|
||||
}
|
||||
if (op === '<') {
|
||||
return cur < ver;
|
||||
} else if (op === '>=') {
|
||||
return cur >= ver;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return op === '>=';
|
||||
}
|
||||
|
||||
function matchesRange(range) {
|
||||
var specifiers = range.split(/ ?&& ?/);
|
||||
if (specifiers.length === 0) { return false; }
|
||||
for (var i = 0; i < specifiers.length; ++i) {
|
||||
if (!specifierIncluded(specifiers[i])) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function versionIncluded(specifierValue) {
|
||||
if (typeof specifierValue === 'boolean') { return specifierValue; }
|
||||
if (specifierValue && typeof specifierValue === 'object') {
|
||||
for (var i = 0; i < specifierValue.length; ++i) {
|
||||
if (matchesRange(specifierValue[i])) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return matchesRange(specifierValue);
|
||||
}
|
||||
|
||||
var data = require('./core.json');
|
||||
|
||||
var core = {};
|
||||
for (var mod in data) { // eslint-disable-line no-restricted-syntax
|
||||
if (Object.prototype.hasOwnProperty.call(data, mod)) {
|
||||
core[mod] = versionIncluded(data[mod]);
|
||||
}
|
||||
}
|
||||
module.exports = core;
|
||||
@@ -0,0 +1,409 @@
|
||||
var feature = require('caniuse-lite/dist/unpacker/feature').default
|
||||
var region = require('caniuse-lite/dist/unpacker/region').default
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
|
||||
var BrowserslistError = require('./error')
|
||||
|
||||
var IS_SECTION = /^\s*\[(.+)]\s*$/
|
||||
var CONFIG_PATTERN = /^browserslist-config-/
|
||||
var SCOPED_CONFIG__PATTERN = /@[^/]+\/browserslist-config(-|$|\/)/
|
||||
var TIME_TO_UPDATE_CANIUSE = 6 * 30 * 24 * 60 * 60 * 1000
|
||||
var FORMAT =
|
||||
'Browserslist config should be a string or an array ' +
|
||||
'of strings with browser queries'
|
||||
|
||||
var dataTimeChecked = false
|
||||
var filenessCache = {}
|
||||
var configCache = {}
|
||||
function checkExtend(name) {
|
||||
var use = ' Use `dangerousExtend` option to disable.'
|
||||
if (!CONFIG_PATTERN.test(name) && !SCOPED_CONFIG__PATTERN.test(name)) {
|
||||
throw new BrowserslistError(
|
||||
'Browserslist config needs `browserslist-config-` prefix. ' + use
|
||||
)
|
||||
}
|
||||
if (name.replace(/^@[^/]+\//, '').indexOf('.') !== -1) {
|
||||
throw new BrowserslistError(
|
||||
'`.` not allowed in Browserslist config name. ' + use
|
||||
)
|
||||
}
|
||||
if (name.indexOf('node_modules') !== -1) {
|
||||
throw new BrowserslistError(
|
||||
'`node_modules` not allowed in Browserslist config.' + use
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function isFile(file) {
|
||||
if (file in filenessCache) {
|
||||
return filenessCache[file]
|
||||
}
|
||||
var result = fs.existsSync(file) && fs.statSync(file).isFile()
|
||||
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
|
||||
filenessCache[file] = result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function eachParent(file, callback) {
|
||||
var dir = isFile(file) ? path.dirname(file) : file
|
||||
var loc = path.resolve(dir)
|
||||
do {
|
||||
var result = callback(loc)
|
||||
if (typeof result !== 'undefined') return result
|
||||
} while (loc !== (loc = path.dirname(loc)))
|
||||
return undefined
|
||||
}
|
||||
|
||||
function check(section) {
|
||||
if (Array.isArray(section)) {
|
||||
for (var i = 0; i < section.length; i++) {
|
||||
if (typeof section[i] !== 'string') {
|
||||
throw new BrowserslistError(FORMAT)
|
||||
}
|
||||
}
|
||||
} else if (typeof section !== 'string') {
|
||||
throw new BrowserslistError(FORMAT)
|
||||
}
|
||||
}
|
||||
|
||||
function pickEnv(config, opts) {
|
||||
if (typeof config !== 'object') return config
|
||||
|
||||
var name
|
||||
if (typeof opts.env === 'string') {
|
||||
name = opts.env
|
||||
} else if (process.env.BROWSERSLIST_ENV) {
|
||||
name = process.env.BROWSERSLIST_ENV
|
||||
} else if (process.env.NODE_ENV) {
|
||||
name = process.env.NODE_ENV
|
||||
} else {
|
||||
name = 'production'
|
||||
}
|
||||
|
||||
if (opts.throwOnMissing) {
|
||||
if (name && name !== 'defaults' && !config[name]) {
|
||||
throw new BrowserslistError(
|
||||
'Missing config for Browserslist environment `' + name + '`'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return config[name] || config.defaults
|
||||
}
|
||||
|
||||
function parsePackage(file) {
|
||||
var config = JSON.parse(
|
||||
fs
|
||||
.readFileSync(file)
|
||||
.toString()
|
||||
.replace(/^\uFEFF/m, '')
|
||||
)
|
||||
if (config.browserlist && !config.browserslist) {
|
||||
throw new BrowserslistError(
|
||||
'`browserlist` key instead of `browserslist` in ' + file
|
||||
)
|
||||
}
|
||||
var list = config.browserslist
|
||||
if (Array.isArray(list) || typeof list === 'string') {
|
||||
list = { defaults: list }
|
||||
}
|
||||
for (var i in list) {
|
||||
check(list[i])
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
function latestReleaseTime(agents) {
|
||||
var latest = 0
|
||||
for (var name in agents) {
|
||||
var dates = agents[name].releaseDate || {}
|
||||
for (var key in dates) {
|
||||
if (latest < dates[key]) {
|
||||
latest = dates[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
return latest * 1000
|
||||
}
|
||||
|
||||
function normalizeStats(data, stats) {
|
||||
if (!data) {
|
||||
data = {}
|
||||
}
|
||||
if (stats && 'dataByBrowser' in stats) {
|
||||
stats = stats.dataByBrowser
|
||||
}
|
||||
|
||||
if (typeof stats !== 'object') return undefined
|
||||
|
||||
var normalized = {}
|
||||
for (var i in stats) {
|
||||
var versions = Object.keys(stats[i])
|
||||
if (versions.length === 1 && data[i] && data[i].versions.length === 1) {
|
||||
var normal = data[i].versions[0]
|
||||
normalized[i] = {}
|
||||
normalized[i][normal] = stats[i][versions[0]]
|
||||
} else {
|
||||
normalized[i] = stats[i]
|
||||
}
|
||||
}
|
||||
|
||||
return normalized
|
||||
}
|
||||
|
||||
function normalizeUsageData(usageData, data) {
|
||||
for (var browser in usageData) {
|
||||
var browserUsage = usageData[browser]
|
||||
// eslint-disable-next-line max-len
|
||||
// https://github.com/browserslist/browserslist/issues/431#issuecomment-565230615
|
||||
// caniuse-db returns { 0: "percentage" } for `and_*` regional stats
|
||||
if ('0' in browserUsage) {
|
||||
var versions = data[browser].versions
|
||||
browserUsage[versions[versions.length - 1]] = browserUsage[0]
|
||||
delete browserUsage[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
loadQueries: function loadQueries(ctx, name) {
|
||||
if (!ctx.dangerousExtend && !process.env.BROWSERSLIST_DANGEROUS_EXTEND) {
|
||||
checkExtend(name)
|
||||
}
|
||||
var queries = require(require.resolve(name, { paths: ['.', ctx.path] }))
|
||||
if (queries) {
|
||||
if (Array.isArray(queries)) {
|
||||
return queries
|
||||
} else if (typeof queries === 'object') {
|
||||
if (!queries.defaults) queries.defaults = []
|
||||
return pickEnv(queries, ctx, name)
|
||||
}
|
||||
}
|
||||
throw new BrowserslistError(
|
||||
'`' +
|
||||
name +
|
||||
'` config exports not an array of queries' +
|
||||
' or an object of envs'
|
||||
)
|
||||
},
|
||||
|
||||
loadStat: function loadStat(ctx, name, data) {
|
||||
if (!ctx.dangerousExtend && !process.env.BROWSERSLIST_DANGEROUS_EXTEND) {
|
||||
checkExtend(name)
|
||||
}
|
||||
var stats = require(require.resolve(
|
||||
path.join(name, 'browserslist-stats.json'),
|
||||
{ paths: ['.'] }
|
||||
))
|
||||
return normalizeStats(data, stats)
|
||||
},
|
||||
|
||||
getStat: function getStat(opts, data) {
|
||||
var stats
|
||||
if (opts.stats) {
|
||||
stats = opts.stats
|
||||
} else if (process.env.BROWSERSLIST_STATS) {
|
||||
stats = process.env.BROWSERSLIST_STATS
|
||||
} else if (opts.path && path.resolve && fs.existsSync) {
|
||||
stats = eachParent(opts.path, function (dir) {
|
||||
var file = path.join(dir, 'browserslist-stats.json')
|
||||
return isFile(file) ? file : undefined
|
||||
})
|
||||
}
|
||||
if (typeof stats === 'string') {
|
||||
try {
|
||||
stats = JSON.parse(fs.readFileSync(stats))
|
||||
} catch (e) {
|
||||
throw new BrowserslistError("Can't read " + stats)
|
||||
}
|
||||
}
|
||||
return normalizeStats(data, stats)
|
||||
},
|
||||
|
||||
loadConfig: function loadConfig(opts) {
|
||||
if (process.env.BROWSERSLIST) {
|
||||
return process.env.BROWSERSLIST
|
||||
} else if (opts.config || process.env.BROWSERSLIST_CONFIG) {
|
||||
var file = opts.config || process.env.BROWSERSLIST_CONFIG
|
||||
if (path.basename(file) === 'package.json') {
|
||||
return pickEnv(parsePackage(file), opts)
|
||||
} else {
|
||||
return pickEnv(module.exports.readConfig(file), opts)
|
||||
}
|
||||
} else if (opts.path) {
|
||||
return pickEnv(module.exports.findConfig(opts.path), opts)
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
},
|
||||
|
||||
loadCountry: function loadCountry(usage, country, data) {
|
||||
var code = country.replace(/[^\w-]/g, '')
|
||||
if (!usage[code]) {
|
||||
var compressed
|
||||
try {
|
||||
compressed = require('caniuse-lite/data/regions/' + code + '.js')
|
||||
} catch (e) {
|
||||
throw new BrowserslistError('Unknown region name `' + code + '`.')
|
||||
}
|
||||
var usageData = region(compressed)
|
||||
normalizeUsageData(usageData, data)
|
||||
usage[country] = {}
|
||||
for (var i in usageData) {
|
||||
for (var j in usageData[i]) {
|
||||
usage[country][i + ' ' + j] = usageData[i][j]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
loadFeature: function loadFeature(features, name) {
|
||||
name = name.replace(/[^\w-]/g, '')
|
||||
if (features[name]) return
|
||||
var compressed
|
||||
try {
|
||||
compressed = require('caniuse-lite/data/features/' + name + '.js')
|
||||
} catch (e) {
|
||||
throw new BrowserslistError('Unknown feature name `' + name + '`.')
|
||||
}
|
||||
var stats = feature(compressed).stats
|
||||
features[name] = {}
|
||||
for (var i in stats) {
|
||||
for (var j in stats[i]) {
|
||||
features[name][i + ' ' + j] = stats[i][j]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseConfig: function parseConfig(string) {
|
||||
var result = { defaults: [] }
|
||||
var sections = ['defaults']
|
||||
|
||||
string
|
||||
.toString()
|
||||
.replace(/#[^\n]*/g, '')
|
||||
.split(/\n|,/)
|
||||
.map(function (line) {
|
||||
return line.trim()
|
||||
})
|
||||
.filter(function (line) {
|
||||
return line !== ''
|
||||
})
|
||||
.forEach(function (line) {
|
||||
if (IS_SECTION.test(line)) {
|
||||
sections = line.match(IS_SECTION)[1].trim().split(' ')
|
||||
sections.forEach(function (section) {
|
||||
if (result[section]) {
|
||||
throw new BrowserslistError(
|
||||
'Duplicate section ' + section + ' in Browserslist config'
|
||||
)
|
||||
}
|
||||
result[section] = []
|
||||
})
|
||||
} else {
|
||||
sections.forEach(function (section) {
|
||||
result[section].push(line)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
readConfig: function readConfig(file) {
|
||||
if (!isFile(file)) {
|
||||
throw new BrowserslistError("Can't read " + file + ' config')
|
||||
}
|
||||
return module.exports.parseConfig(fs.readFileSync(file))
|
||||
},
|
||||
|
||||
findConfig: function findConfig(from) {
|
||||
from = path.resolve(from)
|
||||
|
||||
var passed = []
|
||||
var resolved = eachParent(from, function (dir) {
|
||||
if (dir in configCache) {
|
||||
return configCache[dir]
|
||||
}
|
||||
|
||||
passed.push(dir)
|
||||
|
||||
var config = path.join(dir, 'browserslist')
|
||||
var pkg = path.join(dir, 'package.json')
|
||||
var rc = path.join(dir, '.browserslistrc')
|
||||
|
||||
var pkgBrowserslist
|
||||
if (isFile(pkg)) {
|
||||
try {
|
||||
pkgBrowserslist = parsePackage(pkg)
|
||||
} catch (e) {
|
||||
if (e.name === 'BrowserslistError') throw e
|
||||
console.warn(
|
||||
'[Browserslist] Could not parse ' + pkg + '. Ignoring it.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (isFile(config) && pkgBrowserslist) {
|
||||
throw new BrowserslistError(
|
||||
dir + ' contains both browserslist and package.json with browsers'
|
||||
)
|
||||
} else if (isFile(rc) && pkgBrowserslist) {
|
||||
throw new BrowserslistError(
|
||||
dir + ' contains both .browserslistrc and package.json with browsers'
|
||||
)
|
||||
} else if (isFile(config) && isFile(rc)) {
|
||||
throw new BrowserslistError(
|
||||
dir + ' contains both .browserslistrc and browserslist'
|
||||
)
|
||||
} else if (isFile(config)) {
|
||||
return module.exports.readConfig(config)
|
||||
} else if (isFile(rc)) {
|
||||
return module.exports.readConfig(rc)
|
||||
} else {
|
||||
return pkgBrowserslist
|
||||
}
|
||||
})
|
||||
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
|
||||
passed.forEach(function (dir) {
|
||||
configCache[dir] = resolved
|
||||
})
|
||||
}
|
||||
return resolved
|
||||
},
|
||||
|
||||
clearCaches: function clearCaches() {
|
||||
dataTimeChecked = false
|
||||
filenessCache = {}
|
||||
configCache = {}
|
||||
|
||||
this.cache = {}
|
||||
},
|
||||
|
||||
oldDataWarning: function oldDataWarning(agentsObj) {
|
||||
if (dataTimeChecked) return
|
||||
dataTimeChecked = true
|
||||
if (process.env.BROWSERSLIST_IGNORE_OLD_DATA) return
|
||||
|
||||
var latest = latestReleaseTime(agentsObj)
|
||||
var halfYearAgo = Date.now() - TIME_TO_UPDATE_CANIUSE
|
||||
|
||||
if (latest !== 0 && latest < halfYearAgo) {
|
||||
console.warn(
|
||||
'Browserslist: caniuse-lite is outdated. Please run:\n' +
|
||||
' npx update-browserslist-db@latest\n' +
|
||||
' Why you should do it regularly: ' +
|
||||
'https://github.com/browserslist/update-db#readme'
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
currentNode: function currentNode() {
|
||||
return 'node ' + process.versions.node
|
||||
},
|
||||
|
||||
env: process.env
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
// node 0.10 doesn't have a prototype method
|
||||
var $byteOffset = callBound('TypedArray.prototype.byteOffset', true) || function (x) { return x.byteOffset; };
|
||||
|
||||
var ToIndex = require('./ToIndex');
|
||||
var TypedArrayElementSize = require('./TypedArrayElementSize');
|
||||
|
||||
var isTypedArray = require('is-typed-array');
|
||||
var typedArrayLength = require('typed-array-length');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-validateatomicaccess
|
||||
|
||||
module.exports = function ValidateAtomicAccess(typedArray, requestIndex) {
|
||||
if (!isTypedArray(typedArray)) {
|
||||
throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray');
|
||||
}
|
||||
|
||||
var length = typedArrayLength(typedArray); // step 1
|
||||
|
||||
var accessIndex = ToIndex(requestIndex); // step 2
|
||||
|
||||
/*
|
||||
// this assertion can never be reached
|
||||
if (!(accessIndex >= 0)) {
|
||||
throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4
|
||||
}
|
||||
*/
|
||||
|
||||
if (accessIndex >= length) {
|
||||
throw new $RangeError('index out of range'); // step 4
|
||||
}
|
||||
|
||||
var elementSize = TypedArrayElementSize(typedArray); // step 5
|
||||
|
||||
var offset = $byteOffset(typedArray); // step 6
|
||||
|
||||
return (accessIndex * elementSize) + offset; // step 7
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
var baseFlatten = require('./_baseFlatten'),
|
||||
map = require('./map');
|
||||
|
||||
/**
|
||||
* Creates a flattened array of values by running each element in `collection`
|
||||
* thru `iteratee` and flattening the mapped results. The iteratee is invoked
|
||||
* with three arguments: (value, index|key, collection).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Collection
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* function duplicate(n) {
|
||||
* return [n, n];
|
||||
* }
|
||||
*
|
||||
* _.flatMap([1, 2], duplicate);
|
||||
* // => [1, 1, 2, 2]
|
||||
*/
|
||||
function flatMap(collection, iteratee) {
|
||||
return baseFlatten(map(collection, iteratee), 1);
|
||||
}
|
||||
|
||||
module.exports = flatMap;
|
||||
Reference in New Issue
Block a user