WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

3
node_modules/@hapi/hoek/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,3 @@
Breaking changes are documented using GitHub issues, see [issues labeled "release notes"](https://github.com/hapijs/hoek/issues?q=is%3Aissue+label%3A%22release+notes%22).
If you want changes of a specific minor or patch release, you can browse the [GitHub milestones](https://github.com/hapijs/hoek/milestones?state=closed&direction=asc&sort=due_date).

12
node_modules/@hapi/hoek/LICENSE.md generated vendored Executable file
View File

@ -0,0 +1,12 @@
Copyright (c) 2011-2019, Sideway Inc, and project contributors
Copyright (c) 2011-2014, Walmart
Copyright (c) 2011, Yahoo Inc.
All rights reserved.
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.
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS 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 OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

14
node_modules/@hapi/hoek/README.md generated vendored Executable file
View File

@ -0,0 +1,14 @@
<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# hoek
Utility methods for the hapi ecosystem. This module is not intended to solve every problem for
everyone, but rather as a central place to store hapi-specific methods. If you're looking for a
general purpose utility module, check out [lodash](https://github.com/lodash/lodash) or
[underscore](https://github.com/jashkenas/underscore).
[![Build Status](https://secure.travis-ci.org/hapijs/hoek.svg)](http://travis-ci.org/hapijs/hoek)
## Documentation
[**API Reference**](API.md)

55
node_modules/@hapi/hoek/lib/applyToDefaults.js generated vendored Executable file
View File

@ -0,0 +1,55 @@
'use strict';
const Assert = require('./assert');
const Clone = require('./clone');
const Merge = require('./merge');
const Utils = require('./utils');
const internals = {};
module.exports = function (defaults, source, options = {}) {
Assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object');
Assert(!source || source === true || typeof source === 'object', 'Invalid source value: must be true, falsy or an object');
Assert(typeof options === 'object', 'Invalid options: must be an object');
if (!source) { // If no source, return null
return null;
}
if (options.shallow) {
return internals.applyToDefaultsWithShallow(defaults, source, options);
}
const copy = Clone(defaults);
if (source === true) { // If source is set to true, use defaults
return copy;
}
const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;
return Merge(copy, source, { nullOverride, mergeArrays: false });
};
internals.applyToDefaultsWithShallow = function (defaults, source, options) {
const keys = options.shallow;
Assert(Array.isArray(keys), 'Invalid keys');
options = Object.assign({}, options);
options.shallow = false;
const copy = Clone(defaults, { shallow: keys });
if (source === true) { // If source is set to true, use defaults
return copy;
}
const storage = Utils.store(source, keys); // Move shallow copy items to storage
Merge(copy, source, { mergeArrays: false, nullOverride: false }); // Deep copy the rest
Utils.restore(copy, source, storage); // Shallow copy the stored items and restore
return copy;
};

21
node_modules/@hapi/hoek/lib/assert.js generated vendored Executable file
View File

@ -0,0 +1,21 @@
'use strict';
const AssertError = require('./error');
const internals = {};
module.exports = function (condition, ...args) {
if (condition) {
return;
}
if (args.length === 1 &&
args[0] instanceof Error) {
throw args[0];
}
throw new AssertError(args);
};

29
node_modules/@hapi/hoek/lib/bench.js generated vendored Executable file
View File

@ -0,0 +1,29 @@
'use strict';
const internals = {};
module.exports = internals.Bench = class {
constructor() {
this.ts = 0;
this.reset();
}
reset() {
this.ts = internals.Bench.now();
}
elapsed() {
return internals.Bench.now() - this.ts;
}
static now() {
const ts = process.hrtime();
return (ts[0] * 1e3) + (ts[1] / 1e6);
}
};

12
node_modules/@hapi/hoek/lib/block.js generated vendored Executable file
View File

@ -0,0 +1,12 @@
'use strict';
const Ignore = require('./ignore');
const internals = {};
module.exports = function () {
return new Promise(Ignore); // $lab:coverage:ignore$
};

142
node_modules/@hapi/hoek/lib/clone.js generated vendored Executable file
View File

@ -0,0 +1,142 @@
'use strict';
const Types = require('./types');
const Utils = require('./utils');
const internals = {
needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])
};
module.exports = internals.clone = function (obj, options = {}, _seen = null) {
if (typeof obj !== 'object' ||
obj === null) {
return obj;
}
let clone = internals.clone;
let seen = _seen;
if (options.shallow) {
if (options.shallow !== true) {
return internals.cloneWithShallow(obj, options);
}
clone = (value) => value;
}
else {
seen = seen || new Map();
const lookup = seen.get(obj);
if (lookup) {
return lookup;
}
}
const baseProto = Types.getInternalProto(obj);
let newObj;
switch (baseProto) {
case Types.buffer:
return Buffer && Buffer.from(obj); // $lab:coverage:ignore$
case Types.date:
return new Date(obj.getTime());
case Types.regex:
return new RegExp(obj);
case Types.array:
newObj = [];
break;
default:
if (options.prototype !== false) { // Defaults to true
const proto = Object.getPrototypeOf(obj);
if (proto &&
proto.isImmutable) {
return obj;
}
if (internals.needsProtoHack.has(baseProto)) {
newObj = new proto.constructor();
if (proto !== baseProto) {
Object.setPrototypeOf(newObj, proto);
}
}
else {
newObj = Object.create(proto);
}
}
else if (internals.needsProtoHack.has(baseProto)) {
newObj = new baseProto.constructor();
}
else {
newObj = {};
}
}
if (seen) {
seen.set(obj, newObj); // Set seen, since obj could recurse
}
if (baseProto === Types.set) {
for (const value of obj) {
newObj.add(clone(value, options, seen));
}
}
else if (baseProto === Types.map) {
for (const [key, value] of obj) {
newObj.set(key, clone(value, options, seen));
}
}
const keys = Utils.keys(obj, options);
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
if (baseProto === Types.array &&
key === 'length') {
continue;
}
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
if (descriptor &&
(descriptor.get || descriptor.set)) {
Object.defineProperty(newObj, key, descriptor);
}
else {
Object.defineProperty(newObj, key, {
enumerable: descriptor ? descriptor.enumerable : true,
writable: true,
configurable: true,
value: clone(obj[key], options, seen)
});
}
}
if (baseProto === Types.array) {
newObj.length = obj.length;
}
return newObj;
};
internals.cloneWithShallow = function (source, options) {
const keys = options.shallow;
options = Object.assign({}, options);
options.shallow = false;
const storage = Utils.store(source, keys); // Move shallow copy items to storage
const copy = internals.clone(source, options); // Deep copy the rest
Utils.restore(copy, source, storage); // Shallow copy the stored items and restore
return copy;
};

156
node_modules/@hapi/hoek/lib/contain.js generated vendored Executable file
View File

@ -0,0 +1,156 @@
'use strict';
const Assert = require('./assert');
const DeepEqual = require('./deepEqual');
const EscapeRegex = require('./escapeRegex');
const Utils = require('./utils');
const internals = {};
module.exports = function (ref, values, options = {}) { // options: { deep, once, only, part, symbols }
/*
string -> string(s)
array -> item(s)
object -> key(s)
object -> object (key:value)
*/
let valuePairs = null;
if (typeof ref === 'object' &&
typeof values === 'object' &&
!Array.isArray(ref) &&
!Array.isArray(values)) {
valuePairs = values;
const symbols = Object.getOwnPropertySymbols(values).filter(Object.prototype.propertyIsEnumerable.bind(values));
values = [...Object.keys(values), ...symbols];
}
else {
values = [].concat(values);
}
Assert(typeof ref === 'string' || typeof ref === 'object', 'Reference must be string or an object');
Assert(values.length, 'Values array cannot be empty');
let compare;
let compareFlags;
if (options.deep) {
compare = DeepEqual;
const hasOnly = options.only !== undefined;
const hasPart = options.part !== undefined;
compareFlags = {
prototype: hasOnly ? options.only : hasPart ? !options.part : false,
part: hasOnly ? !options.only : hasPart ? options.part : false
};
}
else {
compare = (a, b) => a === b;
}
let misses = false;
const matches = new Array(values.length);
for (let i = 0; i < matches.length; ++i) {
matches[i] = 0;
}
if (typeof ref === 'string') {
if (ref === '') {
if (values.length === 1 && values[0] === '' || // '' contains ''
!options.once && !values.some((v) => v !== '')) { // '' contains multiple '' if !once
return true;
}
return false;
}
let pattern = '(';
for (let i = 0; i < values.length; ++i) {
const value = values[i];
Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');
pattern += (i ? '|' : '') + EscapeRegex(value);
}
const regex = new RegExp(pattern + ')', 'g');
const leftovers = ref.replace(regex, ($0, $1) => {
const index = values.indexOf($1);
++matches[index];
return ''; // Remove from string
});
misses = !!leftovers;
}
else if (Array.isArray(ref)) {
if (!ref.length) {
return false;
}
const onlyOnce = !!(options.only && options.once);
if (onlyOnce && ref.length !== values.length) {
return false;
}
for (let i = 0; i < ref.length; ++i) {
let matched = false;
for (let j = 0; j < values.length && matched === false; ++j) {
if (!onlyOnce || matches[j] === 0) {
matched = compare(values[j], ref[i], compareFlags) && j;
}
}
if (matched !== false) {
++matches[matched];
}
else {
misses = true;
}
}
}
else {
const keys = Utils.keys(ref, options);
if (!keys.length) {
return false;
}
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const pos = values.indexOf(key);
if (pos !== -1) {
if (valuePairs &&
!compare(valuePairs[key], ref[key], compareFlags)) {
return false;
}
++matches[pos];
}
else {
misses = true;
}
}
}
if (options.only) {
if (misses || !options.once) {
return !misses;
}
}
let result = false;
for (let i = 0; i < matches.length; ++i) {
result = result || !!matches[i];
if ((options.once && matches[i] > 1) ||
(!options.part && !matches[i])) {
return false;
}
}
return result;
};

302
node_modules/@hapi/hoek/lib/deepEqual.js generated vendored Executable file
View File

@ -0,0 +1,302 @@
'use strict';
const Types = require('./types');
const internals = {
mismatched: null
};
module.exports = function (obj, ref, options) {
options = Object.assign({ prototype: true }, options);
return !!internals.isDeepEqual(obj, ref, options, []);
};
internals.isDeepEqual = function (obj, ref, options, seen) {
if (obj === ref) { // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql
return obj !== 0 || 1 / obj === 1 / ref;
}
const type = typeof obj;
if (type !== typeof ref) {
return false;
}
if (obj === null ||
ref === null) {
return false;
}
if (type === 'function') {
if (!options.deepFunction ||
obj.toString() !== ref.toString()) {
return false;
}
// Continue as object
}
else if (type !== 'object') {
return obj !== obj && ref !== ref; // NaN
}
const instanceType = internals.getSharedType(obj, ref, !!options.prototype);
switch (instanceType) {
case Types.buffer:
return Buffer && Buffer.prototype.equals.call(obj, ref); // $lab:coverage:ignore$
case Types.promise:
return obj === ref;
case Types.regex:
return obj.toString() === ref.toString();
case internals.mismatched:
return false;
}
for (let i = seen.length - 1; i >= 0; --i) {
if (seen[i].isSame(obj, ref)) {
return true; // If previous comparison failed, it would have stopped execution
}
}
seen.push(new internals.SeenEntry(obj, ref));
try {
return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);
}
finally {
seen.pop();
}
};
internals.getSharedType = function (obj, ref, checkPrototype) {
if (checkPrototype) {
if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {
return internals.mismatched;
}
return Types.getInternalProto(obj);
}
const type = Types.getInternalProto(obj);
if (type !== Types.getInternalProto(ref)) {
return internals.mismatched;
}
return type;
};
internals.valueOf = function (obj) {
const objValueOf = obj.valueOf;
if (objValueOf === undefined) {
return obj;
}
try {
return objValueOf.call(obj);
}
catch (err) {
return err;
}
};
internals.hasOwnEnumerableProperty = function (obj, key) {
return Object.prototype.propertyIsEnumerable.call(obj, key);
};
internals.isSetSimpleEqual = function (obj, ref) {
for (const entry of obj) {
if (!ref.has(entry)) {
return false;
}
}
return true;
};
internals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {
const { isDeepEqual, valueOf, hasOwnEnumerableProperty } = internals;
const { keys, getOwnPropertySymbols } = Object;
if (instanceType === Types.array) {
if (options.part) {
// Check if any index match any other index
for (let i = 0; i < obj.length; ++i) {
const objValue = obj[i];
for (let j = 0; j < ref.length; ++j) {
if (isDeepEqual(objValue, ref[j], options, seen)) {
return true;
}
}
}
}
else {
if (obj.length !== ref.length) {
return false;
}
for (let i = 0; i < obj.length; ++i) {
if (!isDeepEqual(obj[i], ref[i], options, seen)) {
return false;
}
}
return true;
}
}
else if (instanceType === Types.set) {
if (obj.size !== ref.size) {
return false;
}
if (!internals.isSetSimpleEqual(obj, ref)) {
// Check for deep equality
const ref2 = new Set(ref);
for (const objEntry of obj) {
if (ref2.delete(objEntry)) {
continue;
}
let found = false;
for (const refEntry of ref2) {
if (isDeepEqual(objEntry, refEntry, options, seen)) {
ref2.delete(refEntry);
found = true;
break;
}
}
if (!found) {
return false;
}
}
}
}
else if (instanceType === Types.map) {
if (obj.size !== ref.size) {
return false;
}
for (const [key, value] of obj) {
if (value === undefined && !ref.has(key)) {
return false;
}
if (!isDeepEqual(value, ref.get(key), options, seen)) {
return false;
}
}
}
else if (instanceType === Types.error) {
// Always check name and message
if (obj.name !== ref.name || obj.message !== ref.message) {
return false;
}
}
// Check .valueOf()
const valueOfObj = valueOf(obj);
const valueOfRef = valueOf(ref);
if (!(obj === valueOfObj && ref === valueOfRef) &&
!isDeepEqual(valueOfObj, valueOfRef, options, seen)) {
return false;
}
// Check properties
const objKeys = keys(obj);
if (!options.part &&
objKeys.length !== keys(ref).length) {
return false;
}
for (let i = 0; i < objKeys.length; ++i) {
const key = objKeys[i];
if (!hasOwnEnumerableProperty(ref, key)) {
return false;
}
if (options.skip &&
options.skip.includes(key)) {
continue;
}
if (!isDeepEqual(obj[key], ref[key], options, seen)) {
return false;
}
}
// Check symbols
if (options.symbols !== false) { // Defaults to true
const objSymbols = getOwnPropertySymbols(obj);
const refSymbols = new Set(getOwnPropertySymbols(ref));
for (let i = 0; i < objSymbols.length; ++i) {
const key = objSymbols[i];
if (hasOwnEnumerableProperty(obj, key)) {
if (!hasOwnEnumerableProperty(ref, key)) {
return false;
}
if (!(options.skip && options.skip.includes(key)) &&
!isDeepEqual(obj[key], ref[key], options, seen)) {
return false;
}
}
else if (hasOwnEnumerableProperty(ref, key)) {
return false;
}
refSymbols.delete(key);
}
for (const key of refSymbols) {
if (hasOwnEnumerableProperty(ref, key)) {
return false;
}
}
}
return true;
};
internals.SeenEntry = class {
constructor(obj, ref) {
this.obj = obj;
this.ref = ref;
}
isSame(obj, ref) {
return this.obj === obj && this.ref === ref;
}
};

23
node_modules/@hapi/hoek/lib/error.js generated vendored Executable file
View File

@ -0,0 +1,23 @@
'use strict';
const Stringify = require('./stringify');
const internals = {};
module.exports = class extends Error {
constructor(args) {
const msgs = args
.filter((arg) => arg !== '')
.map((arg) => {
return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);
});
super(msgs.join(' ') || 'Unknown error');
Error.captureStackTrace(this, exports.assert);
}
};

16
node_modules/@hapi/hoek/lib/escapeHeaderAttribute.js generated vendored Executable file
View File

@ -0,0 +1,16 @@
'use strict';
const Assert = require('./assert');
const internals = {};
module.exports = function (attribute) {
// Allowed value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9, \, "
Assert(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(attribute), 'Bad attribute value (' + attribute + ')');
return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // Escape quotes and slash
};

87
node_modules/@hapi/hoek/lib/escapeHtml.js generated vendored Executable file
View File

@ -0,0 +1,87 @@
'use strict';
const internals = {};
module.exports = function (input) {
if (!input) {
return '';
}
let escaped = '';
for (let i = 0; i < input.length; ++i) {
const charCode = input.charCodeAt(i);
if (internals.isSafe(charCode)) {
escaped += input[i];
}
else {
escaped += internals.escapeHtmlChar(charCode);
}
}
return escaped;
};
internals.escapeHtmlChar = function (charCode) {
const namedEscape = internals.namedHtml[charCode];
if (typeof namedEscape !== 'undefined') {
return namedEscape;
}
if (charCode >= 256) {
return '&#' + charCode + ';';
}
const hexValue = charCode.toString(16).padStart(2, '0');
return `&#x${hexValue};`;
};
internals.isSafe = function (charCode) {
return (typeof internals.safeCharCodes[charCode] !== 'undefined');
};
internals.namedHtml = {
'38': '&amp;',
'60': '&lt;',
'62': '&gt;',
'34': '&quot;',
'160': '&nbsp;',
'162': '&cent;',
'163': '&pound;',
'164': '&curren;',
'169': '&copy;',
'174': '&reg;'
};
internals.safeCharCodes = (function () {
const safe = {};
for (let i = 32; i < 123; ++i) {
if ((i >= 97) || // a-z
(i >= 65 && i <= 90) || // A-Z
(i >= 48 && i <= 57) || // 0-9
i === 32 || // space
i === 46 || // .
i === 44 || // ,
i === 45 || // -
i === 58 || // :
i === 95) { // _
safe[i] = null;
}
}
return safe;
}());

41
node_modules/@hapi/hoek/lib/escapeJson.js generated vendored Executable file
View File

@ -0,0 +1,41 @@
'use strict';
const internals = {};
module.exports = function (input) {
if (!input) {
return '';
}
const lessThan = 0x3C;
const greaterThan = 0x3E;
const andSymbol = 0x26;
const lineSeperator = 0x2028;
// replace method
let charCode;
return input.replace(/[<>&\u2028\u2029]/g, (match) => {
charCode = match.charCodeAt(0);
if (charCode === lessThan) {
return '\\u003c';
}
if (charCode === greaterThan) {
return '\\u003e';
}
if (charCode === andSymbol) {
return '\\u0026';
}
if (charCode === lineSeperator) {
return '\\u2028';
}
return '\\u2029';
});
};

11
node_modules/@hapi/hoek/lib/escapeRegex.js generated vendored Executable file
View File

@ -0,0 +1,11 @@
'use strict';
const internals = {};
module.exports = function (string) {
// Escape ^$.*+-?=!:|\/()[]{},
return string.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, '\\$&');
};

20
node_modules/@hapi/hoek/lib/flatten.js generated vendored Executable file
View File

@ -0,0 +1,20 @@
'use strict';
const internals = {};
module.exports = internals.flatten = function (array, target) {
const result = target || [];
for (let i = 0; i < array.length; ++i) {
if (Array.isArray(array[i])) {
internals.flatten(array[i], result);
}
else {
result.push(array[i]);
}
}
return result;
};

6
node_modules/@hapi/hoek/lib/ignore.js generated vendored Executable file
View File

@ -0,0 +1,6 @@
'use strict';
const internals = {};
module.exports = function () { };

442
node_modules/@hapi/hoek/lib/index.d.ts generated vendored Executable file
View File

@ -0,0 +1,442 @@
/**
Performs a deep comparison of the two values including support for circular dependencies, prototype, and enumerable properties.
@param obj - The value being compared.
@param ref - The reference value used for comparison.
@return true when the two values are equal, otherwise false.
*/
export function deepEqual(obj: any, ref: any, options?: deepEqual.Options): boolean;
declare namespace deepEqual {
interface Options {
/**
Compare functions with difference references by comparing their internal code and properties.
@default false
*/
readonly deepFunction?: boolean;
/**
Allow partial match.
@default false
*/
readonly part?: boolean;
/**
Compare the objects' prototypes.
@default true
*/
readonly prototype?: boolean;
/**
List of object keys to ignore different values of.
@default null
*/
readonly skip?: (string | symbol)[];
/**
Compare symbol properties.
@default true
*/
readonly symbols?: boolean;
}
}
/**
Clone any value, object, or array.
@param obj - The value being cloned.
@param options - Optional settings.
@returns A deep clone of `obj`.
*/
export function clone<T>(obj: T, options?: clone.Options): T;
declare namespace clone {
interface Options {
/**
Clone the object's prototype.
@default true
*/
readonly prototype?: boolean;
/**
Include symbol properties.
@default true
*/
readonly symbols?: boolean;
/**
Shallow clone the specified keys.
@default undefined
*/
readonly shallow?: string[] | string[][] | boolean;
}
}
/**
Merge all the properties of source into target.
@param target - The object being modified.
@param source - The object used to copy properties from.
@param options - Optional settings.
@returns The `target` object.
*/
export function merge<T1 extends object, T2 extends object>(target: T1, source: T2, options?: merge.Options): T1 & T2;
declare namespace merge {
interface Options {
/**
When true, null value from `source` overrides existing value in `target`.
@default true
*/
readonly nullOverride?: boolean;
/**
When true, array value from `source` is merged with the existing value in `target`.
@default false
*/
readonly mergeArrays?: boolean;
/**
Compare symbol properties.
@default true
*/
readonly symbols?: boolean;
}
}
/**
Apply source to a copy of the defaults.
@param defaults - An object with the default values to use of `options` does not contain the same keys.
@param source - The source used to override the `defaults`.
@param options - Optional settings.
@returns A copy of `defaults` with `source` keys overriding any conflicts.
*/
export function applyToDefaults<T extends object>(defaults: Partial<T>, source: Partial<T> | boolean | null, options?: applyToDefaults.Options): Partial<T>;
declare namespace applyToDefaults {
interface Options {
/**
When true, null value from `source` overrides existing value in `target`.
@default true
*/
readonly nullOverride?: boolean;
/**
Shallow clone the specified keys.
@default undefined
*/
readonly shallow?: string[] | string[][];
}
}
/**
Find the common unique items in two arrays.
@param array1 - The first array to compare.
@param array2 - The second array to compare.
@param options - Optional settings.
@return - An array of the common items. If `justFirst` is true, returns the first common item.
*/
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): Array<T1 | T2>;
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): T1 | T2;
declare namespace intersect {
type Array<T> = ArrayLike<T> | Set<T> | null;
interface Options {
/**
When true, return the first overlapping value.
@default false
*/
readonly first?: boolean;
}
}
/**
Checks if the reference value contains the provided values.
@param ref - The reference string, array, or object.
@param values - A single or array of values to find within `ref`. If `ref` is an object, `values` can be a key name, an array of key names, or an object with key-value pairs to compare.
@return true if the value contains the provided values, otherwise false.
*/
export function contain(ref: string, values: string | string[], options?: contain.Options): boolean;
export function contain(ref: any[], values: any, options?: contain.Options): boolean;
export function contain(ref: object, values: string | string[] | object, options?: contain.Options): boolean;
declare namespace contain {
interface Options {
/**
Perform a deep comparison.
@default false
*/
readonly deep?: boolean;
/**
Allow only one occurrence of each value.
@default false
*/
readonly once?: boolean;
/**
Allow only values explicitly listed.
@default false
*/
readonly only?: boolean;
/**
Allow partial match.
@default false
*/
readonly part?: boolean;
/**
Include symbol properties.
@default true
*/
readonly symbols?: boolean;
}
}
/**
Flatten an array with sub arrays
@param array - an array of items or other arrays to flatten.
@param target - if provided, an array to shallow copy the flattened `array` items to
@return a flat array of the provided values (appended to `target` is provided).
*/
export function flatten<T>(array: ArrayLike<T | ReadonlyArray<T>>, target?: ArrayLike<T | ReadonlyArray<T>>): T[];
/**
Convert an object key chain string to reference.
@param obj - the object from which to look up the value.
@param chain - the string path of the requested value. The chain string is split into key names using `options.separator`, or an array containing each individual key name. A chain including negative numbers will work like negative indices on an array.
@return The value referenced by the chain if found, otherwise undefined. If chain is null, undefined, or false, the object itself will be returned.
*/
export function reach(obj: object | null, chain: string | (string | number)[] | false | null | undefined, options?: reach.Options): any;
declare namespace reach {
interface Options {
/**
String to split chain path on. Defaults to '.'.
@default false
*/
readonly separator?: string;
/**
Value to return if the path or value is not present. No default value.
@default false
*/
readonly default?: any;
/**
If true, will throw an error on missing member in the chain. Default to false.
@default false
*/
readonly strict?: boolean;
/**
If true, allows traversing functions for properties. false will throw an error if a function is part of the chain.
@default true
*/
readonly functions?: boolean;
/**
If true, allows traversing Set and Map objects for properties. false will return undefined regardless of the Set or Map passed.
@default false
*/
readonly iterables?: boolean;
}
}
/**
Replace string parameters (using format "{path.to.key}") with their corresponding object key values using `Hoek.reach()`.
@param obj - the object from which to look up the value.
@param template - the string containing {} enclosed key paths to be replaced.
@return The template string with the {} enclosed keys replaced with looked-up values.
*/
export function reachTemplate(obj: object | null, template: string, options?: reach.Options): string;
/**
Throw an error if condition is falsey.
@param condition - If `condition` is not truthy, an exception is thrown.
@param error - The error thrown if the condition fails.
@return Does not return a value but throws if the `condition` is falsey.
*/
export function assert(condition: any, error: Error): void;
/**
Throw an error if condition is falsey.
@param condition - If `condition` is not truthy, an exception is thrown.
@param args - Any number of values, concatenated together (space separated) to create the error message.
@return Does not return a value but throws if the `condition` is falsey.
*/
export function assert(condition: any, ...args: any): void;
/**
A benchmarking timer, using the internal node clock for maximum accuracy.
*/
export class Bench {
constructor();
/** The starting timestamp expressed in the number of milliseconds since the epoch. */
ts: number;
/** The time in milliseconds since the object was created. */
elapsed(): number;
/** Reset the `ts` value to now. */
reset(): void;
/** The current time in milliseconds since the epoch. */
static now(): number;
}
/**
Escape string for Regex construction by prefixing all reserved characters with a backslash.
@param string - The string to be escaped.
@return The escaped string.
*/
export function escapeRegex(string: string): string;
/**
Escape string for usage as an attribute value in HTTP headers.
@param attribute - The string to be escaped.
@return The escaped string. Will throw on invalid characters that are not supported to be escaped.
*/
export function escapeHeaderAttribute(attribute: string): string;
/**
Escape string for usage in HTML.
@param string - The string to be escaped.
@return The escaped string.
*/
export function escapeHtml(string: string): string;
/**
Escape string for usage in JSON.
@param string - The string to be escaped.
@return The escaped string.
*/
export function escapeJson(string: string): string;
/**
Wraps a function to ensure it can only execute once.
@param method - The function to be wrapped.
@return The wrapped function.
*/
export function once<T extends Function>(method: T): T;
/**
A reusable no-op function.
*/
export function ignore(...ignore: any): void;
/**
Converts a JavaScript value to a JavaScript Object Notation (JSON) string with protection against thrown errors.
@param value A JavaScript value, usually an object or array, to be converted.
@param replacer The JSON.stringify() `replacer` argument.
@param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
@return The JSON string. If the operation fails, an error string value is returned (no exception thrown).
*/
export function stringify(value: any, replacer?: any, space?: string | number): string;
/**
Returns a Promise that resolves after the requested timeout.
@param timeout - The number of milliseconds to wait before resolving the Promise.
@return A Promise.
*/
export function wait(timeout?: number): Promise<void>;
/**
Returns a Promise that never resolves.
*/
export function block(): Promise<void>;

28
node_modules/@hapi/hoek/lib/index.js generated vendored Executable file
View File

@ -0,0 +1,28 @@
'use strict';
const internals = {};
module.exports = {
applyToDefaults: require('./applyToDefaults'),
assert: require('./assert'),
Bench: require('./bench'),
block: require('./block'),
clone: require('./clone'),
contain: require('./contain'),
deepEqual: require('./deepEqual'),
Error: require('./error'),
escapeHeaderAttribute: require('./escapeHeaderAttribute'),
escapeHtml: require('./escapeHtml'),
escapeJson: require('./escapeJson'),
escapeRegex: require('./escapeRegex'),
flatten: require('./flatten'),
ignore: require('./ignore'),
intersect: require('./intersect'),
merge: require('./merge'),
once: require('./once'),
reach: require('./reach'),
reachTemplate: require('./reachTemplate'),
stringify: require('./stringify'),
wait: require('./wait')
};

41
node_modules/@hapi/hoek/lib/intersect.js generated vendored Executable file
View File

@ -0,0 +1,41 @@
'use strict';
const internals = {};
module.exports = function (array1, array2, options = {}) {
if (!array1 ||
!array2) {
return (options.first ? null : []);
}
const common = [];
const hash = (Array.isArray(array1) ? new Set(array1) : array1);
const found = new Set();
for (const value of array2) {
if (internals.has(hash, value) &&
!found.has(value)) {
if (options.first) {
return value;
}
common.push(value);
found.add(value);
}
}
return (options.first ? null : common);
};
internals.has = function (ref, key) {
if (typeof ref.has === 'function') {
return ref.has(key);
}
return ref[key] !== undefined;
};

74
node_modules/@hapi/hoek/lib/merge.js generated vendored Executable file
View File

@ -0,0 +1,74 @@
'use strict';
const Assert = require('./assert');
const Clone = require('./clone');
const Utils = require('./utils');
const internals = {};
module.exports = internals.merge = function (target, source, options) {
Assert(target && typeof target === 'object', 'Invalid target value: must be an object');
Assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object');
if (!source) {
return target;
}
options = Object.assign({ nullOverride: true, mergeArrays: true }, options);
if (Array.isArray(source)) {
Assert(Array.isArray(target), 'Cannot merge array onto an object');
if (!options.mergeArrays) {
target.length = 0; // Must not change target assignment
}
for (let i = 0; i < source.length; ++i) {
target.push(Clone(source[i], { symbols: options.symbols }));
}
return target;
}
const keys = Utils.keys(source, options);
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
if (key === '__proto__' ||
!Object.prototype.propertyIsEnumerable.call(source, key)) {
continue;
}
const value = source[key];
if (value &&
typeof value === 'object') {
if (!target[key] ||
typeof target[key] !== 'object' ||
(Array.isArray(target[key]) !== Array.isArray(value)) ||
value instanceof Date ||
(Buffer && Buffer.isBuffer(value)) || // $lab:coverage:ignore$
value instanceof RegExp) {
target[key] = Clone(value, { symbols: options.symbols });
}
else {
internals.merge(target[key], value, options);
}
}
else {
if (value !== null &&
value !== undefined) { // Explicit to preserve empty strings
target[key] = value;
}
else if (options.nullOverride) {
target[key] = value;
}
}
}
return target;
};

23
node_modules/@hapi/hoek/lib/once.js generated vendored Executable file
View File

@ -0,0 +1,23 @@
'use strict';
const internals = {};
module.exports = function (method) {
if (method._hoekOnce) {
return method;
}
let once = false;
const wrapped = function (...args) {
if (!once) {
once = true;
method(...args);
}
};
wrapped._hoekOnce = true;
return wrapped;
};

76
node_modules/@hapi/hoek/lib/reach.js generated vendored Executable file
View File

@ -0,0 +1,76 @@
'use strict';
const Assert = require('./assert');
const internals = {};
module.exports = function (obj, chain, options) {
if (chain === false ||
chain === null ||
chain === undefined) {
return obj;
}
options = options || {};
if (typeof options === 'string') {
options = { separator: options };
}
const isChainArray = Array.isArray(chain);
Assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain');
const path = isChainArray ? chain : chain.split(options.separator || '.');
let ref = obj;
for (let i = 0; i < path.length; ++i) {
let key = path[i];
const type = options.iterables && internals.iterables(ref);
if (Array.isArray(ref) ||
type === 'set') {
const number = Number(key);
if (Number.isInteger(number)) {
key = number < 0 ? ref.length + number : number;
}
}
if (!ref ||
typeof ref === 'function' && options.functions === false || // Defaults to true
!type && ref[key] === undefined) {
Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);
Assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);
ref = options.default;
break;
}
if (!type) {
ref = ref[key];
}
else if (type === 'set') {
ref = [...ref][key];
}
else { // type === 'map'
ref = ref.get(key);
}
}
return ref;
};
internals.iterables = function (ref) {
if (ref instanceof Set) {
return 'set';
}
if (ref instanceof Map) {
return 'map';
}
};

16
node_modules/@hapi/hoek/lib/reachTemplate.js generated vendored Executable file
View File

@ -0,0 +1,16 @@
'use strict';
const Reach = require('./reach');
const internals = {};
module.exports = function (obj, template, options) {
return template.replace(/{([^}]+)}/g, ($0, chain) => {
const value = Reach(obj, chain, options);
return (value === undefined || value === null ? '' : value);
});
};

14
node_modules/@hapi/hoek/lib/stringify.js generated vendored Executable file
View File

@ -0,0 +1,14 @@
'use strict';
const internals = {};
module.exports = function (...args) {
try {
return JSON.stringify.apply(null, args);
}
catch (err) {
return '[Cannot display object: ' + err.message + ']';
}
};

51
node_modules/@hapi/hoek/lib/types.js generated vendored Executable file
View File

@ -0,0 +1,51 @@
'use strict';
const internals = {};
exports = module.exports = {
array: Array.prototype,
buffer: Buffer && Buffer.prototype, // $lab:coverage:ignore$
date: Date.prototype,
error: Error.prototype,
generic: Object.prototype,
map: Map.prototype,
promise: Promise.prototype,
regex: RegExp.prototype,
set: Set.prototype,
weakMap: WeakMap.prototype,
weakSet: WeakSet.prototype
};
internals.typeMap = new Map([
['[object Error]', exports.error],
['[object Map]', exports.map],
['[object Promise]', exports.promise],
['[object Set]', exports.set],
['[object WeakMap]', exports.weakMap],
['[object WeakSet]', exports.weakSet]
]);
exports.getInternalProto = function (obj) {
if (Array.isArray(obj)) {
return exports.array;
}
if (Buffer && obj instanceof Buffer) { // $lab:coverage:ignore$
return exports.buffer;
}
if (obj instanceof Date) {
return exports.date;
}
if (obj instanceof RegExp) {
return exports.regex;
}
const objName = Object.prototype.toString.call(obj);
return internals.typeMap.get(objName) || exports.generic;
};

54
node_modules/@hapi/hoek/lib/utils.js generated vendored Executable file
View File

@ -0,0 +1,54 @@
'use strict';
const Reach = require('./reach');
const internals = {};
exports.keys = function (obj, options = {}) {
return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true
};
exports.store = function (source, keys) {
const storage = new Map();
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const value = Reach(source, key);
if (typeof value === 'object' ||
typeof value === 'function') {
storage.set(key, value);
internals.reachSet(source, key, undefined);
}
}
return storage;
};
exports.restore = function (copy, source, storage) {
for (const [key, value] of storage) {
internals.reachSet(copy, key, value);
internals.reachSet(source, key, value);
}
};
internals.reachSet = function (obj, key, value) {
const path = Array.isArray(key) ? key : key.split('.');
let ref = obj;
for (let i = 0; i < path.length; ++i) {
const segment = path[i];
if (i + 1 === path.length) {
ref[segment] = value;
}
ref = ref[segment];
}
};

9
node_modules/@hapi/hoek/lib/wait.js generated vendored Executable file
View File

@ -0,0 +1,9 @@
'use strict';
const internals = {};
module.exports = function (timeout) {
return new Promise((resolve) => setTimeout(resolve, timeout));
};

58
node_modules/@hapi/hoek/package.json generated vendored Executable file
View File

@ -0,0 +1,58 @@
{
"_from": "@hapi/hoek@8.x.x",
"_id": "@hapi/hoek@8.2.1",
"_inBundle": false,
"_integrity": "sha512-JPiBy+oSmsq3St7XlipfN5pNA6bDJ1kpa73PrK/zR29CVClDVqy04AanM/M/qx5bSF+I61DdCfAvRrujau+zRg==",
"_location": "/@hapi/hoek",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@hapi/hoek@8.x.x",
"name": "@hapi/hoek",
"escapedName": "@hapi%2fhoek",
"scope": "@hapi",
"rawSpec": "8.x.x",
"saveSpec": null,
"fetchSpec": "8.x.x"
},
"_requiredBy": [
"/@hapi/joi",
"/@hapi/topo"
],
"_resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.1.tgz",
"_shasum": "924af04cbb22e17359c620d2a9c946e63f58eb77",
"_spec": "@hapi/hoek@8.x.x",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/@hapi/joi",
"bugs": {
"url": "https://github.com/hapijs/hoek/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "General purpose node utilities",
"devDependencies": {
"@hapi/code": "6.x.x",
"@hapi/lab": "20.x.x"
},
"files": [
"lib"
],
"homepage": "https://github.com/hapijs/hoek#readme",
"keywords": [
"utilities"
],
"license": "BSD-3-Clause",
"main": "lib/index.js",
"name": "@hapi/hoek",
"repository": {
"type": "git",
"url": "git://github.com/hapijs/hoek.git"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
},
"types": "lib/index.d.ts",
"version": "8.2.1"
}