new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# string-width
|
||||
|
||||
> Get the visual width of a string - the number of columns required to display it
|
||||
|
||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||
|
||||
Useful to be able to measure the actual width of command-line output.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install string-width
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stringWidth = require('string-width');
|
||||
|
||||
stringWidth('a');
|
||||
//=> 1
|
||||
|
||||
stringWidth('古');
|
||||
//=> 2
|
||||
|
||||
stringWidth('\u001B[1m古\u001B[22m');
|
||||
//=> 2
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
||||
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
||||
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-string-width?utm_source=npm-string-width&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
Copyright 2018 Kilian Valkhof
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
var util = require("./util");
|
||||
var schedule;
|
||||
var noAsyncScheduler = function() {
|
||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
};
|
||||
var NativePromise = util.getNativePromise();
|
||||
if (util.isNode && typeof MutationObserver === "undefined") {
|
||||
var GlobalSetImmediate = global.setImmediate;
|
||||
var ProcessNextTick = process.nextTick;
|
||||
schedule = util.isRecentNode
|
||||
? function(fn) { GlobalSetImmediate.call(global, fn); }
|
||||
: function(fn) { ProcessNextTick.call(process, fn); };
|
||||
} else if (typeof NativePromise === "function" &&
|
||||
typeof NativePromise.resolve === "function") {
|
||||
var nativePromise = NativePromise.resolve();
|
||||
schedule = function(fn) {
|
||||
nativePromise.then(fn);
|
||||
};
|
||||
} else if ((typeof MutationObserver !== "undefined") &&
|
||||
!(typeof window !== "undefined" &&
|
||||
window.navigator &&
|
||||
(window.navigator.standalone || window.cordova)) &&
|
||||
("classList" in document.documentElement)) {
|
||||
schedule = (function() {
|
||||
var div = document.createElement("div");
|
||||
var opts = {attributes: true};
|
||||
var toggleScheduled = false;
|
||||
var div2 = document.createElement("div");
|
||||
var o2 = new MutationObserver(function() {
|
||||
div.classList.toggle("foo");
|
||||
toggleScheduled = false;
|
||||
});
|
||||
o2.observe(div2, opts);
|
||||
|
||||
var scheduleToggle = function() {
|
||||
if (toggleScheduled) return;
|
||||
toggleScheduled = true;
|
||||
div2.classList.toggle("foo");
|
||||
};
|
||||
|
||||
return function schedule(fn) {
|
||||
var o = new MutationObserver(function() {
|
||||
o.disconnect();
|
||||
fn();
|
||||
});
|
||||
o.observe(div, opts);
|
||||
scheduleToggle();
|
||||
};
|
||||
})();
|
||||
} else if (typeof setImmediate !== "undefined") {
|
||||
schedule = function (fn) {
|
||||
setImmediate(fn);
|
||||
};
|
||||
} else if (typeof setTimeout !== "undefined") {
|
||||
schedule = function (fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
} else {
|
||||
schedule = noAsyncScheduler;
|
||||
}
|
||||
module.exports = schedule;
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@babel/helper-validator-identifier",
|
||||
"version": "7.19.1",
|
||||
"description": "Validate identifier/keywords name",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-validator-identifier"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": "./lib/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@unicode/unicode-15.0.0": "^1.3.1",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(require("es5-ext/global"), "WeakMap",
|
||||
{
|
||||
value: require("./polyfill"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { SchedulerLike } from '../types';
|
||||
export declare function bindNodeCallback(callbackFunc: (...args: any[]) => void, resultSelector: (...args: any[]) => any, scheduler?: SchedulerLike): (...args: any[]) => Observable<any>;
|
||||
export declare function bindNodeCallback<A extends readonly unknown[], R extends readonly unknown[]>(callbackFunc: (...args: [...A, (err: any, ...res: R) => void]) => void, schedulerLike?: SchedulerLike): (...arg: A) => Observable<R extends [] ? void : R extends [any] ? R[0] : R>;
|
||||
//# sourceMappingURL=bindNodeCallback.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M"},C:{"1":"RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB EC FC"},D:{"1":"GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB"},E:{"1":"B C K L G 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F A HC zB IC JC KC LC"},F:{"1":"3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 F B C G M N O w g x y z PC QC RC SC qB AC TC rB"},G:{"1":"cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC aC bC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","2":"AD"}},B:1,C:"Minimum length attribute for input fields"};
|
||||
@@ -0,0 +1,50 @@
|
||||
// @ts-check
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
export function init(args, configs) {
|
||||
let messages = []
|
||||
|
||||
let tailwindConfigLocation = path.resolve(args['_'][1] ?? `./${configs.tailwind}`)
|
||||
if (fs.existsSync(tailwindConfigLocation)) {
|
||||
messages.push(`${path.basename(tailwindConfigLocation)} already exists.`)
|
||||
} else {
|
||||
let stubFile = fs.readFileSync(
|
||||
args['--full']
|
||||
? path.resolve(__dirname, '../../../stubs/defaultConfig.stub.js')
|
||||
: path.resolve(__dirname, '../../../stubs/simpleConfig.stub.js'),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
// Change colors import
|
||||
stubFile = stubFile.replace('../colors', 'tailwindcss/colors')
|
||||
|
||||
fs.writeFileSync(tailwindConfigLocation, stubFile, 'utf8')
|
||||
|
||||
messages.push(`Created Tailwind CSS config file: ${path.basename(tailwindConfigLocation)}`)
|
||||
}
|
||||
|
||||
if (args['--postcss']) {
|
||||
let postcssConfigLocation = path.resolve(`./${configs.postcss}`)
|
||||
if (fs.existsSync(postcssConfigLocation)) {
|
||||
messages.push(`${path.basename(postcssConfigLocation)} already exists.`)
|
||||
} else {
|
||||
let stubFile = fs.readFileSync(
|
||||
path.resolve(__dirname, '../../../stubs/defaultPostCssConfig.stub.js'),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
fs.writeFileSync(postcssConfigLocation, stubFile, 'utf8')
|
||||
|
||||
messages.push(`Created PostCSS config file: ${path.basename(postcssConfigLocation)}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (messages.length > 0) {
|
||||
console.log()
|
||||
for (let message of messages) {
|
||||
console.log(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
MIT License Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,4 @@
|
||||
aa,bb
|
||||
ss,"12345
|
||||
6789,abcde""
|
||||
ddee"
|
||||
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
function joinPath(pathArray)
|
||||
{
|
||||
if (pathArray.length > 0)
|
||||
{
|
||||
return pathArray.join("/") + "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function resolveDotSegments(pathArray)
|
||||
{
|
||||
var pathAbsolute = [];
|
||||
|
||||
pathArray.forEach( function(dir)
|
||||
{
|
||||
if (dir !== "..")
|
||||
{
|
||||
if (dir !== ".")
|
||||
{
|
||||
pathAbsolute.push(dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove parent
|
||||
if (pathAbsolute.length > 0)
|
||||
{
|
||||
pathAbsolute.splice(pathAbsolute.length-1, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return pathAbsolute;
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports =
|
||||
{
|
||||
join: joinPath,
|
||||
resolveDotSegments: resolveDotSegments
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "copyWithin", {
|
||||
value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true node:true rhino:true */
|
||||
|
||||
var fs, esprima, fname, forceFile, content, options, syntax;
|
||||
|
||||
if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
try {
|
||||
esprima = require('esprima');
|
||||
} catch (e) {
|
||||
esprima = require('../');
|
||||
}
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = { argv: arguments, exit: quit };
|
||||
process.argv.unshift('esparse.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esparse [options] [file.js]');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --comment Gather all line and block comments in an array');
|
||||
console.log(' --loc Include line-column location info for each syntax node');
|
||||
console.log(' --range Include index-based range for each syntax node');
|
||||
console.log(' --raw Display the raw value of literals');
|
||||
console.log(' --tokens List all tokens in an array');
|
||||
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
|
||||
console.log(' -v, --version Shows program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
options = {};
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (forceFile || entry === '-' || entry.slice(0, 1) !== '-') {
|
||||
if (typeof fname === 'string') {
|
||||
console.log('Error: more than one input file.');
|
||||
process.exit(1);
|
||||
} else {
|
||||
fname = entry;
|
||||
}
|
||||
} else if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry === '--comment') {
|
||||
options.comment = true;
|
||||
} else if (entry === '--loc') {
|
||||
options.loc = true;
|
||||
} else if (entry === '--range') {
|
||||
options.range = true;
|
||||
} else if (entry === '--raw') {
|
||||
options.raw = true;
|
||||
} else if (entry === '--tokens') {
|
||||
options.tokens = true;
|
||||
} else if (entry === '--tolerant') {
|
||||
options.tolerant = true;
|
||||
} else if (entry === '--') {
|
||||
forceFile = true;
|
||||
} else {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
// Special handling for regular expression literal since we need to
|
||||
// convert it to a string literal, otherwise it will be decoded
|
||||
// as object "{}" and the regular expression would be lost.
|
||||
function adjustRegexLiteral(key, value) {
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function run(content) {
|
||||
syntax = esprima.parse(content, options);
|
||||
console.log(JSON.stringify(syntax, adjustRegexLiteral, 4));
|
||||
}
|
||||
|
||||
try {
|
||||
if (fname && (fname !== '-' || forceFile)) {
|
||||
run(fs.readFileSync(fname, 'utf-8'));
|
||||
} else {
|
||||
var content = '';
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', function(chunk) {
|
||||
content += chunk;
|
||||
});
|
||||
process.stdin.on('end', function() {
|
||||
run(content);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error: ' + e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import url from 'node:url';
|
||||
import path from 'node:path';
|
||||
import util from 'node:util';
|
||||
import { createRequire } from 'node:module';
|
||||
import _ from 'lodash';
|
||||
import Version from './version/Version.js';
|
||||
import Git from './git/Git.js';
|
||||
import GitLab from './gitlab/GitLab.js';
|
||||
import GitHub from './github/GitHub.js';
|
||||
import npm from './npm/npm.js';
|
||||
|
||||
const debug = util.debug('release-it:plugins');
|
||||
|
||||
const pluginNames = ['npm', 'git', 'github', 'gitlab', 'version'];
|
||||
|
||||
const plugins = {
|
||||
version: Version,
|
||||
git: Git,
|
||||
gitlab: GitLab,
|
||||
github: GitHub,
|
||||
npm: npm
|
||||
};
|
||||
|
||||
const load = async pluginName => {
|
||||
let plugin = null;
|
||||
try {
|
||||
const module = await import(pluginName);
|
||||
plugin = module.default;
|
||||
} catch (err) {
|
||||
try {
|
||||
const module = await import(path.join(process.cwd(), pluginName));
|
||||
plugin = module.default;
|
||||
} catch (err) {
|
||||
// In some cases or tests we might need to support legacy `require.resolve`
|
||||
const require = createRequire(process.cwd());
|
||||
const module = await import(url.pathToFileURL(require.resolve(pluginName, { paths: [process.cwd()] })));
|
||||
plugin = module.default;
|
||||
}
|
||||
}
|
||||
return [getPluginName(pluginName), plugin];
|
||||
};
|
||||
|
||||
export const getPluginName = pluginName => {
|
||||
if (pluginName.startsWith('.')) {
|
||||
return path.parse(pluginName).name;
|
||||
}
|
||||
|
||||
return pluginName;
|
||||
};
|
||||
|
||||
export let getPlugins = async (config, container) => {
|
||||
const context = config.getContext();
|
||||
const disabledPlugins = [];
|
||||
|
||||
const enabledExternalPlugins = await _.reduce(
|
||||
context.plugins,
|
||||
async (result, pluginConfig, pluginName) => {
|
||||
const [name, Plugin] = await load(pluginName);
|
||||
const [namespace, options] = pluginConfig.length === 2 ? pluginConfig : [name, pluginConfig];
|
||||
config.setContext({ [namespace]: options });
|
||||
if (await Plugin.isEnabled(options)) {
|
||||
const instance = new Plugin({ namespace, options: config.getContext(), container });
|
||||
debug({ namespace, options: instance.options });
|
||||
(await result).push(instance);
|
||||
disabledPlugins.push(..._.intersection(pluginNames, _.castArray(Plugin.disablePlugin(options))));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const enabledPlugins = await pluginNames.reduce(async (result, plugin) => {
|
||||
if (plugin in plugins && !disabledPlugins.includes(plugin)) {
|
||||
const Plugin = plugins[plugin];
|
||||
const pluginOptions = context[plugin];
|
||||
if (await Plugin.isEnabled(pluginOptions)) {
|
||||
const instance = new Plugin({ namespace: plugin, options: context, container });
|
||||
debug({ namespace: plugin, options: instance.options });
|
||||
(await result).push(instance);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
return [enabledPlugins, enabledExternalPlugins];
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import type {SplitIncludingDelimiters} from './delimiter-case';
|
||||
import type {SnakeCase} from './snake-case';
|
||||
import type {Includes} from './includes';
|
||||
|
||||
/**
|
||||
Returns a boolean for whether the string is screaming snake case.
|
||||
*/
|
||||
type IsScreamingSnakeCase<Value extends string> = Value extends Uppercase<Value>
|
||||
? Includes<SplitIncludingDelimiters<Lowercase<Value>, '_'>, '_'> extends true
|
||||
? true
|
||||
: false
|
||||
: false;
|
||||
|
||||
/**
|
||||
Convert a string literal to screaming-snake-case.
|
||||
|
||||
This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.
|
||||
|
||||
@example
|
||||
```
|
||||
import type {ScreamingSnakeCase} from 'type-fest';
|
||||
|
||||
const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
|
||||
```
|
||||
|
||||
@category Change case
|
||||
@category Template literal
|
||||
*/
|
||||
export type ScreamingSnakeCase<Value> = Value extends string
|
||||
? IsScreamingSnakeCase<Value> extends true
|
||||
? Value
|
||||
: Uppercase<SnakeCase<Value>>
|
||||
: Value;
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var defineProperties = require('define-properties');
|
||||
|
||||
var implementation = require('./implementation');
|
||||
var getPolyfill = require('./polyfill');
|
||||
var shim = require('./shim');
|
||||
|
||||
var polyfill = getPolyfill();
|
||||
|
||||
var getGlobal = function () { return polyfill; };
|
||||
|
||||
defineProperties(getGlobal, {
|
||||
getPolyfill: getPolyfill,
|
||||
implementation: implementation,
|
||||
shim: shim
|
||||
});
|
||||
|
||||
module.exports = getGlobal;
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Commands:": "Kommandoar:",
|
||||
"Options:": "Alternativ:",
|
||||
"Examples:": "Døme:",
|
||||
"boolean": "boolsk",
|
||||
"count": "mengd",
|
||||
"string": "streng",
|
||||
"number": "nummer",
|
||||
"array": "matrise",
|
||||
"required": "obligatorisk",
|
||||
"default": "standard",
|
||||
"default:": "standard:",
|
||||
"choices:": "val:",
|
||||
"generated-value": "generert-verdi",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "Ikkje nok ikkje-alternativ argument: fekk %s, treng minst %s",
|
||||
"other": "Ikkje nok ikkje-alternativ argument: fekk %s, treng minst %s"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "For mange ikkje-alternativ argument: fekk %s, maksimum %s",
|
||||
"other": "For mange ikkje-alternativ argument: fekk %s, maksimum %s"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "Manglar argumentverdi: %s",
|
||||
"other": "Manglar argumentverdiar: %s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "Manglar obligatorisk argument: %s",
|
||||
"other": "Manglar obligatoriske argument: %s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "Ukjent argument: %s",
|
||||
"other": "Ukjende argument: %s"
|
||||
},
|
||||
"Invalid values:": "Ugyldige verdiar:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gjeve: %s, Val: %s",
|
||||
"Argument check failed: %s": "Argumentsjekk mislukkast: %s",
|
||||
"Implications failed:": "Konsekvensane mislukkast:",
|
||||
"Not enough arguments following: %s": "Ikkje nok fylgjande argument: %s",
|
||||
"Invalid JSON config file: %s": "Ugyldig JSON konfigurasjonsfil: %s",
|
||||
"Path to JSON config file": "Bane til JSON konfigurasjonsfil",
|
||||
"Show help": "Vis hjelp",
|
||||
"Show version number": "Vis versjonsnummer"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.01578,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0.00395,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.00395,"69":0,"70":0,"71":0,"72":0.00789,"73":0.00395,"74":0,"75":0.00395,"76":0,"77":0.00395,"78":0.00395,"79":0.00395,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0.00395,"89":0,"90":0,"91":0.00395,"92":0,"93":0.00395,"94":0.00395,"95":0.00395,"96":0,"97":0,"98":0.00395,"99":0.00789,"100":0.00395,"101":0.00395,"102":0.01578,"103":0.00395,"104":0.01184,"105":0.00395,"106":0.01973,"107":0.00789,"108":0.02762,"109":0.5523,"110":0.33927,"111":0.00395,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0.00789,"39":0,"40":0,"41":0,"42":0,"43":0.00395,"44":0.00395,"45":0.00395,"46":0,"47":0.00395,"48":0,"49":0.00789,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0.00395,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.01184,"69":0.00395,"70":0.00789,"71":0,"72":0.00395,"73":0,"74":0.00395,"75":0.00395,"76":0.00395,"77":0,"78":0.00789,"79":0.05918,"80":0.01184,"81":0.00789,"83":0.00789,"84":0.01184,"85":0.01578,"86":0.00789,"87":0.02762,"88":0.00789,"89":0.00789,"90":0.00395,"91":0.5168,"92":0.01973,"93":0.00395,"94":0.00789,"95":0.00789,"96":0.01578,"97":0.01578,"98":0.01184,"99":0.00789,"100":0.01973,"101":0.01578,"102":0.01578,"103":0.05129,"104":0.02762,"105":0.02367,"106":0.02762,"107":0.05918,"108":0.32744,"109":6.65522,"110":3.54656,"111":0.00395,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0.00789,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0.03551,"68":0,"69":0,"70":0,"71":0,"72":0.00395,"73":0,"74":0.00789,"75":0,"76":0,"77":0,"78":0,"79":0.00395,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.05129,"94":0.41817,"95":0.19725,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0.00395,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0.01184,"79":0,"80":0,"81":0,"83":0,"84":0.00395,"85":0,"86":0.00395,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00395,"93":0,"94":0,"95":0,"96":0.00395,"97":0,"98":0,"99":0,"100":0,"101":0.00395,"102":0,"103":0.00395,"104":0,"105":0.00789,"106":0.00395,"107":0.00789,"108":0.00789,"109":0.3156,"110":0.41817},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0.00395,"10":0,"11":0,"12":0,"13":0,"14":0.00395,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0.00395,"6.1":0,"7.1":0,"9.1":0.00395,"10.1":0,"11.1":0,"12.1":0,"13.1":0.00789,"14.1":0.01973,"15.1":0.00395,"15.2-15.3":0.00395,"15.4":0.00395,"15.5":0.01973,"15.6":0.03156,"16.0":0.00395,"16.1":0.01578,"16.2":0.0434,"16.3":0.05129,"16.4":0},G:{"8":0.00054,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00054,"5.0-5.1":0.00434,"6.0-6.1":0.01138,"7.0-7.1":0.01626,"8.1-8.4":0.01301,"9.0-9.2":0.00542,"9.3":0.0271,"10.0-10.2":0.00108,"10.3":0.0103,"11.0-11.2":0.0168,"11.3-11.4":0.00759,"12.0-12.1":0.00542,"12.2-12.5":0.17671,"13.0-13.1":0.00163,"13.2":0.00108,"13.3":0.00434,"13.4-13.7":0.02927,"14.0-14.4":0.06179,"14.5-14.8":0.13226,"15.0-15.1":0.02222,"15.2-15.3":0.10245,"15.4":0.04607,"15.5":0.12467,"15.6":0.37238,"16.0":0.61901,"16.1":1.17569,"16.2":1.23748,"16.3":0.76374,"16.4":0.00163},P:{"4":0.32715,"20":0.64408,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.39871,"8.2":0.01022,"9.2":0.02045,"10.1":0,"11.1-11.2":0.09201,"12.0":0.02045,"13.0":0.07156,"14.0":0.05112,"15.0":0.06134,"16.0":0.12268,"17.0":0.14313,"18.0":0.1329,"19.0":1.34949},I:{"0":0,"3":0,"4":0.00636,"2.1":0,"2.2":0,"2.3":0.00318,"4.1":0.00636,"4.2-4.3":0.01907,"4.4":0,"4.4.3-4.4.4":0.20026},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0.01282,"9":0.00427,"10":0.00427,"11":0.02992,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.21193},H:{"0":0.38981},L:{"0":73.58031},R:{_:"0"},M:{"0":0.15743},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,26 @@
|
||||
var test = require('tap').test;
|
||||
var detective = require('../');
|
||||
var fs = require('fs');
|
||||
var src = fs.readFileSync(__dirname + '/files/both.js');
|
||||
|
||||
test('both', function (t) {
|
||||
var modules = detective.find(src);
|
||||
t.deepEqual(modules.strings, [ 'a', 'b' ]);
|
||||
t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]);
|
||||
t.notOk(modules.nodes, 'has no nodes');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('both with nodes specified in opts', function (t) {
|
||||
var modules = detective.find(src, { nodes: true });
|
||||
t.deepEqual(modules.strings, [ 'a', 'b' ]);
|
||||
t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]);
|
||||
t.deepEqual(
|
||||
modules.nodes.map(function (n) {
|
||||
var arg = n.arguments[0];
|
||||
return arg.value || arg.left.value;
|
||||
}),
|
||||
[ 'a', 'b', 'c', 'd' ],
|
||||
'has a node for each require');
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
# json-buffer
|
||||
|
||||
JSON functions that can convert buffers!
|
||||
|
||||
[](http://travis-ci.org/dominictarr/json-buffer)
|
||||
|
||||
[](https://ci.testling.com/dominictarr/json-buffer)
|
||||
|
||||
JSON mangles buffers by converting to an array...
|
||||
which isn't helpful. json-buffers converts to base64 instead,
|
||||
and deconverts base64 to a buffer.
|
||||
|
||||
``` js
|
||||
var JSONB = require('json-buffer')
|
||||
var Buffer = require('buffer').Buffer
|
||||
|
||||
var str = JSONB.stringify(Buffer.from('hello there!'))
|
||||
|
||||
console.log(JSONB.parse(str)) //GET a BUFFER back
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,173 @@
|
||||
# ansi-styles
|
||||
|
||||
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||
|
||||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install ansi-styles
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
console.log(`${styles.green.open}Hello world!${styles.green.close}`);
|
||||
|
||||
|
||||
// Color conversion between 256/truecolor
|
||||
// NOTE: When converting from truecolor to 256 colors, the original color
|
||||
// may be degraded to fit the new color palette. This means terminals
|
||||
// that do not support 16 million colors will best-match the
|
||||
// original color.
|
||||
console.log(`${styles.color.ansi(styles.rgbToAnsi(199, 20, 250))}Hello World${styles.color.close}`)
|
||||
console.log(`${styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World${styles.color.close}`)
|
||||
console.log(`${styles.color.ansi16m(...styles.hexToRgb('#abcdef'))}Hello World${styles.color.close}`)
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `open` and `close`
|
||||
|
||||
Each style has an `open` and `close` property.
|
||||
|
||||
### `modifierNames`, `foregroundColorNames`, `backgroundColorNames`, and `colorNames`
|
||||
|
||||
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
|
||||
|
||||
This can be useful if you need to validate input:
|
||||
|
||||
```js
|
||||
import {modifierNames, foregroundColorNames} from 'ansi-styles';
|
||||
|
||||
console.log(modifierNames.includes('bold'));
|
||||
//=> true
|
||||
|
||||
console.log(foregroundColorNames.includes('pink'));
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `italic` *(Not widely supported)*
|
||||
- `underline`
|
||||
- `overline` *Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.*
|
||||
- `inverse`
|
||||
- `hidden`
|
||||
- `strikethrough` *(Not widely supported)*
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
## Advanced usage
|
||||
|
||||
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||
|
||||
- `styles.modifier`
|
||||
- `styles.color`
|
||||
- `styles.bgColor`
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
console.log(styles.color.green.open);
|
||||
```
|
||||
|
||||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `styles.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
console.log(styles.codes.get(36));
|
||||
//=> 39
|
||||
```
|
||||
|
||||
## 16 / 256 / 16 million (TrueColor) support
|
||||
|
||||
`ansi-styles` allows converting between various color formats and ANSI escapes, with support for 16, 256 and [16 million colors](https://gist.github.com/XVilka/8346728).
|
||||
|
||||
The following color spaces are supported:
|
||||
|
||||
- `rgb`
|
||||
- `hex`
|
||||
- `ansi256`
|
||||
- `ansi`
|
||||
|
||||
To use these, call the associated conversion function with the intended output, for example:
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
styles.color.ansi(styles.rgbToAnsi(100, 200, 15)); // RGB to 16 color ansi foreground code
|
||||
styles.bgColor.ansi(styles.hexToAnsi('#C0FFEE')); // HEX to 16 color ansi foreground code
|
||||
|
||||
styles.color.ansi256(styles.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code
|
||||
styles.bgColor.ansi256(styles.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code
|
||||
|
||||
styles.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code
|
||||
styles.bgColor.ansi16m(...styles.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
## For enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
// Borrowed from ansi-regex package
|
||||
// https://github.com/chalk/ansi-regex/blob/a28b8e7ee67aa9996ba44bf123f0436eea62d285/index.js
|
||||
|
||||
return new RegExp(
|
||||
"[\\u001B\\u009B][[\\]()#;?]" +
|
||||
"*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]" +
|
||||
"+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)" +
|
||||
"|" +
|
||||
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
|
||||
"g"
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
'use strict';
|
||||
|
||||
import cliui from 'https://unpkg.com/cliui@7.0.1/index.mjs'; // eslint-disable-line
|
||||
import Parser from 'https://unpkg.com/yargs-parser@19.0.0/browser.js'; // eslint-disable-line
|
||||
import {getProcessArgvBin} from '../../build/lib/utils/process-argv.js';
|
||||
import {YError} from '../../build/lib/yerror.js';
|
||||
|
||||
const REQUIRE_ERROR = 'require is not supported in browser';
|
||||
const REQUIRE_DIRECTORY_ERROR =
|
||||
'loading a directory of commands is not supported in browser';
|
||||
|
||||
export default {
|
||||
assert: {
|
||||
notStrictEqual: (a, b) => {
|
||||
// noop.
|
||||
},
|
||||
strictEqual: (a, b) => {
|
||||
// noop.
|
||||
},
|
||||
},
|
||||
cliui,
|
||||
findUp: () => undefined,
|
||||
getEnv: key => {
|
||||
// There is no environment in browser:
|
||||
return undefined;
|
||||
},
|
||||
inspect: console.log,
|
||||
getCallerFile: () => {
|
||||
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
||||
},
|
||||
getProcessArgvBin,
|
||||
mainFilename: 'yargs',
|
||||
Parser,
|
||||
path: {
|
||||
basename: str => str,
|
||||
dirname: str => str,
|
||||
extname: str => str,
|
||||
relative: str => str,
|
||||
},
|
||||
process: {
|
||||
argv: () => [],
|
||||
cwd: () => '',
|
||||
emitWarning: (warning, name) => {},
|
||||
execPath: () => '',
|
||||
// exit is noop browser:
|
||||
exit: () => {},
|
||||
nextTick: cb => {
|
||||
// eslint-disable-next-line no-undef
|
||||
window.setTimeout(cb, 1);
|
||||
},
|
||||
stdColumns: 80,
|
||||
},
|
||||
readFileSync: () => {
|
||||
return '';
|
||||
},
|
||||
require: () => {
|
||||
throw new YError(REQUIRE_ERROR);
|
||||
},
|
||||
requireDirectory: () => {
|
||||
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
||||
},
|
||||
stringWidth: str => {
|
||||
return [...str].length;
|
||||
},
|
||||
// TODO: replace this with y18n once it's ported to ESM:
|
||||
y18n: {
|
||||
__: (...str) => {
|
||||
if (str.length === 0) return '';
|
||||
const args = str.slice(1);
|
||||
return sprintf(str[0], ...args);
|
||||
},
|
||||
__n: (str1, str2, count, ...args) => {
|
||||
if (count === 1) {
|
||||
return sprintf(str1, ...args);
|
||||
} else {
|
||||
return sprintf(str2, ...args);
|
||||
}
|
||||
},
|
||||
getLocale: () => {
|
||||
return 'en_US';
|
||||
},
|
||||
setLocale: () => {},
|
||||
updateLocale: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
function sprintf(_str, ...args) {
|
||||
let str = '';
|
||||
const split = _str.split('%s');
|
||||
split.forEach((token, i) => {
|
||||
str += `${token}${split[i + 1] !== undefined && args[i] ? args[i] : ''}`;
|
||||
});
|
||||
return str;
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
"use strict";;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var types_1 = tslib_1.__importDefault(require("./types"));
|
||||
var path_1 = tslib_1.__importDefault(require("./path"));
|
||||
var scope_1 = tslib_1.__importDefault(require("./scope"));
|
||||
function nodePathPlugin(fork) {
|
||||
var types = fork.use(types_1.default);
|
||||
var n = types.namedTypes;
|
||||
var b = types.builders;
|
||||
var isNumber = types.builtInTypes.number;
|
||||
var isArray = types.builtInTypes.array;
|
||||
var Path = fork.use(path_1.default);
|
||||
var Scope = fork.use(scope_1.default);
|
||||
var NodePath = function NodePath(value, parentPath, name) {
|
||||
if (!(this instanceof NodePath)) {
|
||||
throw new Error("NodePath constructor cannot be invoked without 'new'");
|
||||
}
|
||||
Path.call(this, value, parentPath, name);
|
||||
};
|
||||
var NPp = NodePath.prototype = Object.create(Path.prototype, {
|
||||
constructor: {
|
||||
value: NodePath,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
Object.defineProperties(NPp, {
|
||||
node: {
|
||||
get: function () {
|
||||
Object.defineProperty(this, "node", {
|
||||
configurable: true,
|
||||
value: this._computeNode()
|
||||
});
|
||||
return this.node;
|
||||
}
|
||||
},
|
||||
parent: {
|
||||
get: function () {
|
||||
Object.defineProperty(this, "parent", {
|
||||
configurable: true,
|
||||
value: this._computeParent()
|
||||
});
|
||||
return this.parent;
|
||||
}
|
||||
},
|
||||
scope: {
|
||||
get: function () {
|
||||
Object.defineProperty(this, "scope", {
|
||||
configurable: true,
|
||||
value: this._computeScope()
|
||||
});
|
||||
return this.scope;
|
||||
}
|
||||
}
|
||||
});
|
||||
NPp.replace = function () {
|
||||
delete this.node;
|
||||
delete this.parent;
|
||||
delete this.scope;
|
||||
return Path.prototype.replace.apply(this, arguments);
|
||||
};
|
||||
NPp.prune = function () {
|
||||
var remainingNodePath = this.parent;
|
||||
this.replace();
|
||||
return cleanUpNodesAfterPrune(remainingNodePath);
|
||||
};
|
||||
// The value of the first ancestor Path whose value is a Node.
|
||||
NPp._computeNode = function () {
|
||||
var value = this.value;
|
||||
if (n.Node.check(value)) {
|
||||
return value;
|
||||
}
|
||||
var pp = this.parentPath;
|
||||
return pp && pp.node || null;
|
||||
};
|
||||
// The first ancestor Path whose value is a Node distinct from this.node.
|
||||
NPp._computeParent = function () {
|
||||
var value = this.value;
|
||||
var pp = this.parentPath;
|
||||
if (!n.Node.check(value)) {
|
||||
while (pp && !n.Node.check(pp.value)) {
|
||||
pp = pp.parentPath;
|
||||
}
|
||||
if (pp) {
|
||||
pp = pp.parentPath;
|
||||
}
|
||||
}
|
||||
while (pp && !n.Node.check(pp.value)) {
|
||||
pp = pp.parentPath;
|
||||
}
|
||||
return pp || null;
|
||||
};
|
||||
// The closest enclosing scope that governs this node.
|
||||
NPp._computeScope = function () {
|
||||
var value = this.value;
|
||||
var pp = this.parentPath;
|
||||
var scope = pp && pp.scope;
|
||||
if (n.Node.check(value) &&
|
||||
Scope.isEstablishedBy(value)) {
|
||||
scope = new Scope(this, scope);
|
||||
}
|
||||
return scope || null;
|
||||
};
|
||||
NPp.getValueProperty = function (name) {
|
||||
return types.getFieldValue(this.value, name);
|
||||
};
|
||||
/**
|
||||
* Determine whether this.node needs to be wrapped in parentheses in order
|
||||
* for a parser to reproduce the same local AST structure.
|
||||
*
|
||||
* For instance, in the expression `(1 + 2) * 3`, the BinaryExpression
|
||||
* whose operator is "+" needs parentheses, because `1 + 2 * 3` would
|
||||
* parse differently.
|
||||
*
|
||||
* If assumeExpressionContext === true, we don't worry about edge cases
|
||||
* like an anonymous FunctionExpression appearing lexically first in its
|
||||
* enclosing statement and thus needing parentheses to avoid being parsed
|
||||
* as a FunctionDeclaration with a missing name.
|
||||
*/
|
||||
NPp.needsParens = function (assumeExpressionContext) {
|
||||
var pp = this.parentPath;
|
||||
if (!pp) {
|
||||
return false;
|
||||
}
|
||||
var node = this.value;
|
||||
// Only expressions need parentheses.
|
||||
if (!n.Expression.check(node)) {
|
||||
return false;
|
||||
}
|
||||
// Identifiers never need parentheses.
|
||||
if (node.type === "Identifier") {
|
||||
return false;
|
||||
}
|
||||
while (!n.Node.check(pp.value)) {
|
||||
pp = pp.parentPath;
|
||||
if (!pp) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var parent = pp.value;
|
||||
switch (node.type) {
|
||||
case "UnaryExpression":
|
||||
case "SpreadElement":
|
||||
case "SpreadProperty":
|
||||
return parent.type === "MemberExpression"
|
||||
&& this.name === "object"
|
||||
&& parent.object === node;
|
||||
case "BinaryExpression":
|
||||
case "LogicalExpression":
|
||||
switch (parent.type) {
|
||||
case "CallExpression":
|
||||
return this.name === "callee"
|
||||
&& parent.callee === node;
|
||||
case "UnaryExpression":
|
||||
case "SpreadElement":
|
||||
case "SpreadProperty":
|
||||
return true;
|
||||
case "MemberExpression":
|
||||
return this.name === "object"
|
||||
&& parent.object === node;
|
||||
case "BinaryExpression":
|
||||
case "LogicalExpression": {
|
||||
var n_1 = node;
|
||||
var po = parent.operator;
|
||||
var pp_1 = PRECEDENCE[po];
|
||||
var no = n_1.operator;
|
||||
var np = PRECEDENCE[no];
|
||||
if (pp_1 > np) {
|
||||
return true;
|
||||
}
|
||||
if (pp_1 === np && this.name === "right") {
|
||||
if (parent.right !== n_1) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case "SequenceExpression":
|
||||
switch (parent.type) {
|
||||
case "ForStatement":
|
||||
// Although parentheses wouldn't hurt around sequence
|
||||
// expressions in the head of for loops, traditional style
|
||||
// dictates that e.g. i++, j++ should not be wrapped with
|
||||
// parentheses.
|
||||
return false;
|
||||
case "ExpressionStatement":
|
||||
return this.name !== "expression";
|
||||
default:
|
||||
// Otherwise err on the side of overparenthesization, adding
|
||||
// explicit exceptions above if this proves overzealous.
|
||||
return true;
|
||||
}
|
||||
case "YieldExpression":
|
||||
switch (parent.type) {
|
||||
case "BinaryExpression":
|
||||
case "LogicalExpression":
|
||||
case "UnaryExpression":
|
||||
case "SpreadElement":
|
||||
case "SpreadProperty":
|
||||
case "CallExpression":
|
||||
case "MemberExpression":
|
||||
case "NewExpression":
|
||||
case "ConditionalExpression":
|
||||
case "YieldExpression":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case "Literal":
|
||||
return parent.type === "MemberExpression"
|
||||
&& isNumber.check(node.value)
|
||||
&& this.name === "object"
|
||||
&& parent.object === node;
|
||||
case "AssignmentExpression":
|
||||
case "ConditionalExpression":
|
||||
switch (parent.type) {
|
||||
case "UnaryExpression":
|
||||
case "SpreadElement":
|
||||
case "SpreadProperty":
|
||||
case "BinaryExpression":
|
||||
case "LogicalExpression":
|
||||
return true;
|
||||
case "CallExpression":
|
||||
return this.name === "callee"
|
||||
&& parent.callee === node;
|
||||
case "ConditionalExpression":
|
||||
return this.name === "test"
|
||||
&& parent.test === node;
|
||||
case "MemberExpression":
|
||||
return this.name === "object"
|
||||
&& parent.object === node;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
if (parent.type === "NewExpression" &&
|
||||
this.name === "callee" &&
|
||||
parent.callee === node) {
|
||||
return containsCallExpression(node);
|
||||
}
|
||||
}
|
||||
if (assumeExpressionContext !== true &&
|
||||
!this.canBeFirstInStatement() &&
|
||||
this.firstInStatement())
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
function isBinary(node) {
|
||||
return n.BinaryExpression.check(node)
|
||||
|| n.LogicalExpression.check(node);
|
||||
}
|
||||
// @ts-ignore 'isUnaryLike' is declared but its value is never read. [6133]
|
||||
function isUnaryLike(node) {
|
||||
return n.UnaryExpression.check(node)
|
||||
// I considered making SpreadElement and SpreadProperty subtypes
|
||||
// of UnaryExpression, but they're not really Expression nodes.
|
||||
|| (n.SpreadElement && n.SpreadElement.check(node))
|
||||
|| (n.SpreadProperty && n.SpreadProperty.check(node));
|
||||
}
|
||||
var PRECEDENCE = {};
|
||||
[["||"],
|
||||
["&&"],
|
||||
["|"],
|
||||
["^"],
|
||||
["&"],
|
||||
["==", "===", "!=", "!=="],
|
||||
["<", ">", "<=", ">=", "in", "instanceof"],
|
||||
[">>", "<<", ">>>"],
|
||||
["+", "-"],
|
||||
["*", "/", "%"]
|
||||
].forEach(function (tier, i) {
|
||||
tier.forEach(function (op) {
|
||||
PRECEDENCE[op] = i;
|
||||
});
|
||||
});
|
||||
function containsCallExpression(node) {
|
||||
if (n.CallExpression.check(node)) {
|
||||
return true;
|
||||
}
|
||||
if (isArray.check(node)) {
|
||||
return node.some(containsCallExpression);
|
||||
}
|
||||
if (n.Node.check(node)) {
|
||||
return types.someField(node, function (_name, child) {
|
||||
return containsCallExpression(child);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
NPp.canBeFirstInStatement = function () {
|
||||
var node = this.node;
|
||||
return !n.FunctionExpression.check(node)
|
||||
&& !n.ObjectExpression.check(node);
|
||||
};
|
||||
NPp.firstInStatement = function () {
|
||||
return firstInStatement(this);
|
||||
};
|
||||
function firstInStatement(path) {
|
||||
for (var node, parent; path.parent; path = path.parent) {
|
||||
node = path.node;
|
||||
parent = path.parent.node;
|
||||
if (n.BlockStatement.check(parent) &&
|
||||
path.parent.name === "body" &&
|
||||
path.name === 0) {
|
||||
if (parent.body[0] !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (n.ExpressionStatement.check(parent) &&
|
||||
path.name === "expression") {
|
||||
if (parent.expression !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (n.SequenceExpression.check(parent) &&
|
||||
path.parent.name === "expressions" &&
|
||||
path.name === 0) {
|
||||
if (parent.expressions[0] !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (n.CallExpression.check(parent) &&
|
||||
path.name === "callee") {
|
||||
if (parent.callee !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (n.MemberExpression.check(parent) &&
|
||||
path.name === "object") {
|
||||
if (parent.object !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (n.ConditionalExpression.check(parent) &&
|
||||
path.name === "test") {
|
||||
if (parent.test !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (isBinary(parent) &&
|
||||
path.name === "left") {
|
||||
if (parent.left !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (n.UnaryExpression.check(parent) &&
|
||||
!parent.prefix &&
|
||||
path.name === "argument") {
|
||||
if (parent.argument !== node) {
|
||||
throw new Error("Nodes must be equal");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Pruning certain nodes will result in empty or incomplete nodes, here we clean those nodes up.
|
||||
*/
|
||||
function cleanUpNodesAfterPrune(remainingNodePath) {
|
||||
if (n.VariableDeclaration.check(remainingNodePath.node)) {
|
||||
var declarations = remainingNodePath.get('declarations').value;
|
||||
if (!declarations || declarations.length === 0) {
|
||||
return remainingNodePath.prune();
|
||||
}
|
||||
}
|
||||
else if (n.ExpressionStatement.check(remainingNodePath.node)) {
|
||||
if (!remainingNodePath.get('expression').value) {
|
||||
return remainingNodePath.prune();
|
||||
}
|
||||
}
|
||||
else if (n.IfStatement.check(remainingNodePath.node)) {
|
||||
cleanUpIfStatementAfterPrune(remainingNodePath);
|
||||
}
|
||||
return remainingNodePath;
|
||||
}
|
||||
function cleanUpIfStatementAfterPrune(ifStatement) {
|
||||
var testExpression = ifStatement.get('test').value;
|
||||
var alternate = ifStatement.get('alternate').value;
|
||||
var consequent = ifStatement.get('consequent').value;
|
||||
if (!consequent && !alternate) {
|
||||
var testExpressionStatement = b.expressionStatement(testExpression);
|
||||
ifStatement.replace(testExpressionStatement);
|
||||
}
|
||||
else if (!consequent && alternate) {
|
||||
var negatedTestExpression = b.unaryExpression('!', testExpression, true);
|
||||
if (n.UnaryExpression.check(testExpression) && testExpression.operator === '!') {
|
||||
negatedTestExpression = testExpression.argument;
|
||||
}
|
||||
ifStatement.get("test").replace(negatedTestExpression);
|
||||
ifStatement.get("consequent").replace(alternate);
|
||||
ifStatement.get("alternate").replace();
|
||||
}
|
||||
}
|
||||
return NodePath;
|
||||
}
|
||||
exports.default = nodePathPlugin;
|
||||
module.exports = exports["default"];
|
||||
@@ -0,0 +1,105 @@
|
||||
/* global window, document */
|
||||
import * as svelteInternal from 'svelte/internal'
|
||||
// NOTE from 3.38.3 (or so), insert was carrying the hydration logic, that must
|
||||
// be used because DOM elements are reused more (and so insertion points are not
|
||||
// necessarily added in order); then in 3.40 the logic was moved to
|
||||
// insert_hydration, which is the one we must use for HMR
|
||||
const svelteInsert = svelteInternal.insert_hydration || svelteInternal.insert
|
||||
if (!svelteInsert) {
|
||||
throw new Error(
|
||||
'failed to find insert_hydration and insert in svelte/internal'
|
||||
)
|
||||
}
|
||||
|
||||
import ErrorOverlay from './overlay.js'
|
||||
|
||||
const removeElement = el => el && el.parentNode && el.parentNode.removeChild(el)
|
||||
|
||||
export const adapter = class ProxyAdapterDom {
|
||||
constructor(instance) {
|
||||
this.instance = instance
|
||||
this.insertionPoint = null
|
||||
|
||||
this.afterMount = this.afterMount.bind(this)
|
||||
this.rerender = this.rerender.bind(this)
|
||||
|
||||
this._noOverlay = !!instance.hotOptions.noOverlay
|
||||
}
|
||||
|
||||
// NOTE overlay is only created before being actually shown to help test
|
||||
// runner (it won't have to account for error overlay when running assertions
|
||||
// about the contents of the rendered page)
|
||||
static getErrorOverlay(noCreate = false) {
|
||||
if (!noCreate && !this.errorOverlay) {
|
||||
this.errorOverlay = ErrorOverlay()
|
||||
}
|
||||
return this.errorOverlay
|
||||
}
|
||||
|
||||
// TODO this is probably unused now: remove in next breaking release
|
||||
static renderCompileError(message) {
|
||||
const noCreate = !message
|
||||
const overlay = this.getErrorOverlay(noCreate)
|
||||
if (!overlay) return
|
||||
overlay.setCompileError(message)
|
||||
}
|
||||
|
||||
dispose() {
|
||||
// Component is being destroyed, detaching is not optional in Svelte3's
|
||||
// component API, so we can dispose of the insertion point in every case.
|
||||
if (this.insertionPoint) {
|
||||
removeElement(this.insertionPoint)
|
||||
this.insertionPoint = null
|
||||
}
|
||||
this.clearError()
|
||||
}
|
||||
|
||||
// NOTE afterMount CAN be called multiple times (e.g. keyed list)
|
||||
afterMount(target, anchor) {
|
||||
const {
|
||||
instance: { debugName },
|
||||
} = this
|
||||
if (!this.insertionPoint) {
|
||||
this.insertionPoint = document.createComment(debugName)
|
||||
}
|
||||
svelteInsert(target, this.insertionPoint, anchor)
|
||||
}
|
||||
|
||||
rerender() {
|
||||
this.clearError()
|
||||
const {
|
||||
instance: { refreshComponent },
|
||||
insertionPoint,
|
||||
} = this
|
||||
if (!insertionPoint) {
|
||||
throw new Error('Cannot rerender: missing insertion point')
|
||||
}
|
||||
refreshComponent(insertionPoint.parentNode, insertionPoint)
|
||||
}
|
||||
|
||||
renderError(err) {
|
||||
if (this._noOverlay) return
|
||||
const {
|
||||
instance: { debugName },
|
||||
} = this
|
||||
const title = debugName || err.moduleName || 'Error'
|
||||
this.constructor.getErrorOverlay().addError(err, title)
|
||||
}
|
||||
|
||||
clearError() {
|
||||
if (this._noOverlay) return
|
||||
const overlay = this.constructor.getErrorOverlay(true)
|
||||
if (!overlay) return
|
||||
overlay.clearErrors()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO this is probably unused now: remove in next breaking release
|
||||
if (typeof window !== 'undefined') {
|
||||
window.__SVELTE_HMR_ADAPTER = adapter
|
||||
}
|
||||
|
||||
// mitigate situation with Snowpack remote source pulling latest of runtime,
|
||||
// but using previous version of the Node code transform in the plugin
|
||||
// see: https://github.com/rixo/svelte-hmr/issues/27
|
||||
export default adapter
|
||||
@@ -0,0 +1,334 @@
|
||||
# cacheable-request
|
||||
|
||||
> Wrap native HTTP requests with RFC compliant cache support
|
||||
|
||||
[](https://github.com/jaredwray/cacheable-request/actions/workflows/tests.yaml)
|
||||
[](https://codecov.io/gh/jaredwray/cacheable-request)
|
||||
[](https://www.npmjs.com/package/cacheable-request)
|
||||
[](https://www.npmjs.com/package/cacheable-request)
|
||||
|
||||
[RFC 7234](http://httpwg.org/specs/rfc7234.html) compliant HTTP caching for native Node.js HTTP/HTTPS requests. Caching works out of the box in memory or is easily pluggable with a wide range of storage adapters.
|
||||
|
||||
**Note:** This is a low level wrapper around the core HTTP modules, it's not a high level request library.
|
||||
|
||||
# Table of Contents
|
||||
* [Latest Changes](#latest-changes)
|
||||
* [Features](#features)
|
||||
* [Install and Usage](#install-and-usage)
|
||||
* [Storage Adapters](#storage-adapters)
|
||||
* [API](#api)
|
||||
* [Using Hooks](#using-hooks)
|
||||
* [Contributing](#contributing)
|
||||
* [Ask a Question](#ask-a-question)
|
||||
* [License](#license) (MIT)
|
||||
|
||||
# Latest Changes
|
||||
|
||||
## Breaking Changes with v10.0.0
|
||||
This release contains breaking changes. This is the new way to use this package.
|
||||
|
||||
### Usage Before v10
|
||||
```js
|
||||
import http from 'http';
|
||||
import CacheableRequest from 'cacheable-request';
|
||||
|
||||
// Then instead of
|
||||
const req = http.request('http://example.com', cb);
|
||||
req.end();
|
||||
|
||||
// You can do
|
||||
const cacheableRequest = new CacheableRequest(http.request);
|
||||
const cacheReq = cacheableRequest('http://example.com', cb);
|
||||
cacheReq.on('request', req => req.end());
|
||||
// Future requests to 'example.com' will be returned from cache if still valid
|
||||
|
||||
// You pass in any other http.request API compatible method to be wrapped with cache support:
|
||||
const cacheableRequest = new CacheableRequest(https.request);
|
||||
const cacheableRequest = new CacheableRequest(electron.net);
|
||||
```
|
||||
|
||||
### Usage After v10.1.0
|
||||
```js
|
||||
|
||||
import CacheableRequest from 'cacheable-request';
|
||||
|
||||
// Now You can do
|
||||
const cacheableRequest = new CacheableRequest(http.request).request();
|
||||
const cacheReq = cacheableRequest('http://example.com', cb);
|
||||
cacheReq.on('request', req => req.end());
|
||||
// Future requests to 'example.com' will be returned from cache if still valid
|
||||
|
||||
// You pass in any other http.request API compatible method to be wrapped with cache support:
|
||||
const cacheableRequest = new CacheableRequest(https.request).request();
|
||||
const cacheableRequest = new CacheableRequest(electron.net).request();
|
||||
```
|
||||
|
||||
The biggest change is that when you do a `new` CacheableRequest you now want to call `request` method will give you the instance to use.
|
||||
|
||||
```diff
|
||||
- const cacheableRequest = new CacheableRequest(http.request);
|
||||
+ const cacheableRequest = new CacheableRequest(http.request).request();
|
||||
```
|
||||
|
||||
### ESM Support in version 9 and higher.
|
||||
|
||||
We are now using pure esm support in our package. If you need to use commonjs you can use v8 or lower. To learn more about using ESM please read this from `sindresorhus`: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
## Features
|
||||
|
||||
- Only stores cacheable responses as defined by RFC 7234
|
||||
- Fresh cache entries are served directly from cache
|
||||
- Stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers
|
||||
- 304 responses from revalidation requests use cached body
|
||||
- Updates `Age` header on cached responses
|
||||
- Can completely bypass cache on a per request basis
|
||||
- In memory cache by default
|
||||
- Official support for Redis, Memcache, Etcd, MongoDB, SQLite, PostgreSQL and MySQL storage adapters
|
||||
- Easily plug in your own or third-party storage adapters
|
||||
- If DB connection fails, cache is automatically bypassed ([disabled by default](#optsautomaticfailover))
|
||||
- Adds cache support to any existing HTTP code with minimal changes
|
||||
- Uses [http-cache-semantics](https://github.com/pornel/http-cache-semantics) internally for HTTP RFC 7234 compliance
|
||||
|
||||
## Install and Usage
|
||||
|
||||
```shell
|
||||
npm install cacheable-request
|
||||
```
|
||||
|
||||
```js
|
||||
import http from 'http';
|
||||
import CacheableRequest from 'cacheable-request';
|
||||
|
||||
// Then instead of
|
||||
const req = http.request('http://example.com', cb);
|
||||
req.end();
|
||||
|
||||
// You can do
|
||||
const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();
|
||||
const cacheReq = cacheableRequest('http://example.com', cb);
|
||||
cacheReq.on('request', req => req.end());
|
||||
// Future requests to 'example.com' will be returned from cache if still valid
|
||||
|
||||
// You pass in any other http.request API compatible method to be wrapped with cache support:
|
||||
const cacheableRequest = new CacheableRequest(https.request).createCacheableRequest();
|
||||
const cacheableRequest = new CacheableRequest(electron.net).createCacheableRequest();
|
||||
```
|
||||
|
||||
## Storage Adapters
|
||||
|
||||
`cacheable-request` uses [Keyv](https://github.com/jaredwray/keyv) to support a wide range of storage adapters.
|
||||
|
||||
For example, to use Redis as a cache backend, you just need to install the official Redis Keyv storage adapter:
|
||||
|
||||
```
|
||||
npm install @keyv/redis
|
||||
```
|
||||
|
||||
And then you can pass `CacheableRequest` your connection string:
|
||||
|
||||
```js
|
||||
const cacheableRequest = new CacheableRequest(http.request, 'redis://user:pass@localhost:6379').createCacheableRequest();
|
||||
```
|
||||
|
||||
[View all official Keyv storage adapters.](https://github.com/jaredwray/keyv#official-storage-adapters)
|
||||
|
||||
Keyv also supports anything that follows the Map API so it's easy to write your own storage adapter or use a third-party solution.
|
||||
|
||||
e.g The following are all valid storage adapters
|
||||
|
||||
```js
|
||||
const storageAdapter = new Map();
|
||||
// or
|
||||
const storageAdapter = require('./my-storage-adapter');
|
||||
// or
|
||||
const QuickLRU = require('quick-lru');
|
||||
const storageAdapter = new QuickLRU({ maxSize: 1000 });
|
||||
|
||||
const cacheableRequest = new CacheableRequest(http.request, storageAdapter).createCacheableRequest();
|
||||
```
|
||||
|
||||
View the [Keyv docs](https://github.com/jaredwray/keyv) for more information on how to use storage adapters.
|
||||
|
||||
## API
|
||||
|
||||
### new cacheableRequest(request, [storageAdapter])
|
||||
|
||||
Returns the provided request function wrapped with cache support.
|
||||
|
||||
#### request
|
||||
|
||||
Type: `function`
|
||||
|
||||
Request function to wrap with cache support. Should be [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) or a similar API compatible request function.
|
||||
|
||||
#### storageAdapter
|
||||
|
||||
Type: `Keyv storage adapter`<br>
|
||||
Default: `new Map()`
|
||||
|
||||
A [Keyv](https://github.com/jaredwray/keyv) storage adapter instance, or connection string if using with an official Keyv storage adapter.
|
||||
|
||||
### Instance
|
||||
|
||||
#### cacheableRequest(opts, [cb])
|
||||
|
||||
Returns an event emitter.
|
||||
|
||||
##### opts
|
||||
|
||||
Type: `object`, `string`
|
||||
|
||||
- Any of the default request functions options.
|
||||
- Any [`http-cache-semantics`](https://github.com/kornelski/http-cache-semantics#constructor-options) options.
|
||||
- Any of the following:
|
||||
|
||||
###### opts.cache
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
If the cache should be used. Setting this to false will completely bypass the cache for the current request.
|
||||
|
||||
###### opts.strictTtl
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
If set to `true` once a cached resource has expired it is deleted and will have to be re-requested.
|
||||
|
||||
If set to `false` (default), after a cached resource's TTL expires it is kept in the cache and will be revalidated on the next request with `If-None-Match`/`If-Modified-Since` headers.
|
||||
|
||||
###### opts.maxTtl
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `undefined`
|
||||
|
||||
Limits TTL. The `number` represents milliseconds.
|
||||
|
||||
###### opts.automaticFailover
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
When set to `true`, if the DB connection fails we will automatically fallback to a network request. DB errors will still be emitted to notify you of the problem even though the request callback may succeed.
|
||||
|
||||
###### opts.forceRefresh
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a new request and override the cache instead.
|
||||
|
||||
##### cb
|
||||
|
||||
Type: `function`
|
||||
|
||||
The callback function which will receive the response as an argument.
|
||||
|
||||
The response can be either a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage) or a [responselike object](https://github.com/lukechilds/responselike). The response will also have a `fromCache` property set with a boolean value.
|
||||
|
||||
##### .on('request', request)
|
||||
|
||||
`request` event to get the request object of the request.
|
||||
|
||||
**Note:** This event will only fire if an HTTP request is actually made, not when a response is retrieved from cache. However, you should always handle the `request` event to end the request and handle any potential request errors.
|
||||
|
||||
##### .on('response', response)
|
||||
|
||||
`response` event to get the response object from the HTTP request or cache.
|
||||
|
||||
##### .on('error', error)
|
||||
|
||||
`error` event emitted in case of an error with the cache.
|
||||
|
||||
Errors emitted here will be an instance of `CacheableRequest.RequestError` or `CacheableRequest.CacheError`. You will only ever receive a `RequestError` if the request function throws (normally caused by invalid user input). Normal request errors should be handled inside the `request` event.
|
||||
|
||||
To properly handle all error scenarios you should use the following pattern:
|
||||
|
||||
```js
|
||||
cacheableRequest('example.com', cb)
|
||||
.on('error', err => {
|
||||
if (err instanceof CacheableRequest.CacheError) {
|
||||
handleCacheError(err); // Cache error
|
||||
} else if (err instanceof CacheableRequest.RequestError) {
|
||||
handleRequestError(err); // Request function thrown
|
||||
}
|
||||
})
|
||||
.on('request', req => {
|
||||
req.on('error', handleRequestError); // Request error emitted
|
||||
req.end();
|
||||
});
|
||||
```
|
||||
**Note:** Database connection errors are emitted here, however `cacheable-request` will attempt to re-request the resource and bypass the cache on a connection error. Therefore a database connection error doesn't necessarily mean the request won't be fulfilled.
|
||||
|
||||
|
||||
## Using Hooks
|
||||
Hooks have been implemented since version `v9` and are very useful to modify response before saving it in cache. You can use hooks to modify response before saving it in cache.
|
||||
|
||||
### Add Hooks
|
||||
|
||||
The hook will pre compute response right before saving it in cache. You can include many hooks and it will run in order you add hook on response object.
|
||||
|
||||
```js
|
||||
import http from 'http';
|
||||
import CacheableRequest from 'cacheable-request';
|
||||
|
||||
const cacheableRequest = new CacheableRequest(request, cache).request();
|
||||
|
||||
// adding a hook to decompress response
|
||||
cacheableRequest.addHook('onResponse', async (value: CacheValue, response: any) => {
|
||||
const buffer = await pm(gunzip)(value.body);
|
||||
value.body = buffer.toString();
|
||||
return value;
|
||||
});
|
||||
```
|
||||
|
||||
here is also an example of how to add in the remote address
|
||||
|
||||
```js
|
||||
import CacheableRequest, {CacheValue} from 'cacheable-request';
|
||||
|
||||
const cacheableRequest = new CacheableRequest(request, cache).request();
|
||||
cacheableRequest.addHook('onResponse', (value: CacheValue, response: any) => {
|
||||
if (response.connection) {
|
||||
value.remoteAddress = response.connection.remoteAddress;
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
```
|
||||
|
||||
### Remove Hooks
|
||||
|
||||
You can also remove hook by using below
|
||||
|
||||
```js
|
||||
CacheableRequest.removeHook('onResponse');
|
||||
```
|
||||
|
||||
## How to Contribute
|
||||
|
||||
Cacheable-Request is an open source package and community driven that is maintained regularly. In addtion we have a couple of other guidelines for review:
|
||||
|
||||
* [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Our code of conduct
|
||||
* [CONTRIBUTING.md](CONTRIBUTING.md) - How to contribute to this project
|
||||
* [SECURITY.md](SECURITY.md) - Security guidelines and supported versions
|
||||
|
||||
## Post an Issue
|
||||
|
||||
To post an issue, navigate to the "Issues" tab in the main repository, and then select "New Issue." Enter a clear title describing the issue, as well as a description containing additional relevant information. Also select the label that best describes your issue type. For a bug report, for example, create an issue with the label "bug." In the description field, Be sure to include replication steps, as well as any relevant error messages.
|
||||
|
||||
If you're reporting a security violation, be sure to check out the project's [security policy](SECURITY.md).
|
||||
|
||||
Please also refer to our [Code of Conduct](CODE_OF_CONDUCT.md) for more information on how to report issues.
|
||||
|
||||
## Ask a Question
|
||||
|
||||
To ask a question, create an issue with the label "question." In the issue description, include the related code and any context that can help us answer your question.
|
||||
|
||||
## License
|
||||
|
||||
This project is under the [MIT](LICENSE) license.
|
||||
|
||||
MIT © Luke Childs 2017-2021
|
||||
MIT © Jared Wray 2022
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "setprototypeof",
|
||||
"version": "1.2.0",
|
||||
"description": "A small polyfill for Object.setprototypeof",
|
||||
"main": "index.js",
|
||||
"typings": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "standard && mocha",
|
||||
"testallversions": "npm run node010 && npm run node4 && npm run node6 && npm run node9 && npm run node11",
|
||||
"testversion": "docker run -it --rm -v $(PWD):/usr/src/app -w /usr/src/app node:${NODE_VER} npm install mocha@${MOCHA_VER:-latest} && npm t",
|
||||
"node010": "NODE_VER=0.10 MOCHA_VER=3 npm run testversion",
|
||||
"node4": "NODE_VER=4 npm run testversion",
|
||||
"node6": "NODE_VER=6 npm run testversion",
|
||||
"node9": "NODE_VER=9 npm run testversion",
|
||||
"node11": "NODE_VER=11 npm run testversion",
|
||||
"prepublishOnly": "npm t",
|
||||
"postpublish": "git push origin && git push origin --tags"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/wesleytodd/setprototypeof.git"
|
||||
},
|
||||
"keywords": [
|
||||
"polyfill",
|
||||
"object",
|
||||
"setprototypeof"
|
||||
],
|
||||
"author": "Wes Todd",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/wesleytodd/setprototypeof/issues"
|
||||
},
|
||||
"homepage": "https://github.com/wesleytodd/setprototypeof",
|
||||
"devDependencies": {
|
||||
"mocha": "^6.1.4",
|
||||
"standard": "^13.0.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tap = void 0;
|
||||
var isFunction_1 = require("../util/isFunction");
|
||||
var lift_1 = require("../util/lift");
|
||||
var OperatorSubscriber_1 = require("./OperatorSubscriber");
|
||||
var identity_1 = require("../util/identity");
|
||||
function tap(observerOrNext, error, complete) {
|
||||
var tapObserver = isFunction_1.isFunction(observerOrNext) || error || complete
|
||||
?
|
||||
{ next: observerOrNext, error: error, complete: complete }
|
||||
: observerOrNext;
|
||||
return tapObserver
|
||||
? lift_1.operate(function (source, subscriber) {
|
||||
var _a;
|
||||
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
||||
var isUnsub = true;
|
||||
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
|
||||
var _a;
|
||||
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
||||
subscriber.next(value);
|
||||
}, function () {
|
||||
var _a;
|
||||
isUnsub = false;
|
||||
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
||||
subscriber.complete();
|
||||
}, function (err) {
|
||||
var _a;
|
||||
isUnsub = false;
|
||||
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
|
||||
subscriber.error(err);
|
||||
}, function () {
|
||||
var _a, _b;
|
||||
if (isUnsub) {
|
||||
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
||||
}
|
||||
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
|
||||
}));
|
||||
})
|
||||
:
|
||||
identity_1.identity;
|
||||
}
|
||||
exports.tap = tap;
|
||||
//# sourceMappingURL=tap.js.map
|
||||
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var parse = require('../');
|
||||
|
||||
test('boolean default true', function (t) {
|
||||
var argv = parse([], {
|
||||
boolean: 'sometrue',
|
||||
default: { sometrue: true },
|
||||
});
|
||||
t.equal(argv.sometrue, true);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean default false', function (t) {
|
||||
var argv = parse([], {
|
||||
boolean: 'somefalse',
|
||||
default: { somefalse: false },
|
||||
});
|
||||
t.equal(argv.somefalse, false);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean default to null', function (t) {
|
||||
var argv = parse([], {
|
||||
boolean: 'maybe',
|
||||
default: { maybe: null },
|
||||
});
|
||||
t.equal(argv.maybe, null);
|
||||
|
||||
var argvLong = parse(['--maybe'], {
|
||||
boolean: 'maybe',
|
||||
default: { maybe: null },
|
||||
});
|
||||
t.equal(argvLong.maybe, true);
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var isNaN = require('../../helpers/isNaN');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-number-multiply
|
||||
|
||||
module.exports = function NumberMultiply(x, y) {
|
||||
if (Type(x) !== 'Number' || Type(y) !== 'Number') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
|
||||
}
|
||||
|
||||
if (isNaN(x) || isNaN(y) || (x === 0 && !isFinite(y)) || (!isFinite(x) && y === 0)) {
|
||||
return NaN;
|
||||
}
|
||||
if (!isFinite(x) && !isFinite(y)) {
|
||||
return x === y ? Infinity : -Infinity;
|
||||
}
|
||||
if (!isFinite(x) && y !== 0) {
|
||||
return x > 0 ? Infinity : -Infinity;
|
||||
}
|
||||
if (!isFinite(y) && x !== 0) {
|
||||
return y > 0 ? Infinity : -Infinity;
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x * y;
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
v1.3.0
|
||||
* Additionally include chromium to electron mappings
|
||||
|
||||
v1.2.0
|
||||
* versions and full-versions are now separately importable.
|
||||
|
||||
v1.1.0
|
||||
* Both electronToChromium and electronToBrowserList now can accept strings as well as numbers.
|
||||
|
||||
v1.0.1
|
||||
Update documentation
|
||||
|
||||
v1.0.0
|
||||
Inititial release
|
||||
@@ -0,0 +1,330 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/Gruntfile.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</a> Gruntfile.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/8</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/1</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>0/8</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
</div>
|
||||
<div class='status-line low'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a>
|
||||
<a name='L13'></a><a href='#L13'>13</a>
|
||||
<a name='L14'></a><a href='#L14'>14</a>
|
||||
<a name='L15'></a><a href='#L15'>15</a>
|
||||
<a name='L16'></a><a href='#L16'>16</a>
|
||||
<a name='L17'></a><a href='#L17'>17</a>
|
||||
<a name='L18'></a><a href='#L18'>18</a>
|
||||
<a name='L19'></a><a href='#L19'>19</a>
|
||||
<a name='L20'></a><a href='#L20'>20</a>
|
||||
<a name='L21'></a><a href='#L21'>21</a>
|
||||
<a name='L22'></a><a href='#L22'>22</a>
|
||||
<a name='L23'></a><a href='#L23'>23</a>
|
||||
<a name='L24'></a><a href='#L24'>24</a>
|
||||
<a name='L25'></a><a href='#L25'>25</a>
|
||||
<a name='L26'></a><a href='#L26'>26</a>
|
||||
<a name='L27'></a><a href='#L27'>27</a>
|
||||
<a name='L28'></a><a href='#L28'>28</a>
|
||||
<a name='L29'></a><a href='#L29'>29</a>
|
||||
<a name='L30'></a><a href='#L30'>30</a>
|
||||
<a name='L31'></a><a href='#L31'>31</a>
|
||||
<a name='L32'></a><a href='#L32'>32</a>
|
||||
<a name='L33'></a><a href='#L33'>33</a>
|
||||
<a name='L34'></a><a href='#L34'>34</a>
|
||||
<a name='L35'></a><a href='#L35'>35</a>
|
||||
<a name='L36'></a><a href='#L36'>36</a>
|
||||
<a name='L37'></a><a href='#L37'>37</a>
|
||||
<a name='L38'></a><a href='#L38'>38</a>
|
||||
<a name='L39'></a><a href='#L39'>39</a>
|
||||
<a name='L40'></a><a href='#L40'>40</a>
|
||||
<a name='L41'></a><a href='#L41'>41</a>
|
||||
<a name='L42'></a><a href='#L42'>42</a>
|
||||
<a name='L43'></a><a href='#L43'>43</a>
|
||||
<a name='L44'></a><a href='#L44'>44</a>
|
||||
<a name='L45'></a><a href='#L45'>45</a>
|
||||
<a name='L46'></a><a href='#L46'>46</a>
|
||||
<a name='L47'></a><a href='#L47'>47</a>
|
||||
<a name='L48'></a><a href='#L48'>48</a>
|
||||
<a name='L49'></a><a href='#L49'>49</a>
|
||||
<a name='L50'></a><a href='#L50'>50</a>
|
||||
<a name='L51'></a><a href='#L51'>51</a>
|
||||
<a name='L52'></a><a href='#L52'>52</a>
|
||||
<a name='L53'></a><a href='#L53'>53</a>
|
||||
<a name='L54'></a><a href='#L54'>54</a>
|
||||
<a name='L55'></a><a href='#L55'>55</a>
|
||||
<a name='L56'></a><a href='#L56'>56</a>
|
||||
<a name='L57'></a><a href='#L57'>57</a>
|
||||
<a name='L58'></a><a href='#L58'>58</a>
|
||||
<a name='L59'></a><a href='#L59'>59</a>
|
||||
<a name='L60'></a><a href='#L60'>60</a>
|
||||
<a name='L61'></a><a href='#L61'>61</a>
|
||||
<a name='L62'></a><a href='#L62'>62</a>
|
||||
<a name='L63'></a><a href='#L63'>63</a>
|
||||
<a name='L64'></a><a href='#L64'>64</a>
|
||||
<a name='L65'></a><a href='#L65'>65</a>
|
||||
<a name='L66'></a><a href='#L66'>66</a>
|
||||
<a name='L67'></a><a href='#L67'>67</a>
|
||||
<a name='L68'></a><a href='#L68'>68</a>
|
||||
<a name='L69'></a><a href='#L69'>69</a>
|
||||
<a name='L70'></a><a href='#L70'>70</a>
|
||||
<a name='L71'></a><a href='#L71'>71</a>
|
||||
<a name='L72'></a><a href='#L72'>72</a>
|
||||
<a name='L73'></a><a href='#L73'>73</a>
|
||||
<a name='L74'></a><a href='#L74'>74</a>
|
||||
<a name='L75'></a><a href='#L75'>75</a>
|
||||
<a name='L76'></a><a href='#L76'>76</a>
|
||||
<a name='L77'></a><a href='#L77'>77</a>
|
||||
<a name='L78'></a><a href='#L78'>78</a>
|
||||
<a name='L79'></a><a href='#L79'>79</a>
|
||||
<a name='L80'></a><a href='#L80'>80</a>
|
||||
<a name='L81'></a><a href='#L81'>81</a>
|
||||
<a name='L82'></a><a href='#L82'>82</a>
|
||||
<a name='L83'></a><a href='#L83'>83</a>
|
||||
<a name='L84'></a><a href='#L84'>84</a>
|
||||
<a name='L85'></a><a href='#L85'>85</a>
|
||||
<a name='L86'></a><a href='#L86'>86</a>
|
||||
<a name='L87'></a><a href='#L87'>87</a>
|
||||
<a name='L88'></a><a href='#L88'>88</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/*
|
||||
GRUNT instructions
|
||||
1. ensure you have dependencies installed run `npm install` in the root directory of the repo to get dev dependencies
|
||||
2. run `grunt` in root dir of the repo in a shell to get the watcher started
|
||||
The watcher looks at files. When a file is added or changed it passes the file through jshint
|
||||
3. run `grunt test` to execute all unit tests and get output
|
||||
4. run `grunt jshint` to pass all files through linter
|
||||
|
||||
MADGE instructions
|
||||
1. run `npm install -g madge` to get madge executable
|
||||
2. Insure graphviz is installed and the bin folder is in your path.
|
||||
3. run `madge -x "node_modules|util|stream|os|assert|fs|http" -i graph.png ./` to generate graph.png
|
||||
which is the dependency graph for the current build.
|
||||
*/
|
||||
|
||||
<span class="cstat-no" title="statement not covered" >module.exports = <span class="fstat-no" title="function not covered" >fu</span>nction(grunt) {</span>
|
||||
<span class="cstat-no" title="statement not covered" > require('load-grunt-tasks')(grunt);</span>
|
||||
<span class="cstat-no" title="statement not covered" > grunt.loadTasks('./devops/grunt-wiki');</span>
|
||||
var files = <span class="cstat-no" title="statement not covered" >['Gruntfile.js', 'libs/**/*.js', 'libs/**/**/*.js', 'test/*.js', 'bin/csvtojson',</span>
|
||||
'bin/csvtojson.js', 'devops/*.js'
|
||||
];
|
||||
<span class="cstat-no" title="statement not covered" > grunt.initConfig({</span>
|
||||
uglify: {
|
||||
client: {
|
||||
options: {
|
||||
mangle: true,
|
||||
banner: "/*Automatically Generated. Do not modify.*/\n"
|
||||
},
|
||||
src: "./dist/csvtojson.js",
|
||||
dest: "./dist/csvtojson.min.js",
|
||||
}
|
||||
},
|
||||
browserify: {
|
||||
dist: {
|
||||
src: "./browser_index.js",
|
||||
dest: "./dist/csvtojson.js"
|
||||
}
|
||||
},
|
||||
jshint: {
|
||||
all: {
|
||||
src: files,
|
||||
options: {
|
||||
'globals': { // false makes global variable readonly true is read/write
|
||||
'describe': false,
|
||||
'it': false
|
||||
},
|
||||
// see the docs for full list of options http://jshint.com/docs/options/
|
||||
'bitwise': true,
|
||||
'curly': true,
|
||||
'eqeqeq': true,
|
||||
'forin': true,
|
||||
'freeze': true,
|
||||
'funcscope': true,
|
||||
'futurehostile': true,
|
||||
'latedef': false,
|
||||
'maxcomplexity': 10, // arbitrary but anything over 10 quickly becomes hard to think about
|
||||
'maxdepth': 3, // also arbitrary. Deeply nested functions should be refactored to use helper functions.
|
||||
'maxparams': 4, // arbitrary. Consider using an object literal instead of list of params.
|
||||
'nocomma': true,
|
||||
//'nonew': true, // In the future when all objects are refactored to avoid new.
|
||||
//'strict': true, // in the future when all functions are closer to adhering to strict.
|
||||
'notypeof': true,
|
||||
'undef': true,
|
||||
'unused': true,
|
||||
'node': true // defines node globals
|
||||
}
|
||||
}
|
||||
},
|
||||
mochaTest: {
|
||||
test: {
|
||||
src: [files[3]]
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: files,
|
||||
tasks: ['newer:jshint:all', 'mochaTest'],
|
||||
options: {
|
||||
spawn: false,
|
||||
event: ['changed', 'added']
|
||||
}
|
||||
},
|
||||
wiki: {},
|
||||
});
|
||||
<span class="cstat-no" title="statement not covered" > grunt.registerTask('default', ['watch']);</span>
|
||||
<span class="cstat-no" title="statement not covered" > grunt.registerTask('test', ['mochaTest']);</span>
|
||||
<span class="cstat-no" title="statement not covered" > grunt.registerTask("build:browser",["browserify:dist","uglify:client"]);</span>
|
||||
};
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri May 11 2018 21:20:20 GMT+0100 (IST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../sorter.js"></script>
|
||||
<script src="../block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* https://tc39.es/ecma402/#sec-getnumberoption
|
||||
* @param options
|
||||
* @param property
|
||||
* @param min
|
||||
* @param max
|
||||
* @param fallback
|
||||
*/
|
||||
import { DefaultNumberOption } from './DefaultNumberOption';
|
||||
export function GetNumberOption(options, property, minimum, maximum, fallback) {
|
||||
var val = options[property];
|
||||
// @ts-expect-error
|
||||
return DefaultNumberOption(val, minimum, maximum, fallback);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scheduled.js","sourceRoot":"","sources":["../../../../src/internal/scheduled/scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAa1E,MAAM,UAAU,SAAS,CAAI,KAAyB,EAAE,SAAwB;IAC9E,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;YAC9B,OAAO,kBAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAC7C;QACD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;YACtB,OAAO,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SACxC;QACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACpB,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAC1C;QACD,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAChD;QACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;YACrB,OAAO,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAC3C;QACD,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE;YAC/B,OAAO,0BAA0B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SACrD;KACF;IACD,MAAM,gCAAgC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"normalize-range","version":"0.1.2","files":{"package.json":{"checkedAt":1678883670318,"integrity":"sha512-VAbG7+1ME70qCIN9ztoCF8q0ej1IMsoecybeo7g1Wmo66/2+XHTLhVnIdprkf6Mw7D/+fZd2ctyRyYJjXCYOpw==","mode":420,"size":1184},"license":{"checkedAt":1678883670318,"integrity":"sha512-/Tha6r7PzRZdYlX+DGAJROGAtJT+a2znFVhjIBiLidz9xf1AzzGBwXqPKD6vQkpJwz1fblqHLtT9doz8yErbbA==","mode":420,"size":1120},"readme.md":{"checkedAt":1678883670318,"integrity":"sha512-STHkL+6pB7j0XQfNkt9/Oi+JtKEJynAm1vhfi6QG9CxFsI7Y5LGNYnuAAKNVzIm9MP6XGwPJ/kx0TRlxJuobRA==","mode":420,"size":4013},"index.js":{"checkedAt":1678883670318,"integrity":"sha512-cz393TPSfgGQRUbf3wantlSTG8M5veCOTQhkCguk4PsV/+vu7Gv0RXv2FnrKjkiVANMcneJ5CP9sNGLVNrP6kg==","mode":420,"size":1454}}}
|
||||
@@ -0,0 +1,446 @@
|
||||
/**
|
||||
* The `node:test` module provides a standalone testing module.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.x/lib/test.js)
|
||||
*/
|
||||
declare module 'node:test' {
|
||||
/**
|
||||
* Programmatically start the test runner.
|
||||
* @since v18.9.0
|
||||
* @param options Configuration options for running tests.
|
||||
* @returns A {@link TapStream} that emits events about the test execution.
|
||||
*/
|
||||
function run(options?: RunOptions): TapStream;
|
||||
|
||||
/**
|
||||
* The `test()` function is the value imported from the test module. Each invocation of this
|
||||
* function results in the creation of a test point in the TAP output.
|
||||
*
|
||||
* The {@link TestContext} object passed to the fn argument can be used to perform actions
|
||||
* related to the current test. Examples include skipping the test, adding additional TAP
|
||||
* diagnostic information, or creating subtests.
|
||||
*
|
||||
* `test()` returns a {@link Promise} that resolves once the test completes. The return value
|
||||
* can usually be discarded for top level tests. However, the return value from subtests should
|
||||
* be used to prevent the parent test from finishing first and cancelling the subtest as shown
|
||||
* in the following example.
|
||||
*
|
||||
* ```js
|
||||
* test('top level test', async (t) => {
|
||||
* // The setTimeout() in the following subtest would cause it to outlive its
|
||||
* // parent test if 'await' is removed on the next line. Once the parent test
|
||||
* // completes, it will cancel any outstanding subtests.
|
||||
* await t.test('longer running subtest', async (t) => {
|
||||
* return new Promise((resolve, reject) => {
|
||||
* setTimeout(resolve, 1000);
|
||||
* });
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @since v18.0.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
* @param fn The function under test. The first argument to this function is a
|
||||
* {@link TestContext} object. If the test uses callbacks, the callback function is
|
||||
* passed as the second argument. Default: A no-op function.
|
||||
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
||||
*/
|
||||
function test(name?: string, fn?: TestFn): Promise<void>;
|
||||
function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
||||
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
|
||||
function test(fn?: TestFn): Promise<void>;
|
||||
|
||||
/**
|
||||
* @since v18.6.0
|
||||
* @param name The name of the suite, which is displayed when reporting suite results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the suite
|
||||
* @param fn The function under suite. Default: A no-op function.
|
||||
*/
|
||||
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
||||
function describe(name?: string, fn?: SuiteFn): void;
|
||||
function describe(options?: TestOptions, fn?: SuiteFn): void;
|
||||
function describe(fn?: SuiteFn): void;
|
||||
namespace describe {
|
||||
// Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
|
||||
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
||||
function skip(name?: string, fn?: SuiteFn): void;
|
||||
function skip(options?: TestOptions, fn?: SuiteFn): void;
|
||||
function skip(fn?: SuiteFn): void;
|
||||
|
||||
// Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
|
||||
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
||||
function todo(name?: string, fn?: SuiteFn): void;
|
||||
function todo(options?: TestOptions, fn?: SuiteFn): void;
|
||||
function todo(fn?: SuiteFn): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since v18.6.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
* @param fn The function under test. If the test uses callbacks, the callback function is
|
||||
* passed as the second argument. Default: A no-op function.
|
||||
*/
|
||||
function it(name?: string, options?: TestOptions, fn?: ItFn): void;
|
||||
function it(name?: string, fn?: ItFn): void;
|
||||
function it(options?: TestOptions, fn?: ItFn): void;
|
||||
function it(fn?: ItFn): void;
|
||||
namespace it {
|
||||
// Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
|
||||
function skip(name?: string, options?: TestOptions, fn?: ItFn): void;
|
||||
function skip(name?: string, fn?: ItFn): void;
|
||||
function skip(options?: TestOptions, fn?: ItFn): void;
|
||||
function skip(fn?: ItFn): void;
|
||||
|
||||
// Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
|
||||
function todo(name?: string, options?: TestOptions, fn?: ItFn): void;
|
||||
function todo(name?: string, fn?: ItFn): void;
|
||||
function todo(options?: TestOptions, fn?: ItFn): void;
|
||||
function todo(fn?: ItFn): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of a function under test. The first argument to this function is a
|
||||
* {@link TestContext} object. If the test uses callbacks, the callback function is passed as
|
||||
* the second argument.
|
||||
*/
|
||||
type TestFn = (t: TestContext, done: (result?: any) => void) => any;
|
||||
|
||||
/**
|
||||
* The type of a function under Suite.
|
||||
* If the test uses callbacks, the callback function is passed as an argument
|
||||
*/
|
||||
type SuiteFn = (done: (result?: any) => void) => void;
|
||||
|
||||
/**
|
||||
* The type of a function under test.
|
||||
* If the test uses callbacks, the callback function is passed as an argument
|
||||
*/
|
||||
type ItFn = (done: (result?: any) => void) => any;
|
||||
|
||||
interface RunOptions {
|
||||
/**
|
||||
* If a number is provided, then that many files would run in parallel.
|
||||
* If truthy, it would run (number of cpu cores - 1) files in parallel.
|
||||
* If falsy, it would only run one file at a time.
|
||||
* If unspecified, subtests inherit this value from their parent.
|
||||
* @default true
|
||||
*/
|
||||
concurrency?: number | boolean | undefined;
|
||||
|
||||
/**
|
||||
* An array containing the list of files to run.
|
||||
* If unspecified, the test runner execution model will be used.
|
||||
*/
|
||||
files?: readonly string[] | undefined;
|
||||
|
||||
/**
|
||||
* Allows aborting an in-progress test execution.
|
||||
* @default undefined
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the test will fail after.
|
||||
* If unspecified, subtests inherit this value from their parent.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number | undefined;
|
||||
|
||||
/**
|
||||
* Sets inspector port of test child process.
|
||||
* If a nullish value is provided, each process gets its own port,
|
||||
* incremented from the primary's `process.debugPort`.
|
||||
*/
|
||||
inspectPort?: number | (() => number) | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* A successful call of the `run()` method will return a new `TapStream` object,
|
||||
* streaming a [TAP](https://testanything.org/) output.
|
||||
* `TapStream` will emit events in the order of the tests' definitions.
|
||||
* @since v18.9.0
|
||||
*/
|
||||
interface TapStream extends NodeJS.ReadableStream {
|
||||
addListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
emit(event: 'test:diagnostic', message: string): boolean;
|
||||
emit(event: 'test:fail', data: TestFail): boolean;
|
||||
emit(event: 'test:pass', data: TestPass): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
on(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
on(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
on(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
once(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
once(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
interface TestFail {
|
||||
/**
|
||||
* The test duration.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The failure casing test to fail.
|
||||
*/
|
||||
error: Error;
|
||||
|
||||
/**
|
||||
* The test name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The ordinal number of the test.
|
||||
*/
|
||||
testNumber: number;
|
||||
|
||||
/**
|
||||
* Present if `context.todo` is called.
|
||||
*/
|
||||
todo?: string;
|
||||
|
||||
/**
|
||||
* Present if `context.skip` is called.
|
||||
*/
|
||||
skip?: string;
|
||||
}
|
||||
|
||||
interface TestPass {
|
||||
/**
|
||||
* The test duration.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The test name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The ordinal number of the test.
|
||||
*/
|
||||
testNumber: number;
|
||||
|
||||
/**
|
||||
* Present if `context.todo` is called.
|
||||
*/
|
||||
todo?: string;
|
||||
|
||||
/**
|
||||
* Present if `context.skip` is called.
|
||||
*/
|
||||
skip?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of `TestContext` is passed to each test function in order to interact with the
|
||||
* test runner. However, the `TestContext` constructor is not exposed as part of the API.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
interface TestContext {
|
||||
/**
|
||||
* This function is used to create a hook running before each subtest of the current test.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
beforeEach: typeof beforeEach;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after each subtest of the current test.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
afterEach: typeof afterEach;
|
||||
|
||||
/**
|
||||
* This function is used to write TAP diagnostics to the output. Any diagnostic information is
|
||||
* included at the end of the test's results. This function does not return a value.
|
||||
* @param message Message to be displayed as a TAP diagnostic.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
diagnostic(message: string): void;
|
||||
|
||||
/**
|
||||
* The name of the test.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only`
|
||||
* option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
|
||||
* command-line option, this function is a no-op.
|
||||
* @param shouldRunOnlyTests Whether or not to run `only` tests.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
runOnly(shouldRunOnlyTests: boolean): void;
|
||||
|
||||
/**
|
||||
* Can be used to abort test subtasks when the test has been aborted.
|
||||
* @since v18.7.0
|
||||
*/
|
||||
readonly signal: AbortSignal;
|
||||
|
||||
/**
|
||||
* This function causes the test's output to indicate the test as skipped. If `message` is
|
||||
* provided, it is included in the TAP output. Calling `skip()` does not terminate execution of
|
||||
* the test function. This function does not return a value.
|
||||
* @param message Optional skip message to be displayed in TAP output.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
skip(message?: string): void;
|
||||
|
||||
/**
|
||||
* This function adds a `TODO` directive to the test's output. If `message` is provided, it is
|
||||
* included in the TAP output. Calling `todo()` does not terminate execution of the test
|
||||
* function. This function does not return a value.
|
||||
* @param message Optional `TODO` message to be displayed in TAP output.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
todo(message?: string): void;
|
||||
|
||||
/**
|
||||
* This function is used to create subtests under the current test. This function behaves in
|
||||
* the same fashion as the top level {@link test} function.
|
||||
* @since v18.0.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
* @param fn The function under test. This first argument to this function is a
|
||||
* {@link TestContext} object. If the test uses callbacks, the callback function is
|
||||
* passed as the second argument. Default: A no-op function.
|
||||
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
||||
*/
|
||||
test: typeof test;
|
||||
}
|
||||
|
||||
interface TestOptions {
|
||||
/**
|
||||
* If a number is provided, then that many tests would run in parallel.
|
||||
* If truthy, it would run (number of cpu cores - 1) tests in parallel.
|
||||
* For subtests, it will be `Infinity` tests in parallel.
|
||||
* If falsy, it would only run one test at a time.
|
||||
* If unspecified, subtests inherit this value from their parent.
|
||||
* @default false
|
||||
*/
|
||||
concurrency?: number | boolean | undefined;
|
||||
|
||||
/**
|
||||
* If truthy, and the test context is configured to run `only` tests, then this test will be
|
||||
* run. Otherwise, the test is skipped.
|
||||
* @default false
|
||||
*/
|
||||
only?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Allows aborting an in-progress test.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
|
||||
/**
|
||||
* If truthy, the test is skipped. If a string is provided, that string is displayed in the
|
||||
* test results as the reason for skipping the test.
|
||||
* @default false
|
||||
*/
|
||||
skip?: boolean | string | undefined;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
* @since v18.7.0
|
||||
*/
|
||||
timeout?: number | undefined;
|
||||
|
||||
/**
|
||||
* If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in
|
||||
* the test results as the reason why the test is `TODO`.
|
||||
* @default false
|
||||
*/
|
||||
todo?: boolean | string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running before running a suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function before(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after running a suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function after(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running before each subtest of the current suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function beforeEach(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after each subtest of the current test.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function afterEach(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* The hook function. If the hook uses callbacks, the callback function is passed as the
|
||||
* second argument.
|
||||
*/
|
||||
type HookFn = (done: (result?: any) => void) => any;
|
||||
|
||||
/**
|
||||
* Configuration options for hooks.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
interface HookOptions {
|
||||
/**
|
||||
* Allows aborting an in-progress hook.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the hook will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number | undefined;
|
||||
}
|
||||
|
||||
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach };
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0.00317,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0.01587,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.00317,"35":0,"36":0,"37":0,"38":0.00317,"39":0,"40":0.00317,"41":0,"42":0,"43":0.00317,"44":0,"45":0,"46":0,"47":0.00635,"48":0.00635,"49":0,"50":0,"51":0,"52":0.0476,"53":0,"54":0,"55":0,"56":0.00317,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0.00317,"65":0,"66":0,"67":0,"68":0.00317,"69":0,"70":0,"71":0,"72":0.00317,"73":0,"74":0,"75":0.00317,"76":0,"77":0,"78":0.00317,"79":0,"80":0,"81":0.00317,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.00317,"92":0,"93":0,"94":0.00317,"95":0.00317,"96":0,"97":0,"98":0,"99":0.00317,"100":0.00317,"101":0.00317,"102":0.01587,"103":0.00317,"104":0.00635,"105":0.00317,"106":0.00635,"107":0.01269,"108":0.02538,"109":0.3998,"110":0.31095,"111":0.00635,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0.00317,"27":0,"28":0.00317,"29":0,"30":0,"31":0.00317,"32":0.00952,"33":0.00952,"34":0,"35":0,"36":0,"37":0,"38":0.00317,"39":0,"40":0.00635,"41":0,"42":0,"43":0.05077,"44":0.00317,"45":0,"46":0.00317,"47":0.00317,"48":0.00317,"49":0.04125,"50":0.00317,"51":0,"52":0,"53":0,"54":0,"55":0.00317,"56":0.00635,"57":0,"58":0.00635,"59":0,"60":0.00635,"61":0.00317,"62":0.00317,"63":0.00952,"64":0.00635,"65":0.00317,"66":0.00317,"67":0.01269,"68":0.00952,"69":0.00635,"70":0.00635,"71":0.01269,"72":0.00635,"73":0.00317,"74":0.00952,"75":0.00317,"76":0.00635,"77":0.00635,"78":0.00317,"79":0.02221,"80":0.00952,"81":0.02221,"83":0.00952,"84":0.00635,"85":0.02221,"86":0.01269,"87":0.01269,"88":0.00635,"89":0.00635,"90":0.00635,"91":0.00952,"92":0.00952,"93":0.00317,"94":0.00317,"95":0.01904,"96":0.00635,"97":0.00952,"98":0.03173,"99":0.01269,"100":0.01269,"101":0.00952,"102":0.02856,"103":0.03173,"104":0.01269,"105":0.03173,"106":0.02538,"107":0.06029,"108":0.16817,"109":4.70556,"110":1.31045,"111":0.00317,"112":0.00317,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0.00317,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0.00317,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0.00317,"62":0,"63":0.00317,"64":0.00317,"65":0.00317,"66":0,"67":0.01904,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0.01269,"80":0,"81":0,"82":0,"83":0,"84":0.00317,"85":0.01587,"86":0.00317,"87":0.00317,"88":0,"89":0,"90":0,"91":0.00317,"92":0,"93":0.01269,"94":0.19038,"95":0.18086,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0.00317,"13":0.01269,"14":0,"15":0.00317,"16":0.00317,"17":0,"18":0.00635,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00635,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0.00317,"107":0.00952,"108":0.00952,"109":0.20307,"110":0.26019},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.00317,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0.00317,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0.00317,"14.1":0.00635,"15.1":0.00317,"15.2-15.3":0.00317,"15.4":0.00317,"15.5":0.00635,"15.6":0.02538,"16.0":0.00317,"16.1":0.01904,"16.2":0.02221,"16.3":0.02856,"16.4":0},G:{"8":0.00055,"3.2":0.00109,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.01038,"6.0-6.1":0.00328,"7.0-7.1":0.04645,"8.1-8.4":0.00164,"9.0-9.2":0.00109,"9.3":0.08306,"10.0-10.2":0.00164,"10.3":0.04207,"11.0-11.2":0.01366,"11.3-11.4":0.00437,"12.0-12.1":0.0082,"12.2-12.5":0.2131,"13.0-13.1":0.00437,"13.2":0.0082,"13.3":0.01421,"13.4-13.7":0.03989,"14.0-14.4":0.10491,"14.5-14.8":0.18032,"15.0-15.1":0.07595,"15.2-15.3":0.10491,"15.4":0.1377,"15.5":0.21638,"15.6":0.38031,"16.0":0.61363,"16.1":0.89067,"16.2":0.86061,"16.3":0.77155,"16.4":0.00437},P:{"4":0.12422,"20":0.2588,"5.0-5.4":0.01035,"6.2-6.4":0,"7.2-7.4":0.09317,"8.2":0,"9.2":0.0207,"10.1":0.01035,"11.1-11.2":0.04141,"12.0":0.01035,"13.0":0.05176,"14.0":0.03106,"15.0":0.0207,"16.0":0.08282,"17.0":0.07246,"18.0":0.09317,"19.0":0.66253},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00499,"4.2-4.3":0.02991,"4.4":0,"4.4.3-4.4.4":0.12712},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0.01363,"9":0.00341,"10":0.00341,"11":0.06816,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.32087},H:{"0":0.43305},L:{"0":82.49636},R:{_:"0"},M:{"0":0.10923},Q:{"13.1":0}};
|
||||
Reference in New Issue
Block a user