aboutsummaryrefslogtreecommitdiff
path: root/node_modules/yargs/build/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/yargs/build/lib/utils')
-rw-r--r--node_modules/yargs/build/lib/utils/apply-extends.js59
-rw-r--r--node_modules/yargs/build/lib/utils/is-promise.js5
-rw-r--r--node_modules/yargs/build/lib/utils/levenshtein.js34
-rw-r--r--node_modules/yargs/build/lib/utils/maybe-async-result.js17
-rw-r--r--node_modules/yargs/build/lib/utils/obj-filter.js10
-rw-r--r--node_modules/yargs/build/lib/utils/process-argv.js17
-rw-r--r--node_modules/yargs/build/lib/utils/set-blocking.js12
-rw-r--r--node_modules/yargs/build/lib/utils/which-module.js10
8 files changed, 0 insertions, 164 deletions
diff --git a/node_modules/yargs/build/lib/utils/apply-extends.js b/node_modules/yargs/build/lib/utils/apply-extends.js
deleted file mode 100644
index 0e593b4..0000000
--- a/node_modules/yargs/build/lib/utils/apply-extends.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import { YError } from '../yerror.js';
-let previouslyVisitedConfigs = [];
-let shim;
-export function applyExtends(config, cwd, mergeExtends, _shim) {
- shim = _shim;
- let defaultConfig = {};
- if (Object.prototype.hasOwnProperty.call(config, 'extends')) {
- if (typeof config.extends !== 'string')
- return defaultConfig;
- const isPath = /\.json|\..*rc$/.test(config.extends);
- let pathToDefault = null;
- if (!isPath) {
- try {
- pathToDefault = require.resolve(config.extends);
- }
- catch (_err) {
- return config;
- }
- }
- else {
- pathToDefault = getPathToDefaultConfig(cwd, config.extends);
- }
- checkForCircularExtends(pathToDefault);
- previouslyVisitedConfigs.push(pathToDefault);
- defaultConfig = isPath
- ? JSON.parse(shim.readFileSync(pathToDefault, 'utf8'))
- : require(config.extends);
- delete config.extends;
- defaultConfig = applyExtends(defaultConfig, shim.path.dirname(pathToDefault), mergeExtends, shim);
- }
- previouslyVisitedConfigs = [];
- return mergeExtends
- ? mergeDeep(defaultConfig, config)
- : Object.assign({}, defaultConfig, config);
-}
-function checkForCircularExtends(cfgPath) {
- if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) {
- throw new YError(`Circular extended configurations: '${cfgPath}'.`);
- }
-}
-function getPathToDefaultConfig(cwd, pathToExtend) {
- return shim.path.resolve(cwd, pathToExtend);
-}
-function mergeDeep(config1, config2) {
- const target = {};
- function isObject(obj) {
- return obj && typeof obj === 'object' && !Array.isArray(obj);
- }
- Object.assign(target, config1);
- for (const key of Object.keys(config2)) {
- if (isObject(config2[key]) && isObject(target[key])) {
- target[key] = mergeDeep(config1[key], config2[key]);
- }
- else {
- target[key] = config2[key];
- }
- }
- return target;
-}
diff --git a/node_modules/yargs/build/lib/utils/is-promise.js b/node_modules/yargs/build/lib/utils/is-promise.js
deleted file mode 100644
index d250c08..0000000
--- a/node_modules/yargs/build/lib/utils/is-promise.js
+++ /dev/null
@@ -1,5 +0,0 @@
-export function isPromise(maybePromise) {
- return (!!maybePromise &&
- !!maybePromise.then &&
- typeof maybePromise.then === 'function');
-}
diff --git a/node_modules/yargs/build/lib/utils/levenshtein.js b/node_modules/yargs/build/lib/utils/levenshtein.js
deleted file mode 100644
index 60575ef..0000000
--- a/node_modules/yargs/build/lib/utils/levenshtein.js
+++ /dev/null
@@ -1,34 +0,0 @@
-export function levenshtein(a, b) {
- if (a.length === 0)
- return b.length;
- if (b.length === 0)
- return a.length;
- const matrix = [];
- let i;
- for (i = 0; i <= b.length; i++) {
- matrix[i] = [i];
- }
- let j;
- for (j = 0; j <= a.length; j++) {
- matrix[0][j] = j;
- }
- for (i = 1; i <= b.length; i++) {
- for (j = 1; j <= a.length; j++) {
- if (b.charAt(i - 1) === a.charAt(j - 1)) {
- matrix[i][j] = matrix[i - 1][j - 1];
- }
- else {
- if (i > 1 &&
- j > 1 &&
- b.charAt(i - 2) === a.charAt(j - 1) &&
- b.charAt(i - 1) === a.charAt(j - 2)) {
- matrix[i][j] = matrix[i - 2][j - 2] + 1;
- }
- else {
- matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
- }
- }
- }
- }
- return matrix[b.length][a.length];
-}
diff --git a/node_modules/yargs/build/lib/utils/maybe-async-result.js b/node_modules/yargs/build/lib/utils/maybe-async-result.js
deleted file mode 100644
index 8c6a40c..0000000
--- a/node_modules/yargs/build/lib/utils/maybe-async-result.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { isPromise } from './is-promise.js';
-export function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
- throw err;
-}) {
- try {
- const result = isFunction(getResult) ? getResult() : getResult;
- return isPromise(result)
- ? result.then((result) => resultHandler(result))
- : resultHandler(result);
- }
- catch (err) {
- return errorHandler(err);
- }
-}
-function isFunction(arg) {
- return typeof arg === 'function';
-}
diff --git a/node_modules/yargs/build/lib/utils/obj-filter.js b/node_modules/yargs/build/lib/utils/obj-filter.js
deleted file mode 100644
index cd68ad2..0000000
--- a/node_modules/yargs/build/lib/utils/obj-filter.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import { objectKeys } from '../typings/common-types.js';
-export function objFilter(original = {}, filter = () => true) {
- const obj = {};
- objectKeys(original).forEach(key => {
- if (filter(key, original[key])) {
- obj[key] = original[key];
- }
- });
- return obj;
-}
diff --git a/node_modules/yargs/build/lib/utils/process-argv.js b/node_modules/yargs/build/lib/utils/process-argv.js
deleted file mode 100644
index 74dc9e4..0000000
--- a/node_modules/yargs/build/lib/utils/process-argv.js
+++ /dev/null
@@ -1,17 +0,0 @@
-function getProcessArgvBinIndex() {
- if (isBundledElectronApp())
- return 0;
- return 1;
-}
-function isBundledElectronApp() {
- return isElectronApp() && !process.defaultApp;
-}
-function isElectronApp() {
- return !!process.versions.electron;
-}
-export function hideBin(argv) {
- return argv.slice(getProcessArgvBinIndex() + 1);
-}
-export function getProcessArgvBin() {
- return process.argv[getProcessArgvBinIndex()];
-}
diff --git a/node_modules/yargs/build/lib/utils/set-blocking.js b/node_modules/yargs/build/lib/utils/set-blocking.js
deleted file mode 100644
index 88fb806..0000000
--- a/node_modules/yargs/build/lib/utils/set-blocking.js
+++ /dev/null
@@ -1,12 +0,0 @@
-export default function setBlocking(blocking) {
- if (typeof process === 'undefined')
- return;
- [process.stdout, process.stderr].forEach(_stream => {
- const stream = _stream;
- if (stream._handle &&
- stream.isTTY &&
- typeof stream._handle.setBlocking === 'function') {
- stream._handle.setBlocking(blocking);
- }
- });
-}
diff --git a/node_modules/yargs/build/lib/utils/which-module.js b/node_modules/yargs/build/lib/utils/which-module.js
deleted file mode 100644
index 5974e22..0000000
--- a/node_modules/yargs/build/lib/utils/which-module.js
+++ /dev/null
@@ -1,10 +0,0 @@
-export default function whichModule(exported) {
- if (typeof require === 'undefined')
- return null;
- for (let i = 0, files = Object.keys(require.cache), mod; i < files.length; i++) {
- mod = require.cache[files[i]];
- if (mod.exports === exported)
- return mod;
- }
- return null;
-}