inferred-types 0.55.1 → 0.55.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/constants/dist/index.cjs +3 -3
- package/modules/inferred-types/dist/index.cjs +1913 -1856
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +23183 -22963
- package/modules/inferred-types/dist/index.js +1906 -1853
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +2217 -2154
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +9376 -9248
- package/modules/runtime/dist/index.js +2210 -2151
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.cjs +3 -3
- package/modules/types/dist/index.d.ts +11912 -11820
- package/package.json +15 -13
|
@@ -2611,54 +2611,6 @@ function asApi(api2) {
|
|
|
2611
2611
|
function handleDoneFn(val, call_bare_fn = false) {
|
|
2612
2612
|
return isObject(val) || isFunction(val) ? isDoneFn(val) ? val.done() : isFunction(val) ? call_bare_fn ? val() : val : val : isFunction(val) ? call_bare_fn ? val() : val : val;
|
|
2613
2613
|
}
|
|
2614
|
-
function addPropsToFn(fn2, clone_fn) {
|
|
2615
|
-
const localFn = clone_fn ? (...args) => fn2(args) : fn2;
|
|
2616
|
-
return (obj) => {
|
|
2617
|
-
for (const k in obj) {
|
|
2618
|
-
localFn[k] = obj[k];
|
|
2619
|
-
}
|
|
2620
|
-
return localFn;
|
|
2621
|
-
};
|
|
2622
|
-
}
|
|
2623
|
-
function addFnToProps(props, _clone_fn) {
|
|
2624
|
-
return (fn2) => {
|
|
2625
|
-
const localFn = (...args) => fn2(args);
|
|
2626
|
-
for (const k in props) {
|
|
2627
|
-
localFn[k] = props[k];
|
|
2628
|
-
}
|
|
2629
|
-
return localFn;
|
|
2630
|
-
};
|
|
2631
|
-
}
|
|
2632
|
-
function createCssSelector(_opt) {
|
|
2633
|
-
return (...selectors) => {
|
|
2634
|
-
return selectors.join(" ");
|
|
2635
|
-
};
|
|
2636
|
-
}
|
|
2637
|
-
function createFnWithProps(fn2, props, narrowing = false) {
|
|
2638
|
-
const fnWithProps = fn2;
|
|
2639
|
-
for (const prop of Object.keys(props)) {
|
|
2640
|
-
fnWithProps[prop] = props[prop];
|
|
2641
|
-
}
|
|
2642
|
-
return isTrue(narrowing) ? fnWithProps : fnWithProps;
|
|
2643
|
-
}
|
|
2644
|
-
function createFnWithPropsExplicit(fn2, props) {
|
|
2645
|
-
const fnWithProps = fn2;
|
|
2646
|
-
for (const prop of Object.keys(props)) {
|
|
2647
|
-
fnWithProps[prop] = props[prop];
|
|
2648
|
-
}
|
|
2649
|
-
return fnWithProps;
|
|
2650
|
-
}
|
|
2651
|
-
function defineObj(literal2 = {}) {
|
|
2652
|
-
return (wide22 = {}) => {
|
|
2653
|
-
const obj = literal2 ? { ...literal2, ...wide22 } : wide22;
|
|
2654
|
-
return obj;
|
|
2655
|
-
};
|
|
2656
|
-
}
|
|
2657
|
-
function defineTuple(...values) {
|
|
2658
|
-
return values.map(
|
|
2659
|
-
(i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i
|
|
2660
|
-
);
|
|
2661
|
-
}
|
|
2662
2614
|
function objectToApi(obj, def = null) {
|
|
2663
2615
|
const transformed = Object.keys(obj).reduce(
|
|
2664
2616
|
(acc, key) => {
|
|
@@ -4471,21 +4423,6 @@ function ifSameType(value, comparator, same, notSame) {
|
|
|
4471
4423
|
typeof value === typeof comparator ? same(value) : notSame(value)
|
|
4472
4424
|
);
|
|
4473
4425
|
}
|
|
4474
|
-
function isNull(value) {
|
|
4475
|
-
return value === null;
|
|
4476
|
-
}
|
|
4477
|
-
function isString(value) {
|
|
4478
|
-
return typeof value === "string";
|
|
4479
|
-
}
|
|
4480
|
-
function isSymbol(value) {
|
|
4481
|
-
return typeof value === "symbol";
|
|
4482
|
-
}
|
|
4483
|
-
function isNumber(value) {
|
|
4484
|
-
return typeof value === "number";
|
|
4485
|
-
}
|
|
4486
|
-
function isScalar(value) {
|
|
4487
|
-
return isString(value) || isNumber(value) || isSymbol(value) || isNull(value);
|
|
4488
|
-
}
|
|
4489
4426
|
function ifScalar(value, ifCallback, notCallback) {
|
|
4490
4427
|
const result2 = isScalar(value) ? ifCallback(
|
|
4491
4428
|
value
|
|
@@ -4708,7 +4645,7 @@ function get(value, dotPath, options = {
|
|
|
4708
4645
|
return outcome;
|
|
4709
4646
|
}
|
|
4710
4647
|
function keysOf(container) {
|
|
4711
|
-
const keys = Array.isArray(container) ? Object.keys(container).map((i) => Number(i)) : isObject(container) ?
|
|
4648
|
+
const keys = isVueRef(container) ? ["value"] : Array.isArray(container) ? Object.keys(container).map((i) => Number(i)) : isObject(container) ? Object.keys(container) : [];
|
|
4712
4649
|
return keys;
|
|
4713
4650
|
}
|
|
4714
4651
|
function callback() {
|
|
@@ -4796,88 +4733,6 @@ function withKeys(dict, ...keys) {
|
|
|
4796
4733
|
function withoutKeys(dict, ...exclude) {
|
|
4797
4734
|
return omit(dict, ...exclude);
|
|
4798
4735
|
}
|
|
4799
|
-
function doesExtend(type) {
|
|
4800
|
-
return (val) => {
|
|
4801
|
-
let response = false;
|
|
4802
|
-
if (isString(val)) {
|
|
4803
|
-
if (type === "string") {
|
|
4804
|
-
response = true;
|
|
4805
|
-
}
|
|
4806
|
-
if (type.startsWith("string(")) {
|
|
4807
|
-
const literals = stripAfter(
|
|
4808
|
-
stripBefore(type, "string("),
|
|
4809
|
-
")"
|
|
4810
|
-
).split(/,\s*/);
|
|
4811
|
-
if (literals.includes(val)) {
|
|
4812
|
-
response = true;
|
|
4813
|
-
}
|
|
4814
|
-
}
|
|
4815
|
-
}
|
|
4816
|
-
if (isNumber(val)) {
|
|
4817
|
-
if (type === "number") {
|
|
4818
|
-
response = true;
|
|
4819
|
-
}
|
|
4820
|
-
if (type.startsWith("number(")) {
|
|
4821
|
-
const literals = stripAfter(
|
|
4822
|
-
stripBefore(type, "number("),
|
|
4823
|
-
")"
|
|
4824
|
-
).split(/,\s*/).map(Number);
|
|
4825
|
-
if (literals.includes(val)) {
|
|
4826
|
-
response = true;
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
}
|
|
4830
|
-
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
4831
|
-
response = true;
|
|
4832
|
-
}
|
|
4833
|
-
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
4834
|
-
response = true;
|
|
4835
|
-
}
|
|
4836
|
-
if (isBoolean(val)) {
|
|
4837
|
-
if (type === "boolean") {
|
|
4838
|
-
response = true;
|
|
4839
|
-
}
|
|
4840
|
-
if (type === "true" && val === true || type === "false" && val === false) {
|
|
4841
|
-
response = true;
|
|
4842
|
-
}
|
|
4843
|
-
}
|
|
4844
|
-
if (isNarrowableObject(val)) {
|
|
4845
|
-
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
4846
|
-
response = true;
|
|
4847
|
-
}
|
|
4848
|
-
if (startsWith("Dict<")(type)) {
|
|
4849
|
-
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
4850
|
-
if (match) {
|
|
4851
|
-
const { value } = match;
|
|
4852
|
-
const isOpt = value.includes(`Opt<`);
|
|
4853
|
-
const values = objectValues(val);
|
|
4854
|
-
if (values.every((i) => isOpt ? isString(i) || isUndefined(i) : isString(i)) && type === "Dict<string, string>" || values.every((i) => isOpt ? isUndefined(i) || isNumber(i) : isNumber(i)) && type === "Dict<string, number>" || values.every((i) => isOpt ? isUndefined(i) || isBoolean(i) : isBoolean(i)) && type === "Dict<string, boolean>") {
|
|
4855
|
-
response = true;
|
|
4856
|
-
}
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4860
|
-
if (isArray(val)) {
|
|
4861
|
-
if (type === "Array" || type === "Array<unknown>") {
|
|
4862
|
-
return true;
|
|
4863
|
-
}
|
|
4864
|
-
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
4865
|
-
response = true;
|
|
4866
|
-
}
|
|
4867
|
-
}
|
|
4868
|
-
if (isMap(val)) {
|
|
4869
|
-
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
4870
|
-
response = true;
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
|
-
if (isSetContainer(val)) {
|
|
4874
|
-
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
4875
|
-
response = true;
|
|
4876
|
-
}
|
|
4877
|
-
}
|
|
4878
|
-
return response;
|
|
4879
|
-
};
|
|
4880
|
-
}
|
|
4881
4736
|
function withoutValue(wo) {
|
|
4882
4737
|
return (obj) => {
|
|
4883
4738
|
const output = {};
|
|
@@ -4930,6 +4785,54 @@ function fnMeta(func) {
|
|
|
4930
4785
|
};
|
|
4931
4786
|
}
|
|
4932
4787
|
var wrapFn = "NOT IMPLEMENTED";
|
|
4788
|
+
function addPropsToFn(fn2, clone_fn) {
|
|
4789
|
+
const localFn = clone_fn ? (...args) => fn2(args) : fn2;
|
|
4790
|
+
return (obj) => {
|
|
4791
|
+
for (const k in obj) {
|
|
4792
|
+
localFn[k] = obj[k];
|
|
4793
|
+
}
|
|
4794
|
+
return localFn;
|
|
4795
|
+
};
|
|
4796
|
+
}
|
|
4797
|
+
function addFnToProps(props, _clone_fn) {
|
|
4798
|
+
return (fn2) => {
|
|
4799
|
+
const localFn = (...args) => fn2(args);
|
|
4800
|
+
for (const k in props) {
|
|
4801
|
+
localFn[k] = props[k];
|
|
4802
|
+
}
|
|
4803
|
+
return localFn;
|
|
4804
|
+
};
|
|
4805
|
+
}
|
|
4806
|
+
function createCssSelector(_opt) {
|
|
4807
|
+
return (...selectors) => {
|
|
4808
|
+
return selectors.join(" ");
|
|
4809
|
+
};
|
|
4810
|
+
}
|
|
4811
|
+
function createFnWithProps(fn2, props, narrowing = false) {
|
|
4812
|
+
const fnWithProps = fn2;
|
|
4813
|
+
for (const prop of Object.keys(props)) {
|
|
4814
|
+
fnWithProps[prop] = props[prop];
|
|
4815
|
+
}
|
|
4816
|
+
return isTrue(narrowing) ? fnWithProps : fnWithProps;
|
|
4817
|
+
}
|
|
4818
|
+
function createFnWithPropsExplicit(fn2, props) {
|
|
4819
|
+
const fnWithProps = fn2;
|
|
4820
|
+
for (const prop of Object.keys(props)) {
|
|
4821
|
+
fnWithProps[prop] = props[prop];
|
|
4822
|
+
}
|
|
4823
|
+
return fnWithProps;
|
|
4824
|
+
}
|
|
4825
|
+
function defineObj(literal2 = {}) {
|
|
4826
|
+
return (wide22 = {}) => {
|
|
4827
|
+
const obj = literal2 ? { ...literal2, ...wide22 } : wide22;
|
|
4828
|
+
return obj;
|
|
4829
|
+
};
|
|
4830
|
+
}
|
|
4831
|
+
function defineTuple(...values) {
|
|
4832
|
+
return values.map(
|
|
4833
|
+
(i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i
|
|
4834
|
+
);
|
|
4835
|
+
}
|
|
4933
4836
|
function asArray(thing) {
|
|
4934
4837
|
return Array.isArray(thing) === true ? thing : typeof thing === "undefined" ? [] : [thing];
|
|
4935
4838
|
}
|
|
@@ -5112,312 +5015,270 @@ function ensureTrailing(content, ensure) {
|
|
|
5112
5015
|
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
5113
5016
|
);
|
|
5114
5017
|
}
|
|
5115
|
-
function
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5018
|
+
function getTypeSubtype(str) {
|
|
5019
|
+
if (isTypeSubtype(str)) {
|
|
5020
|
+
const [t, st] = str.split("/");
|
|
5021
|
+
return [t, st];
|
|
5022
|
+
} else {
|
|
5023
|
+
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
5024
|
+
err.name = "InvalidTypeSubtype";
|
|
5025
|
+
throw err;
|
|
5026
|
+
}
|
|
5120
5027
|
}
|
|
5121
|
-
function
|
|
5122
|
-
return
|
|
5028
|
+
function identity(...values) {
|
|
5029
|
+
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
5123
5030
|
}
|
|
5124
|
-
function
|
|
5125
|
-
|
|
5031
|
+
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
5032
|
+
if (ch.length !== 1) {
|
|
5033
|
+
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
5034
|
+
}
|
|
5035
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
5126
5036
|
}
|
|
5127
|
-
function
|
|
5128
|
-
|
|
5037
|
+
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
5038
|
+
if (ch.length !== 1) {
|
|
5039
|
+
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
5040
|
+
}
|
|
5041
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
5129
5042
|
}
|
|
5130
|
-
function
|
|
5131
|
-
|
|
5043
|
+
function parseTemplate(template) {
|
|
5044
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
5045
|
+
let lastIndex = 0;
|
|
5046
|
+
let match;
|
|
5047
|
+
const segments = [];
|
|
5048
|
+
while (match = pattern.exec(template)) {
|
|
5049
|
+
const [fullMatch, varName, asType2] = match;
|
|
5050
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
5051
|
+
if (staticPart) {
|
|
5052
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
5053
|
+
}
|
|
5054
|
+
segments.push({
|
|
5055
|
+
dynamic: true,
|
|
5056
|
+
varName,
|
|
5057
|
+
type: asType2 ? asType2 : "string"
|
|
5058
|
+
});
|
|
5059
|
+
lastIndex = match.index + fullMatch.length;
|
|
5060
|
+
}
|
|
5061
|
+
const remainder = template.slice(lastIndex);
|
|
5062
|
+
if (remainder) {
|
|
5063
|
+
segments.push({ dynamic: false, text: remainder });
|
|
5064
|
+
}
|
|
5065
|
+
return segments;
|
|
5132
5066
|
}
|
|
5133
|
-
function
|
|
5134
|
-
return
|
|
5067
|
+
function escapeRegex(str) {
|
|
5068
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5135
5069
|
}
|
|
5136
|
-
function
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
return false;
|
|
5154
|
-
}
|
|
5155
|
-
;
|
|
5156
|
-
const daysInMonth = new Date(year, month, 0).getDate();
|
|
5157
|
-
if (day < 1 || day > daysInMonth) {
|
|
5158
|
-
return false;
|
|
5159
|
-
}
|
|
5160
|
-
;
|
|
5161
|
-
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
5162
|
-
if (tzMatch) {
|
|
5163
|
-
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
5164
|
-
const numHours = Number.parseInt(tzHours, 10);
|
|
5165
|
-
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
5166
|
-
if (numHours > 14 || numMinutes > 59) {
|
|
5167
|
-
return false;
|
|
5168
|
-
}
|
|
5169
|
-
if (numHours === 14 && numMinutes > 0) {
|
|
5170
|
-
return false;
|
|
5070
|
+
function buildRegexPattern(segments) {
|
|
5071
|
+
let regexStr = "^";
|
|
5072
|
+
for (const seg of segments) {
|
|
5073
|
+
if (!seg.dynamic) {
|
|
5074
|
+
regexStr += escapeRegex(seg.text);
|
|
5075
|
+
} else {
|
|
5076
|
+
switch (seg.type) {
|
|
5077
|
+
case "string":
|
|
5078
|
+
regexStr += "(.*?)";
|
|
5079
|
+
break;
|
|
5080
|
+
case "number":
|
|
5081
|
+
regexStr += "(\\d+)";
|
|
5082
|
+
break;
|
|
5083
|
+
case "boolean":
|
|
5084
|
+
regexStr += "(true|false)";
|
|
5085
|
+
break;
|
|
5086
|
+
}
|
|
5171
5087
|
}
|
|
5172
5088
|
}
|
|
5173
|
-
|
|
5089
|
+
regexStr += "$";
|
|
5090
|
+
return new RegExp(regexStr);
|
|
5174
5091
|
}
|
|
5175
|
-
function
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5092
|
+
function convertValue(type, value) {
|
|
5093
|
+
switch (type) {
|
|
5094
|
+
case "string":
|
|
5095
|
+
return value;
|
|
5096
|
+
case "number":
|
|
5097
|
+
return Number(value);
|
|
5098
|
+
case "boolean":
|
|
5099
|
+
return value === "true";
|
|
5181
5100
|
}
|
|
5182
5101
|
}
|
|
5183
|
-
function
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
5189
|
-
} else {
|
|
5102
|
+
function matchTemplate(template, test) {
|
|
5103
|
+
const segments = parseTemplate(template);
|
|
5104
|
+
const regex = buildRegexPattern(segments);
|
|
5105
|
+
const match = regex.exec(test);
|
|
5106
|
+
if (!match)
|
|
5190
5107
|
return false;
|
|
5108
|
+
let captureIndex = 1;
|
|
5109
|
+
const result2 = {};
|
|
5110
|
+
for (const seg of segments) {
|
|
5111
|
+
if (seg.dynamic) {
|
|
5112
|
+
const rawVal = match[captureIndex++];
|
|
5113
|
+
if (rawVal === void 0)
|
|
5114
|
+
return false;
|
|
5115
|
+
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
5116
|
+
}
|
|
5191
5117
|
}
|
|
5118
|
+
return result2;
|
|
5192
5119
|
}
|
|
5193
|
-
function
|
|
5194
|
-
|
|
5195
|
-
return
|
|
5196
|
-
}
|
|
5197
|
-
return false;
|
|
5198
|
-
}
|
|
5120
|
+
function infer(inference) {
|
|
5121
|
+
return (test) => {
|
|
5122
|
+
return matchTemplate(inference, test);
|
|
5123
|
+
};
|
|
5199
5124
|
}
|
|
5200
|
-
function
|
|
5201
|
-
|
|
5202
|
-
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
5203
|
-
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5204
|
-
} else {
|
|
5205
|
-
return false;
|
|
5206
|
-
}
|
|
5125
|
+
function idLiteral(o) {
|
|
5126
|
+
return { ...o, id: o.id };
|
|
5207
5127
|
}
|
|
5208
|
-
function
|
|
5209
|
-
|
|
5210
|
-
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
5211
|
-
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5212
|
-
} else {
|
|
5213
|
-
return false;
|
|
5214
|
-
}
|
|
5128
|
+
function nameLiteral(o) {
|
|
5129
|
+
return o;
|
|
5215
5130
|
}
|
|
5216
|
-
function
|
|
5217
|
-
return
|
|
5131
|
+
function kindLiteral(o) {
|
|
5132
|
+
return o;
|
|
5218
5133
|
}
|
|
5219
|
-
function
|
|
5220
|
-
return
|
|
5134
|
+
function idTypeGuard(_o) {
|
|
5135
|
+
return true;
|
|
5221
5136
|
}
|
|
5222
|
-
function
|
|
5223
|
-
return
|
|
5137
|
+
function literal(obj) {
|
|
5138
|
+
return obj;
|
|
5224
5139
|
}
|
|
5225
|
-
function
|
|
5226
|
-
|
|
5227
|
-
return false;
|
|
5228
|
-
}
|
|
5229
|
-
return isObject(val) && typeof val.format === "function" && typeof val.year === "function" && typeof val.month === "function" && typeof val.date === "function" && "_isAMomentObject" in val && "_isValid" in val && typeof val.add === "function" && typeof val.subtract === "function" && typeof val.toISOString === "function" && typeof val.isValid === "function";
|
|
5140
|
+
function lowercase(str) {
|
|
5141
|
+
return str.toLowerCase();
|
|
5230
5142
|
}
|
|
5231
|
-
function
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5143
|
+
function narrow(...values) {
|
|
5144
|
+
return values.length === 1 ? values[0] : values;
|
|
5145
|
+
}
|
|
5146
|
+
function pathJoin(...segments) {
|
|
5147
|
+
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
5148
|
+
const original_path = segments.join("/");
|
|
5149
|
+
const pre = original_path.startsWith("/") ? "/" : "";
|
|
5150
|
+
const post = original_path.endsWith("/") ? "/" : "";
|
|
5151
|
+
return `${pre}${clean_path}${post}`;
|
|
5152
|
+
}
|
|
5153
|
+
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
5154
|
+
function getPhoneCountryCode(phone) {
|
|
5155
|
+
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
5156
|
+
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
5157
|
+
...NUMERIC_CHAR2
|
|
5158
|
+
) : "";
|
|
5159
|
+
}
|
|
5160
|
+
function removePhoneCountryCode(phone) {
|
|
5161
|
+
const countryCode = getPhoneCountryCode(phone);
|
|
5162
|
+
return countryCode !== "" ? stripLeading(stripLeading(
|
|
5163
|
+
phone.trim(),
|
|
5164
|
+
"+",
|
|
5165
|
+
"00"
|
|
5166
|
+
), countryCode).trim() : phone.trim();
|
|
5167
|
+
}
|
|
5168
|
+
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
5169
|
+
function endingIn(word, postfix) {
|
|
5170
|
+
switch (postfix) {
|
|
5171
|
+
case "is":
|
|
5172
|
+
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
5173
|
+
case "singular-noun":
|
|
5174
|
+
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
5175
|
+
case "f":
|
|
5176
|
+
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
5177
|
+
case "y":
|
|
5178
|
+
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
5179
|
+
default:
|
|
5180
|
+
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
5244
5181
|
}
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5182
|
+
}
|
|
5183
|
+
function pluralize(word) {
|
|
5184
|
+
const right = rightWhitespace(word);
|
|
5185
|
+
const w = word.trimEnd();
|
|
5186
|
+
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
5187
|
+
return `${result2}${right}`;
|
|
5188
|
+
}
|
|
5189
|
+
function retainAfter(content, ...find2) {
|
|
5190
|
+
const idx = Math.min(
|
|
5191
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
5192
|
+
);
|
|
5193
|
+
const min = Math.min(...find2.map((i) => i.length));
|
|
5194
|
+
let len = Math.max(...find2.map((i) => i.length));
|
|
5195
|
+
if (min !== len) {
|
|
5196
|
+
if (!find2.includes(content.slice(idx, len))) {
|
|
5197
|
+
len = min;
|
|
5255
5198
|
}
|
|
5256
5199
|
}
|
|
5257
|
-
return
|
|
5200
|
+
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
5258
5201
|
}
|
|
5259
|
-
function
|
|
5260
|
-
const
|
|
5261
|
-
|
|
5262
|
-
|
|
5202
|
+
function retainAfterInclusive(content, ...find2) {
|
|
5203
|
+
const minFound = Math.min(
|
|
5204
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
5205
|
+
);
|
|
5206
|
+
return minFound > 0 ? content.slice(minFound) : "";
|
|
5207
|
+
}
|
|
5208
|
+
function retainChars(content, ...retain2) {
|
|
5209
|
+
const chars = asChars(content);
|
|
5210
|
+
return chars.filter((c) => retain2.includes(c)).join("");
|
|
5211
|
+
}
|
|
5212
|
+
function retainUntil(content, ...find2) {
|
|
5213
|
+
const chars = asChars(content);
|
|
5214
|
+
let idx = 0;
|
|
5215
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
5216
|
+
idx = idx + 1;
|
|
5263
5217
|
}
|
|
5264
|
-
|
|
5265
|
-
const targetWeek = getWeekNumber(targetDate);
|
|
5266
|
-
return currentWeek === targetWeek;
|
|
5218
|
+
return idx === 0 ? "" : content.slice(0, idx);
|
|
5267
5219
|
}
|
|
5268
|
-
function
|
|
5269
|
-
const
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
return date.getFullYear() === currentYear;
|
|
5274
|
-
} else {
|
|
5275
|
-
return false;
|
|
5276
|
-
}
|
|
5220
|
+
function retainUntilInclusive(content, ...find2) {
|
|
5221
|
+
const chars = asChars(content);
|
|
5222
|
+
let idx = 0;
|
|
5223
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
5224
|
+
idx = idx + 1;
|
|
5277
5225
|
}
|
|
5278
|
-
return
|
|
5226
|
+
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
5279
5227
|
}
|
|
5280
|
-
function
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
5284
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
5285
|
-
return stripAfter(test.toISOString(), "T") === getToday();
|
|
5286
|
-
} else if (isLuxonDateTime(test)) {
|
|
5287
|
-
return stripAfter(test.toISO(), "T") === getToday();
|
|
5288
|
-
}
|
|
5289
|
-
return false;
|
|
5290
|
-
}
|
|
5291
|
-
function isTomorrow(test) {
|
|
5292
|
-
if (isString(test)) {
|
|
5293
|
-
const justDate = stripAfter(test, "T");
|
|
5294
|
-
return isIsoExplicitDate(justDate) && justDate === getTomorrow();
|
|
5295
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
5296
|
-
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
5297
|
-
} else if (isLuxonDateTime(test)) {
|
|
5298
|
-
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
5299
|
-
}
|
|
5300
|
-
return false;
|
|
5301
|
-
}
|
|
5302
|
-
function isYesterday(test) {
|
|
5303
|
-
if (isString(test)) {
|
|
5304
|
-
const justDate = stripAfter(test, "T");
|
|
5305
|
-
return isIsoExplicitDate(justDate) && justDate === getYesterday();
|
|
5306
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
5307
|
-
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
5308
|
-
} else if (isLuxonDateTime(test)) {
|
|
5309
|
-
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
5310
|
-
}
|
|
5311
|
-
return false;
|
|
5312
|
-
}
|
|
5313
|
-
function isIso3166Alpha2(val) {
|
|
5314
|
-
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
5315
|
-
return isString(val) && codes.includes(val);
|
|
5316
|
-
}
|
|
5317
|
-
function isCountryCode2(val) {
|
|
5318
|
-
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
5319
|
-
return isString(val) && codes.includes(val);
|
|
5320
|
-
}
|
|
5321
|
-
function isIso3166Alpha3(val) {
|
|
5322
|
-
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
5323
|
-
return isString(val) && codes.includes(val);
|
|
5324
|
-
}
|
|
5325
|
-
function isCountryCode3(val) {
|
|
5326
|
-
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
5327
|
-
return isString(val) && codes.includes(val);
|
|
5328
|
-
}
|
|
5329
|
-
function isIso3166CountryCode(val) {
|
|
5330
|
-
const codes = ISO3166_12.map((i) => i.countryCode);
|
|
5331
|
-
return isString(val) && codes.includes(val);
|
|
5332
|
-
}
|
|
5333
|
-
function isCountryAbbrev(val) {
|
|
5334
|
-
return isCountryCode2(val) || isCountryCode3(val);
|
|
5335
|
-
}
|
|
5336
|
-
function isIso3166CountryName(val) {
|
|
5337
|
-
const codes = ISO3166_12.map((i) => i.name);
|
|
5338
|
-
return isString(val) && codes.includes(val);
|
|
5339
|
-
}
|
|
5340
|
-
function isCountryName(val) {
|
|
5341
|
-
const codes = ISO3166_12.map((i) => i.name);
|
|
5342
|
-
return isString(val) && codes.includes(val);
|
|
5343
|
-
}
|
|
5344
|
-
var ABBREV = US_STATE_LOOKUP2.map((i) => i.abbrev);
|
|
5345
|
-
var NAME = US_STATE_LOOKUP2.map((i) => i.name);
|
|
5346
|
-
function isUsStateAbbreviation(val) {
|
|
5347
|
-
return isString(val) && ABBREV.includes(val);
|
|
5228
|
+
function retainWhile(content, ...retain2) {
|
|
5229
|
+
const stopIdx = asChars(content).findIndex((c) => !retain2.includes(c));
|
|
5230
|
+
return content.slice(0, stopIdx);
|
|
5348
5231
|
}
|
|
5349
|
-
function
|
|
5350
|
-
|
|
5232
|
+
function rightWhitespace(content) {
|
|
5233
|
+
const trimmed = content.trimStart();
|
|
5234
|
+
return retainAfterInclusive(
|
|
5235
|
+
trimmed,
|
|
5236
|
+
...WHITESPACE_CHARS2
|
|
5237
|
+
);
|
|
5351
5238
|
}
|
|
5352
5239
|
function split(str, sep = "") {
|
|
5353
5240
|
return str.split(sep);
|
|
5354
5241
|
}
|
|
5355
|
-
function
|
|
5356
|
-
|
|
5357
|
-
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
5242
|
+
function stripAfter(content, find2) {
|
|
5243
|
+
return content.split(find2).shift();
|
|
5358
5244
|
}
|
|
5359
|
-
function
|
|
5360
|
-
|
|
5361
|
-
return typeof value === "string" && split(value).every((i) => numericChars.includes(i)) ? true : typeof value === "number";
|
|
5245
|
+
function stripBefore(content, find2) {
|
|
5246
|
+
return content.split(find2).slice(1).join(find2);
|
|
5362
5247
|
}
|
|
5363
|
-
function
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
}
|
|
5367
|
-
return isString(val) && val.trim().length === 5 && isNumberLike(val.trim());
|
|
5248
|
+
function stripChars(content, ...strip2) {
|
|
5249
|
+
const chars = asChars(content);
|
|
5250
|
+
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
5368
5251
|
}
|
|
5369
|
-
function
|
|
5370
|
-
if (
|
|
5371
|
-
|
|
5372
|
-
const next = stripChars(val.trim().replace(first, "").trim(), "-");
|
|
5373
|
-
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
5252
|
+
function stripLeading(content, ...strip2) {
|
|
5253
|
+
if (isUndefined(content)) {
|
|
5254
|
+
return void 0;
|
|
5374
5255
|
}
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
}
|
|
5380
|
-
|
|
5381
|
-
return (
|
|
5382
|
-
return !!(isConstant(value) && value.kind === kind);
|
|
5383
|
-
};
|
|
5384
|
-
}
|
|
5385
|
-
function hasDefaultValue(value) {
|
|
5386
|
-
const noDefault = isSpecificConstant("no-default-value");
|
|
5387
|
-
return !noDefault(value);
|
|
5388
|
-
}
|
|
5389
|
-
function hasIndexOf(value, idx) {
|
|
5390
|
-
const result2 = isObject(value) ? String(idx) in value : Array.isArray(value) ? Number(idx) in value : false;
|
|
5391
|
-
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
5256
|
+
let output = String(content);
|
|
5257
|
+
for (const s of strip2) {
|
|
5258
|
+
if (output.startsWith(String(s))) {
|
|
5259
|
+
output = output.slice(String(s).length);
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
return isNumber(content) ? Number(output) : output;
|
|
5392
5263
|
}
|
|
5393
|
-
function
|
|
5394
|
-
return (
|
|
5395
|
-
|
|
5396
|
-
|
|
5264
|
+
function stripSurround(...chars) {
|
|
5265
|
+
return (input) => {
|
|
5266
|
+
let output = String(input);
|
|
5267
|
+
for (const s of chars) {
|
|
5268
|
+
if (output.startsWith(String(s))) {
|
|
5269
|
+
output = output.slice(String(s).length);
|
|
5270
|
+
}
|
|
5271
|
+
if (output.endsWith(String(s))) {
|
|
5272
|
+
output = output.slice(0, -1 * String(s).length);
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
return isNumber(input) ? Number(output) : output;
|
|
5397
5276
|
};
|
|
5398
5277
|
}
|
|
5399
|
-
function asChars(str) {
|
|
5400
|
-
return str.split("");
|
|
5401
|
-
}
|
|
5402
|
-
function asRecord(obj) {
|
|
5403
|
-
return obj;
|
|
5404
|
-
}
|
|
5405
|
-
function asString(value) {
|
|
5406
|
-
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
5407
|
-
}
|
|
5408
|
-
function csv(csv2, format = `string-numeric-tuple`) {
|
|
5409
|
-
const tuple3 = [];
|
|
5410
|
-
csv2.split(/,\s?/).forEach((v) => {
|
|
5411
|
-
tuple3.push(
|
|
5412
|
-
format === "string-numeric-tuple" ? isNumberLike(v) ? Number(v) : v : format === "json-tuple" ? isNumberLike(v) ? Number(v) : v === "true" ? true : v === "false" ? false : `"${v}"` : format === "string-tuple" ? `${v}` : Never2
|
|
5413
|
-
);
|
|
5414
|
-
});
|
|
5415
|
-
return tuple3;
|
|
5416
|
-
}
|
|
5417
|
-
function intersect(value, _intersectedWith) {
|
|
5418
|
-
return value;
|
|
5419
|
-
}
|
|
5420
5278
|
function stripTrailing(content, ...strip2) {
|
|
5279
|
+
if (isUndefined(content)) {
|
|
5280
|
+
return void 0;
|
|
5281
|
+
}
|
|
5421
5282
|
let output = String(content);
|
|
5422
5283
|
for (const s of strip2) {
|
|
5423
5284
|
if (output.endsWith(String(s))) {
|
|
@@ -5426,1812 +5287,2000 @@ function stripTrailing(content, ...strip2) {
|
|
|
5426
5287
|
}
|
|
5427
5288
|
return isNumber(content) ? Number(output) : output;
|
|
5428
5289
|
}
|
|
5429
|
-
function
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
function jsonValue(val) {
|
|
5433
|
-
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
5290
|
+
function stripUntil(content, ...until) {
|
|
5291
|
+
const stopIdx = asChars(content).findIndex((c) => until.includes(c));
|
|
5292
|
+
return content.slice(stopIdx);
|
|
5434
5293
|
}
|
|
5435
|
-
function
|
|
5436
|
-
|
|
5294
|
+
function stripWhile(content, ...match) {
|
|
5295
|
+
const stopIdx = asChars(content).findIndex((c) => !match.includes(c));
|
|
5296
|
+
return content.slice(stopIdx);
|
|
5437
5297
|
}
|
|
5438
|
-
function
|
|
5439
|
-
|
|
5440
|
-
return found ? found[prop] : void 0;
|
|
5298
|
+
function surround(prefix, postfix) {
|
|
5299
|
+
return (input) => `${prefix}${input}${postfix}`;
|
|
5441
5300
|
}
|
|
5442
|
-
function
|
|
5443
|
-
const
|
|
5444
|
-
return
|
|
5301
|
+
function takeNumericCharacters(content) {
|
|
5302
|
+
const nonNumericIdx = asChars(content).findIndex((i) => !NUMERIC_CHAR2.includes(i));
|
|
5303
|
+
return content.slice(0, nonNumericIdx);
|
|
5445
5304
|
}
|
|
5446
|
-
function
|
|
5447
|
-
const
|
|
5448
|
-
|
|
5305
|
+
function toCamelCase(input, preserveWhitespace) {
|
|
5306
|
+
const pascal = preserveWhitespace ? toPascalCase(input, preserveWhitespace) : toPascalCase(input);
|
|
5307
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
5308
|
+
pascal
|
|
5309
|
+
);
|
|
5310
|
+
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
5311
|
+
return camel;
|
|
5449
5312
|
}
|
|
5450
|
-
function
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
const
|
|
5458
|
-
return
|
|
5313
|
+
function toKebabCase(input, _preserveWhitespace = false) {
|
|
5314
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
5315
|
+
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
5316
|
+
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
5317
|
+
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
5318
|
+
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
5319
|
+
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
5320
|
+
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
5321
|
+
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
5322
|
+
replaceTrailingDash(
|
|
5323
|
+
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
5324
|
+
)
|
|
5325
|
+
)}${postWhite}`);
|
|
5459
5326
|
}
|
|
5460
|
-
function
|
|
5461
|
-
|
|
5462
|
-
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
5327
|
+
function toNumericArray(arr) {
|
|
5328
|
+
return arr.map((i) => Number(i));
|
|
5463
5329
|
}
|
|
5464
|
-
function
|
|
5465
|
-
const
|
|
5466
|
-
|
|
5330
|
+
function toPascalCase(input, preserveWhitespace = void 0) {
|
|
5331
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
5332
|
+
input
|
|
5333
|
+
);
|
|
5334
|
+
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
5335
|
+
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
5336
|
+
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
5337
|
+
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
5338
|
+
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
5339
|
+
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
5340
|
+
)}${preserveWhitespace ? postWhite : ""}`;
|
|
5341
|
+
return pascal;
|
|
5467
5342
|
}
|
|
5468
|
-
function
|
|
5469
|
-
const
|
|
5470
|
-
|
|
5343
|
+
function toSnakeCase(input, preserveWhitespace = false) {
|
|
5344
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
5345
|
+
const convertInteriorSpace = (input2) => input2.replace(/\s+/g, "_");
|
|
5346
|
+
const convertDashes = (input2) => input2.replace(/-/g, "_");
|
|
5347
|
+
const injectUnderscoreBeforeCaps = (input2) => input2.replace(/([A-Z])/g, "_$1");
|
|
5348
|
+
const removeLeadingUnderscore = (input2) => input2.startsWith("_") ? input2.slice(1) : input2;
|
|
5349
|
+
return ((preserveWhitespace ? preWhite : "") + removeLeadingUnderscore(
|
|
5350
|
+
injectUnderscoreBeforeCaps(convertDashes(convertInteriorSpace(focus)))
|
|
5351
|
+
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
5471
5352
|
}
|
|
5472
|
-
function
|
|
5473
|
-
|
|
5474
|
-
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
5353
|
+
function toString(val) {
|
|
5354
|
+
return String(val);
|
|
5475
5355
|
}
|
|
5476
|
-
function
|
|
5477
|
-
|
|
5478
|
-
kind: "Mapper",
|
|
5479
|
-
map: (from) => {
|
|
5480
|
-
return from.map(fn2);
|
|
5481
|
-
}
|
|
5482
|
-
};
|
|
5483
|
-
return createFnWithPropsExplicit(fn2, props);
|
|
5356
|
+
function toUppercase(str) {
|
|
5357
|
+
return str.split("").map((i) => ifLowercaseChar(i, (v) => capitalize(v), (v) => v)).join("");
|
|
5484
5358
|
}
|
|
5485
|
-
function
|
|
5486
|
-
return (
|
|
5487
|
-
const fn2 = (input) => {
|
|
5488
|
-
return Object.keys(map2).reduce(
|
|
5489
|
-
(acc, key) => {
|
|
5490
|
-
const val = map2[key];
|
|
5491
|
-
return {
|
|
5492
|
-
...acc,
|
|
5493
|
-
[key]: isFunction(val) ? val(input) : val
|
|
5494
|
-
};
|
|
5495
|
-
},
|
|
5496
|
-
{}
|
|
5497
|
-
);
|
|
5498
|
-
};
|
|
5499
|
-
return fn2;
|
|
5500
|
-
};
|
|
5359
|
+
function trim(input) {
|
|
5360
|
+
return input.trim();
|
|
5501
5361
|
}
|
|
5502
|
-
function
|
|
5503
|
-
return (
|
|
5504
|
-
return asMapper(fn2);
|
|
5505
|
-
};
|
|
5362
|
+
function trimLeft(input) {
|
|
5363
|
+
return input.trimStart();
|
|
5506
5364
|
}
|
|
5507
|
-
function
|
|
5508
|
-
|
|
5509
|
-
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
5510
|
-
const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
5511
|
-
const merged = {
|
|
5512
|
-
...intersectingKeys.reduce(
|
|
5513
|
-
(acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
|
|
5514
|
-
{}
|
|
5515
|
-
),
|
|
5516
|
-
...defUnique,
|
|
5517
|
-
...overrideUnique
|
|
5518
|
-
};
|
|
5519
|
-
return merged;
|
|
5365
|
+
function trimStart(input) {
|
|
5366
|
+
return input.trimStart();
|
|
5520
5367
|
}
|
|
5521
|
-
function
|
|
5522
|
-
return
|
|
5368
|
+
function trimRight(input) {
|
|
5369
|
+
return input.trimEnd();
|
|
5523
5370
|
}
|
|
5524
|
-
function
|
|
5525
|
-
return
|
|
5371
|
+
function trimEnd(input) {
|
|
5372
|
+
return input.trimEnd();
|
|
5526
5373
|
}
|
|
5527
|
-
function
|
|
5528
|
-
|
|
5374
|
+
function truncate(content, maxLength, ellipsis = false) {
|
|
5375
|
+
const overLimit = content.length > maxLength;
|
|
5376
|
+
return overLimit ? ellipsis ? `${content.slice(0, maxLength)}${typeof ellipsis === "string" ? ellipsis : "..."}` : content.slice(0, maxLength) : content;
|
|
5529
5377
|
}
|
|
5530
|
-
function
|
|
5531
|
-
|
|
5378
|
+
function tuple(...values) {
|
|
5379
|
+
const arr = values.length === 1 ? values[0] : values;
|
|
5380
|
+
return asArray(arr);
|
|
5532
5381
|
}
|
|
5533
|
-
function
|
|
5534
|
-
return
|
|
5382
|
+
function uncapitalize(str) {
|
|
5383
|
+
return `${str?.slice(0, 1).toLowerCase()}${str?.slice(1)}`;
|
|
5535
5384
|
}
|
|
5536
|
-
|
|
5537
|
-
|
|
5385
|
+
var unset = "<<unset>>";
|
|
5386
|
+
function uppercase(str) {
|
|
5387
|
+
return str.toUpperCase();
|
|
5538
5388
|
}
|
|
5539
|
-
function
|
|
5389
|
+
function widen(value) {
|
|
5540
5390
|
return value;
|
|
5541
5391
|
}
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
}
|
|
5545
|
-
|
|
5546
|
-
switch (typeof val) {
|
|
5547
|
-
case "number":
|
|
5548
|
-
return val;
|
|
5549
|
-
case "string":
|
|
5550
|
-
return Number(val);
|
|
5551
|
-
case "boolean":
|
|
5552
|
-
return val ? 1 : 0;
|
|
5553
|
-
default:
|
|
5554
|
-
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
5555
|
-
}
|
|
5556
|
-
}
|
|
5557
|
-
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
5558
|
-
function toNumber(value) {
|
|
5559
|
-
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
5392
|
+
var PROTOCOLS = Object.values(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i !== "");
|
|
5393
|
+
function getUrlProtocol(url) {
|
|
5394
|
+
const proto = PROTOCOLS.find((p) => url.startsWith(`${p}://`));
|
|
5395
|
+
return proto;
|
|
5560
5396
|
}
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
5397
|
+
function removeUrlProtocol(url) {
|
|
5398
|
+
return stripBefore(url, "://");
|
|
5564
5399
|
}
|
|
5565
|
-
function
|
|
5566
|
-
|
|
5400
|
+
function ensurePath(val) {
|
|
5401
|
+
const val2 = ensureLeading(val, "/");
|
|
5402
|
+
return val === "" ? "" : stripTrailing(val2, "/");
|
|
5567
5403
|
}
|
|
5568
|
-
function
|
|
5569
|
-
return (
|
|
5404
|
+
function getUrlPath(url) {
|
|
5405
|
+
return isUrl(url) ? ensurePath(
|
|
5406
|
+
stripAfter(stripBefore(removeUrlProtocol(url), "/"), "?")
|
|
5407
|
+
) : Never2;
|
|
5570
5408
|
}
|
|
5571
|
-
function
|
|
5572
|
-
|
|
5409
|
+
function getUrlQueryParams(url, specific = void 0) {
|
|
5410
|
+
const qp = stripBefore(url, "?");
|
|
5411
|
+
if (specific) {
|
|
5412
|
+
return qp.includes(`${specific}=`) ? decodeURIComponent(
|
|
5413
|
+
stripAfter(
|
|
5414
|
+
stripBefore(qp, `${specific}=`),
|
|
5415
|
+
"&"
|
|
5416
|
+
).replace(/\+/g, "%20")
|
|
5417
|
+
) : void 0;
|
|
5418
|
+
}
|
|
5419
|
+
return qp === "" ? qp : `?${qp}`;
|
|
5573
5420
|
}
|
|
5574
|
-
function
|
|
5575
|
-
|
|
5421
|
+
function getUrlDefaultPort(url) {
|
|
5422
|
+
const proto = getUrlProtocol(url);
|
|
5423
|
+
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
5576
5424
|
}
|
|
5577
|
-
function
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5425
|
+
function getUrlPort(url, resolve = false) {
|
|
5426
|
+
const re = /.*:(\d{2,3})/;
|
|
5427
|
+
const match = url.match(re);
|
|
5428
|
+
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
5581
5429
|
}
|
|
5582
|
-
function
|
|
5583
|
-
|
|
5430
|
+
function getUrlSource(url) {
|
|
5431
|
+
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
5432
|
+
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
5584
5433
|
}
|
|
5585
|
-
function
|
|
5586
|
-
|
|
5434
|
+
function getUrlBase(url) {
|
|
5435
|
+
const path = getUrlPath(url);
|
|
5436
|
+
const remaining = stripAfter(url, path);
|
|
5437
|
+
return remaining;
|
|
5587
5438
|
}
|
|
5588
|
-
function
|
|
5589
|
-
|
|
5590
|
-
|
|
5439
|
+
function getUrlDynamics(url) {
|
|
5440
|
+
const path = getUrlPath(url);
|
|
5441
|
+
const qp = getUrlQueryParams(url);
|
|
5442
|
+
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
5443
|
+
const segmentTypes = [
|
|
5444
|
+
"string",
|
|
5445
|
+
"number",
|
|
5446
|
+
"boolean",
|
|
5447
|
+
"Opt<string>",
|
|
5448
|
+
"Opt<number>",
|
|
5449
|
+
"Opt<boolean>"
|
|
5450
|
+
];
|
|
5451
|
+
const pathVars = {};
|
|
5452
|
+
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
5453
|
+
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
5454
|
+
const findPathNamed = infer(`<{{infer name}}>`);
|
|
5455
|
+
for (const part of pathParts) {
|
|
5456
|
+
const union4 = findPathUnion(part);
|
|
5457
|
+
const typed = findPathTyped(part);
|
|
5458
|
+
const named = findPathNamed(part);
|
|
5459
|
+
if (union4) {
|
|
5460
|
+
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
5461
|
+
pathVars[union4.name] = `string(${union4.union})`;
|
|
5462
|
+
}
|
|
5463
|
+
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
5464
|
+
pathVars[typed.name] = typed.type;
|
|
5465
|
+
} else if (named && isVariable(named.name)) {
|
|
5466
|
+
pathVars[named.name] = "string";
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
const qpVars = {};
|
|
5470
|
+
const qpParts = stripLeading(qp, "?").split("&");
|
|
5471
|
+
for (const p of qpParts) {
|
|
5472
|
+
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
5473
|
+
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
5474
|
+
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
5475
|
+
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
5476
|
+
qpVars[union4.var] = `string(${union4.params})`;
|
|
5477
|
+
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
5478
|
+
qpVars[dynamic.var] = dynamic.val;
|
|
5479
|
+
} else if (fixed && isVariable(fixed.var)) {
|
|
5480
|
+
qpVars[fixed.var] = fixed.val;
|
|
5481
|
+
}
|
|
5482
|
+
}
|
|
5483
|
+
return {
|
|
5484
|
+
pathVars,
|
|
5485
|
+
qpVars,
|
|
5486
|
+
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
5487
|
+
...pathVars,
|
|
5488
|
+
...qpVars
|
|
5489
|
+
}
|
|
5591
5490
|
};
|
|
5592
5491
|
}
|
|
5593
|
-
function
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5492
|
+
function urlMeta(url) {
|
|
5493
|
+
return {
|
|
5494
|
+
url,
|
|
5495
|
+
isUrl: isUrl(url),
|
|
5496
|
+
protocol: getUrlProtocol(url),
|
|
5497
|
+
path: getUrlPath(url),
|
|
5498
|
+
queryParameters: getUrlQueryParams(url),
|
|
5499
|
+
params: getUrlDynamics,
|
|
5500
|
+
port: getUrlPort(url),
|
|
5501
|
+
source: getUrlSource(url),
|
|
5502
|
+
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
5503
|
+
isIp4Address: isIp4Address(getUrlSource(url)),
|
|
5504
|
+
isIp6Address: isIp6Address(getUrlSource(url))
|
|
5597
5505
|
};
|
|
5598
5506
|
}
|
|
5599
|
-
function
|
|
5600
|
-
return (
|
|
5601
|
-
return typeof value === type;
|
|
5602
|
-
};
|
|
5507
|
+
function getYouTubePageType(url) {
|
|
5508
|
+
return isYouTubeUrl(url) ? isYouTubeVideoUrl(url) && (hasUrlQueryParameter(url, "v") || isYouTubeShareUrl(url)) ? hasUrlQueryParameter(url, "list") ? isYouTubeShareUrl(url) ? hasUrlQueryParameter(url, "t") ? `play::video::in-list::share-link::with-timestamp` : `play::video::in-list::share-link` : `play::video::in-list` : isYouTubeShareUrl(url) ? hasUrlQueryParameter(url, "t") ? `play::video::solo::share-link::with-timestamp` : `play::video::solo::share-link` : `play::video::solo` : isYouTubeCreatorUrl(url) ? getUrlPath(url).includes("/videos") ? "creator::videos" : getUrlPath(url).includes("/playlists") ? "creator::playlists" : last(getUrlPath(url).split("/")).startsWith("@") || getUrlPath(url).includes("/featured") ? "creator::featured" : "creator::other" : isYouTubeFeedUrl(url) ? isYouTubeFeedUrl(url, "history") ? "feed::history" : isYouTubeFeedUrl(url, "playlists") ? "feed::playlists" : isYouTubeFeedUrl(url, "liked") ? "feed::liked" : isYouTubeFeedUrl(url, "subscriptions") ? "feed::subscriptions" : isYouTubeFeedUrl(url, "trending") ? "feed::trending" : "feed::other" : isYouTubeVideosInPlaylist(url) ? "playlist::show" : "other" : Never2;
|
|
5603
5509
|
}
|
|
5604
|
-
function
|
|
5605
|
-
|
|
5606
|
-
|
|
5510
|
+
function youtubeEmbed(url) {
|
|
5511
|
+
if (hasUrlQueryParameter(url, "v")) {
|
|
5512
|
+
const id = getUrlQueryParams(url, "v");
|
|
5513
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
5514
|
+
} else if (isYouTubeShareUrl(url)) {
|
|
5515
|
+
const id = url.split("/").pop();
|
|
5516
|
+
if (id) {
|
|
5517
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
5518
|
+
} else {
|
|
5519
|
+
throw new Error(`Unexpected problem parsing share URL -- "${url}" -- into a YouTube embed URL`);
|
|
5520
|
+
}
|
|
5521
|
+
} else {
|
|
5522
|
+
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
function youtubeMeta(url) {
|
|
5526
|
+
return isYouTubeUrl(url) ? {
|
|
5527
|
+
url,
|
|
5528
|
+
isYouTubeUrl: true,
|
|
5529
|
+
isShareUrl: isYouTubeShareUrl(url),
|
|
5530
|
+
pageType: getYouTubePageType(url)
|
|
5531
|
+
} : {
|
|
5532
|
+
url,
|
|
5533
|
+
isYouTubeUrl: false
|
|
5607
5534
|
};
|
|
5608
5535
|
}
|
|
5609
|
-
function
|
|
5610
|
-
return
|
|
5536
|
+
function queue(state) {
|
|
5537
|
+
return {
|
|
5538
|
+
queue: state,
|
|
5539
|
+
size: state.length,
|
|
5540
|
+
isEmpty() {
|
|
5541
|
+
return state.length === 0;
|
|
5542
|
+
},
|
|
5543
|
+
clear() {
|
|
5544
|
+
state.slice(0, 0);
|
|
5545
|
+
},
|
|
5546
|
+
drain() {
|
|
5547
|
+
const old_state = [...state];
|
|
5548
|
+
state.slice(0, 0);
|
|
5549
|
+
return old_state;
|
|
5550
|
+
},
|
|
5551
|
+
push(...add) {
|
|
5552
|
+
state.push(...add);
|
|
5553
|
+
},
|
|
5554
|
+
drop(quantity) {
|
|
5555
|
+
if (quantity && quantity > state.length) {
|
|
5556
|
+
throw new Error("Cannot drop more elements than present in the queue");
|
|
5557
|
+
}
|
|
5558
|
+
state.splice(0, quantity || 1);
|
|
5559
|
+
},
|
|
5560
|
+
take(quantity) {
|
|
5561
|
+
if (quantity && quantity > state.length) {
|
|
5562
|
+
throw new Error("Cannot take more elements than present in the queue");
|
|
5563
|
+
}
|
|
5564
|
+
const result2 = state.slice(0, quantity || 1);
|
|
5565
|
+
state.splice(0, quantity || 1);
|
|
5566
|
+
return result2;
|
|
5567
|
+
},
|
|
5568
|
+
*[Symbol.iterator]() {
|
|
5569
|
+
for (let i = 0; i < state.length; i++) {
|
|
5570
|
+
yield state[i];
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5573
|
+
};
|
|
5611
5574
|
}
|
|
5612
|
-
function
|
|
5613
|
-
return
|
|
5575
|
+
function createFifoQueue(...list2) {
|
|
5576
|
+
return queue([...list2]);
|
|
5614
5577
|
}
|
|
5615
|
-
function
|
|
5616
|
-
return
|
|
5578
|
+
function queue2(state) {
|
|
5579
|
+
return {
|
|
5580
|
+
queue: state,
|
|
5581
|
+
size: state.length,
|
|
5582
|
+
isEmpty() {
|
|
5583
|
+
return state.length === 0;
|
|
5584
|
+
},
|
|
5585
|
+
push(...add) {
|
|
5586
|
+
state.push(...add);
|
|
5587
|
+
},
|
|
5588
|
+
drop(quantity) {
|
|
5589
|
+
state.splice(-quantity);
|
|
5590
|
+
},
|
|
5591
|
+
clear() {
|
|
5592
|
+
state.slice(0, 0);
|
|
5593
|
+
},
|
|
5594
|
+
drain() {
|
|
5595
|
+
const old_state = [...state];
|
|
5596
|
+
state.slice(0, 0);
|
|
5597
|
+
return old_state;
|
|
5598
|
+
},
|
|
5599
|
+
take(quantity) {
|
|
5600
|
+
const result2 = state.slice(-quantity);
|
|
5601
|
+
state.splice(-quantity);
|
|
5602
|
+
return result2;
|
|
5603
|
+
},
|
|
5604
|
+
*[Symbol.iterator]() {
|
|
5605
|
+
for (let i = state.length - 1; i >= 0; i--) {
|
|
5606
|
+
yield state[i];
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5609
|
+
};
|
|
5617
5610
|
}
|
|
5618
|
-
function
|
|
5619
|
-
return
|
|
5611
|
+
function createLifoQueue(...list2) {
|
|
5612
|
+
return queue2([...list2]);
|
|
5620
5613
|
}
|
|
5621
|
-
|
|
5622
|
-
|
|
5614
|
+
var scalarToToken = identity({
|
|
5615
|
+
string: "<<string>>",
|
|
5616
|
+
number: "<<number>>",
|
|
5617
|
+
boolean: "<<boolean>>",
|
|
5618
|
+
true: "<<true>>",
|
|
5619
|
+
false: "<<false>>",
|
|
5620
|
+
null: "<<null>>",
|
|
5621
|
+
undefined: "<<undefined>>",
|
|
5622
|
+
unknown: "<<unknown>>",
|
|
5623
|
+
any: "<<any>>",
|
|
5624
|
+
never: "<<never>>"
|
|
5625
|
+
});
|
|
5626
|
+
function stringLiteral(str) {
|
|
5627
|
+
return stripAfter(stripBefore(str, "string("), ")");
|
|
5623
5628
|
}
|
|
5624
|
-
function
|
|
5625
|
-
return
|
|
5629
|
+
function numericLiteral(str) {
|
|
5630
|
+
return stripAfter(stripBefore(str, "number("), ")");
|
|
5626
5631
|
}
|
|
5627
|
-
function
|
|
5628
|
-
|
|
5632
|
+
function handleOptional(token) {
|
|
5633
|
+
const bare = stripTrailing(stripLeading(token, "Opt<"), ">");
|
|
5634
|
+
return bare.startsWith("string") ? `<<union::[ <<string>>, <<undefined>> ]>>` : bare.startsWith("number") ? `<<union::[ <<number>>, <<undefined>> ]>>` : bare.startsWith("boolean") ? `<<union::[ <<boolean>>, <<undefined>> ]>>` : bare.startsWith("unknown") ? `<<union::[ <<unknown>>, <<undefined>> ]>>` : `<<never>>`;
|
|
5629
5635
|
}
|
|
5630
|
-
|
|
5631
|
-
"
|
|
5632
|
-
"inherit",
|
|
5633
|
-
"initial",
|
|
5634
|
-
"revert",
|
|
5635
|
-
"revert-layer",
|
|
5636
|
-
"unset",
|
|
5637
|
-
"auto"
|
|
5638
|
-
];
|
|
5639
|
-
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
5640
|
-
function isCssAspectRatio(val) {
|
|
5641
|
-
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
5636
|
+
function simpleScalarTokenToTypeToken(val) {
|
|
5637
|
+
return val in scalarToToken ? scalarToToken[val] : val.startsWith("string(") ? stringLiteral(val).includes(",") ? `<<union::[ ${stringLiteral(val).split(/,\s?/).map((i) => `"${i}"`).join(", ")} ]>>` : `<<string::${stringLiteral(val)}>>` : val.startsWith("number(") ? numericLiteral(val).includes(",") ? `<<union::[ ${numericLiteral(val).split(/,\s?/).join(", ")} ]>>` : `<<number::${numericLiteral(val)}>>` : val.startsWith("Opt<") ? handleOptional(val) : `<<never>>`;
|
|
5642
5638
|
}
|
|
5643
|
-
function
|
|
5644
|
-
return
|
|
5639
|
+
function unionNode(node) {
|
|
5640
|
+
return isNumberLike(node) ? `<<number::${node}>>` : isBooleanLike(node) ? `<<${node}>>` : isSimpleContainerToken(node) ? simpleContainerTokenToTypeToken(node) : isSimpleScalarToken(node) ? simpleScalarToken(node) : `<<string::${node}>>`;
|
|
5645
5641
|
}
|
|
5646
|
-
function
|
|
5647
|
-
return
|
|
5642
|
+
function union(nodes) {
|
|
5643
|
+
return Array.isArray(nodes) ? nodes.map((n) => unionNode(n)) : nodes.includes(",") ? nodes.split(/,\s?/).map((n) => unionNode(n)).join(", ") : unionNode(nodes);
|
|
5648
5644
|
}
|
|
5649
|
-
|
|
5650
|
-
|
|
5645
|
+
var stripUnion = stripSurround("Union(", ")");
|
|
5646
|
+
function simpleUnionTokenToTypeToken(val) {
|
|
5647
|
+
return val.startsWith(`Union(`) && val.endsWith(`)`) ? `<<union::[ ${union(stripUnion(val))} ]>>` : Never2;
|
|
5651
5648
|
}
|
|
5652
|
-
function
|
|
5653
|
-
|
|
5654
|
-
|
|
5649
|
+
function simpleContainerTokenToTypeToken(_val) {
|
|
5650
|
+
}
|
|
5651
|
+
function asTypeToken(_val) {
|
|
5652
|
+
return "not ready";
|
|
5653
|
+
}
|
|
5654
|
+
function addToken(token, ...params) {
|
|
5655
|
+
return `<<${token}${params.length > 0 ? `::${params.join("::")}` : ""}>>`;
|
|
5656
|
+
}
|
|
5657
|
+
function boolean(literal2) {
|
|
5658
|
+
return isDefined(literal2) ? isTrue(literal2) ? addToken("true") : isFalse(literal2) ? addToken("false") : addToken("boolean") : addToken("boolean");
|
|
5659
|
+
}
|
|
5660
|
+
var unknown = () => "<<unknown>>";
|
|
5661
|
+
var undefinedType = () => "<<undefined>>";
|
|
5662
|
+
var nullType = () => "<<null>>";
|
|
5663
|
+
function fn(..._args) {
|
|
5664
|
+
return {
|
|
5665
|
+
returns: (_rtn) => ({
|
|
5666
|
+
addProperties: (_kv) => {
|
|
5667
|
+
return null;
|
|
5668
|
+
},
|
|
5669
|
+
done: () => {
|
|
5670
|
+
return null;
|
|
5671
|
+
}
|
|
5672
|
+
}),
|
|
5673
|
+
done: () => {
|
|
5674
|
+
const result2 = null;
|
|
5675
|
+
return result2;
|
|
5676
|
+
}
|
|
5677
|
+
};
|
|
5678
|
+
}
|
|
5679
|
+
function dictionary(_obj) {
|
|
5680
|
+
return null;
|
|
5681
|
+
}
|
|
5682
|
+
function tuple2(..._elements) {
|
|
5683
|
+
return null;
|
|
5684
|
+
}
|
|
5685
|
+
function regexToken(re, ...rep) {
|
|
5686
|
+
let exp = "";
|
|
5687
|
+
if (isString(re)) {
|
|
5688
|
+
try {
|
|
5689
|
+
const test = new RegExp(re);
|
|
5690
|
+
if (!isRegExp(test)) {
|
|
5691
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
5692
|
+
err.name = "InvalidRegEx";
|
|
5693
|
+
throw err;
|
|
5694
|
+
} else {
|
|
5695
|
+
exp = re;
|
|
5696
|
+
}
|
|
5697
|
+
} catch {
|
|
5698
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
5699
|
+
err.name = "InvalidRegEx";
|
|
5700
|
+
throw err;
|
|
5701
|
+
}
|
|
5702
|
+
} else if (isRegExp(re)) {
|
|
5703
|
+
exp = re.toString();
|
|
5655
5704
|
}
|
|
5656
|
-
const
|
|
5657
|
-
|
|
5658
|
-
const tld = domain ? domain.pop() : "";
|
|
5659
|
-
const firstChar = val[0].toLowerCase();
|
|
5660
|
-
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
5705
|
+
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
5706
|
+
return token;
|
|
5661
5707
|
}
|
|
5662
|
-
function
|
|
5663
|
-
return
|
|
5708
|
+
function addSingleton(token, api2) {
|
|
5709
|
+
return (...literals) => {
|
|
5710
|
+
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
5711
|
+
"union",
|
|
5712
|
+
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
5713
|
+
);
|
|
5714
|
+
};
|
|
5715
|
+
}
|
|
5716
|
+
var stringApi = {
|
|
5717
|
+
startsWith: (startsWith2) => addToken(`string-set`, `startsWith::${startsWith2}`),
|
|
5718
|
+
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
5719
|
+
zip: () => addToken("string-set", "Zip5"),
|
|
5720
|
+
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
5721
|
+
zipCode: () => addToken("string-set", "ZipCode"),
|
|
5722
|
+
militaryTime: (resolution) => {
|
|
5723
|
+
return addToken(
|
|
5724
|
+
"string-set",
|
|
5725
|
+
"militaryTime",
|
|
5726
|
+
resolution || "HH:MM"
|
|
5727
|
+
);
|
|
5728
|
+
},
|
|
5729
|
+
civilianTime: (resolution) => {
|
|
5730
|
+
return addToken(
|
|
5731
|
+
"string-set",
|
|
5732
|
+
"militaryTime",
|
|
5733
|
+
resolution || "HH:MM"
|
|
5734
|
+
);
|
|
5735
|
+
},
|
|
5736
|
+
numericString: () => addToken("string-set", "numeric"),
|
|
5737
|
+
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
5738
|
+
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
5739
|
+
regex: (exp, ...literalRepresentation) => {
|
|
5740
|
+
const token = regexToken(exp, ...literalRepresentation);
|
|
5741
|
+
return token;
|
|
5742
|
+
},
|
|
5743
|
+
done: () => addToken("string")
|
|
5744
|
+
};
|
|
5745
|
+
var string22 = addSingleton("string", stringApi);
|
|
5746
|
+
var number = addSingleton("number");
|
|
5747
|
+
function union2(...elements) {
|
|
5748
|
+
const result2 = elements.map((_el) => {
|
|
5749
|
+
});
|
|
5750
|
+
return result2;
|
|
5751
|
+
}
|
|
5752
|
+
function record(_key, _value) {
|
|
5753
|
+
return null;
|
|
5754
|
+
}
|
|
5755
|
+
function array(_type) {
|
|
5756
|
+
return null;
|
|
5757
|
+
}
|
|
5758
|
+
function set(_type) {
|
|
5759
|
+
return null;
|
|
5760
|
+
}
|
|
5761
|
+
function map(_key, _value) {
|
|
5762
|
+
return null;
|
|
5763
|
+
}
|
|
5764
|
+
function weakMap(_key, _value) {
|
|
5765
|
+
return null;
|
|
5766
|
+
}
|
|
5767
|
+
function isAddOrDone(val) {
|
|
5768
|
+
return isObject(val) && hasKeys("add", "done") && typeof val.done === "function" && typeof val.add === "function";
|
|
5769
|
+
}
|
|
5770
|
+
var ShapeApiImplementation = {
|
|
5771
|
+
string: string22,
|
|
5772
|
+
number,
|
|
5773
|
+
boolean,
|
|
5774
|
+
unknown,
|
|
5775
|
+
undefined: undefinedType,
|
|
5776
|
+
null: nullType,
|
|
5777
|
+
union: union2,
|
|
5778
|
+
fn,
|
|
5779
|
+
record,
|
|
5780
|
+
array,
|
|
5781
|
+
set,
|
|
5782
|
+
map,
|
|
5783
|
+
weakMap,
|
|
5784
|
+
dictionary,
|
|
5785
|
+
tuple: tuple2
|
|
5786
|
+
};
|
|
5787
|
+
function shape(cb) {
|
|
5788
|
+
const rtn = cb(ShapeApiImplementation);
|
|
5789
|
+
return handleDoneFn(
|
|
5790
|
+
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
5791
|
+
);
|
|
5792
|
+
}
|
|
5793
|
+
function isShape(v) {
|
|
5794
|
+
return !!(isString(v) && v.startsWith("<<") && v.endsWith(">>") && SHAPE_PREFIXES2.some((i) => v.startsWith(`<<${i}`)));
|
|
5795
|
+
}
|
|
5796
|
+
function asDefineObject(defn) {
|
|
5797
|
+
const result2 = Object.keys(defn).reduce(
|
|
5798
|
+
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
5799
|
+
...acc,
|
|
5800
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
5801
|
+
} : isFunction(defn[i]) ? {
|
|
5802
|
+
...acc,
|
|
5803
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
5804
|
+
} : Never2,
|
|
5805
|
+
{}
|
|
5806
|
+
);
|
|
5807
|
+
return result2;
|
|
5808
|
+
}
|
|
5809
|
+
function asType(...token) {
|
|
5810
|
+
return isFunction(token) ? token(ShapeApiImplementation) : token.length === 1 ? isFunction(token[0]) ? handleDoneFn(token[0](ShapeApiImplementation)) : isDefineObject(token[0]) ? asDefineObject(token[0]) : token[0] : token.map((i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i);
|
|
5811
|
+
}
|
|
5812
|
+
function asStringLiteral(...values) {
|
|
5813
|
+
return values.map((i) => i);
|
|
5814
|
+
}
|
|
5815
|
+
var choices = "NOT READY";
|
|
5816
|
+
function doesExtend(type) {
|
|
5817
|
+
return (val) => {
|
|
5818
|
+
let response = false;
|
|
5819
|
+
if (isString(val)) {
|
|
5820
|
+
if (type === "string") {
|
|
5821
|
+
response = true;
|
|
5822
|
+
}
|
|
5823
|
+
if (type.startsWith("string(")) {
|
|
5824
|
+
const literals = stripAfter(
|
|
5825
|
+
stripBefore(type, "string("),
|
|
5826
|
+
")"
|
|
5827
|
+
).split(/,\s*/);
|
|
5828
|
+
if (literals.includes(val)) {
|
|
5829
|
+
response = true;
|
|
5830
|
+
}
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
if (isNumber(val)) {
|
|
5834
|
+
if (type === "number") {
|
|
5835
|
+
response = true;
|
|
5836
|
+
}
|
|
5837
|
+
if (type.startsWith("number(")) {
|
|
5838
|
+
const literals = stripAfter(
|
|
5839
|
+
stripBefore(type, "number("),
|
|
5840
|
+
")"
|
|
5841
|
+
).split(/,\s*/).map(Number);
|
|
5842
|
+
if (literals.includes(val)) {
|
|
5843
|
+
response = true;
|
|
5844
|
+
}
|
|
5845
|
+
}
|
|
5846
|
+
}
|
|
5847
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
5848
|
+
response = true;
|
|
5849
|
+
}
|
|
5850
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
5851
|
+
response = true;
|
|
5852
|
+
}
|
|
5853
|
+
if (isBoolean(val)) {
|
|
5854
|
+
if (type === "boolean") {
|
|
5855
|
+
response = true;
|
|
5856
|
+
}
|
|
5857
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
5858
|
+
response = true;
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5861
|
+
if (isNarrowableObject(val)) {
|
|
5862
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
5863
|
+
response = true;
|
|
5864
|
+
}
|
|
5865
|
+
if (startsWith("Dict<")(type)) {
|
|
5866
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
5867
|
+
if (match) {
|
|
5868
|
+
const { value } = match;
|
|
5869
|
+
const isOpt = value.includes(`Opt<`);
|
|
5870
|
+
const values = objectValues(val);
|
|
5871
|
+
if (values.every((i) => isOpt ? isString(i) || isUndefined(i) : isString(i)) && type === "Dict<string, string>" || values.every((i) => isOpt ? isUndefined(i) || isNumber(i) : isNumber(i)) && type === "Dict<string, number>" || values.every((i) => isOpt ? isUndefined(i) || isBoolean(i) : isBoolean(i)) && type === "Dict<string, boolean>") {
|
|
5872
|
+
response = true;
|
|
5873
|
+
}
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
}
|
|
5877
|
+
if (isArray(val)) {
|
|
5878
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
5879
|
+
return true;
|
|
5880
|
+
}
|
|
5881
|
+
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
5882
|
+
response = true;
|
|
5883
|
+
}
|
|
5884
|
+
}
|
|
5885
|
+
if (isMap(val)) {
|
|
5886
|
+
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
5887
|
+
response = true;
|
|
5888
|
+
}
|
|
5889
|
+
}
|
|
5890
|
+
if (isSetContainer(val)) {
|
|
5891
|
+
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
5892
|
+
response = true;
|
|
5893
|
+
}
|
|
5894
|
+
}
|
|
5895
|
+
return response;
|
|
5896
|
+
};
|
|
5664
5897
|
}
|
|
5665
|
-
function
|
|
5666
|
-
|
|
5898
|
+
function ip6Prefix(...groups) {
|
|
5899
|
+
const empty = addToken("string");
|
|
5900
|
+
const count = 4 - groups.length;
|
|
5901
|
+
const fillIn = [];
|
|
5902
|
+
for (let index = 0; index < count; index++) {
|
|
5903
|
+
fillIn.push(empty);
|
|
5904
|
+
}
|
|
5905
|
+
return [
|
|
5906
|
+
"<<string::",
|
|
5907
|
+
[
|
|
5908
|
+
groups.join(":"),
|
|
5909
|
+
fillIn.join(":")
|
|
5910
|
+
].join(":"),
|
|
5911
|
+
">>"
|
|
5912
|
+
].join("");
|
|
5667
5913
|
}
|
|
5668
|
-
function
|
|
5669
|
-
|
|
5914
|
+
function createProxy(...initialize) {
|
|
5915
|
+
const state = initialize;
|
|
5916
|
+
state.id = null;
|
|
5917
|
+
const proxy = new Proxy(state, {});
|
|
5918
|
+
Object.defineProperty(proxy, "id", {
|
|
5919
|
+
enumerable: false
|
|
5920
|
+
});
|
|
5921
|
+
return proxy;
|
|
5670
5922
|
}
|
|
5671
|
-
function
|
|
5672
|
-
return
|
|
5923
|
+
function list(...init) {
|
|
5924
|
+
return init.length === 1 && isArray(init[0]) ? createProxy(...init[0]) : createProxy(...init);
|
|
5673
5925
|
}
|
|
5674
|
-
function
|
|
5675
|
-
return
|
|
5926
|
+
function singletonApi(kind) {
|
|
5927
|
+
return {
|
|
5928
|
+
wide: () => `<<${kind}>>`,
|
|
5929
|
+
literal: (val) => `<<${kind}::${val}>>`
|
|
5930
|
+
};
|
|
5676
5931
|
}
|
|
5677
|
-
function
|
|
5678
|
-
return
|
|
5932
|
+
function setApi(_variant) {
|
|
5933
|
+
return null;
|
|
5679
5934
|
}
|
|
5680
|
-
function
|
|
5681
|
-
return
|
|
5935
|
+
function fnReturnsApi(variant, _params, returns) {
|
|
5936
|
+
return isSet(returns) ? null : (_rtn) => {
|
|
5937
|
+
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
5938
|
+
};
|
|
5682
5939
|
}
|
|
5683
|
-
function
|
|
5684
|
-
return
|
|
5940
|
+
function fnParamsApi(variant, params, _returns) {
|
|
5941
|
+
return isSet(params) ? null : (params2) => {
|
|
5942
|
+
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
5943
|
+
};
|
|
5685
5944
|
}
|
|
5686
|
-
function
|
|
5687
|
-
return
|
|
5945
|
+
function fnDoneApi(variant, params, returns) {
|
|
5946
|
+
return isUnset(params) && isUnset(returns) ? `<<` : ``;
|
|
5688
5947
|
}
|
|
5689
|
-
function
|
|
5690
|
-
return
|
|
5948
|
+
function fnTokenClosure(kind, params, returns) {
|
|
5949
|
+
return {
|
|
5950
|
+
done: fnDoneApi(kind, params, returns),
|
|
5951
|
+
params: fnParamsApi(kind, params, returns),
|
|
5952
|
+
returns: fnReturnsApi(kind, params, returns)
|
|
5953
|
+
};
|
|
5691
5954
|
}
|
|
5692
|
-
function
|
|
5693
|
-
return
|
|
5955
|
+
function createTypeToken(kind) {
|
|
5956
|
+
return isAtomicKind(kind) ? `<<${kind}>>` : isSingletonKind(kind) ? singletonApi(kind) : isSetBasedKind(kind) ? setApi(kind) : isFnBasedKind(kind) ? handleDoneFn(fnTokenClosure(kind, unset, unset)) : "<<never>>";
|
|
5694
5957
|
}
|
|
5695
|
-
function
|
|
5696
|
-
return
|
|
5958
|
+
function fromDefineObject(defn) {
|
|
5959
|
+
return defn;
|
|
5697
5960
|
}
|
|
5698
|
-
function
|
|
5699
|
-
const
|
|
5700
|
-
const
|
|
5701
|
-
const
|
|
5702
|
-
|
|
5703
|
-
const nothing = stripChars(svelte, ...[
|
|
5704
|
-
...NUMERIC_CHAR2,
|
|
5705
|
-
...WHITESPACE_CHARS2,
|
|
5706
|
-
"(",
|
|
5707
|
-
")",
|
|
5708
|
-
"+",
|
|
5709
|
-
".",
|
|
5710
|
-
"-"
|
|
5711
|
-
]);
|
|
5712
|
-
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
5961
|
+
function getTokenKind(token) {
|
|
5962
|
+
const bare = stripSurround("<<", ">>")(token);
|
|
5963
|
+
const parts = bare.split("::");
|
|
5964
|
+
const kind = parts.pop();
|
|
5965
|
+
return kind;
|
|
5713
5966
|
}
|
|
5714
|
-
|
|
5715
|
-
|
|
5967
|
+
var simpleToken = (token) => token;
|
|
5968
|
+
var simpleScalarToken = (token) => token;
|
|
5969
|
+
var simpleContainerToken = (token) => token;
|
|
5970
|
+
function simpleScalarType(token) {
|
|
5971
|
+
const value = simpleScalarToken(token);
|
|
5972
|
+
return value;
|
|
5716
5973
|
}
|
|
5717
|
-
function
|
|
5718
|
-
|
|
5974
|
+
function simpleContainerType(token) {
|
|
5975
|
+
const value = simpleContainerToken(token);
|
|
5976
|
+
return value;
|
|
5719
5977
|
}
|
|
5720
|
-
function
|
|
5721
|
-
|
|
5978
|
+
function simpleType(token) {
|
|
5979
|
+
const value = isSimpleScalarToken(token) ? simpleScalarType(token) : isSimpleContainerToken(token) ? simpleContainerToken(token) : Never2;
|
|
5980
|
+
return value;
|
|
5722
5981
|
}
|
|
5723
|
-
function
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
if (isString(val)) {
|
|
5728
|
-
try {
|
|
5729
|
-
const _re = new RegExp(val);
|
|
5982
|
+
function hasOverlappingKeys(a, b) {
|
|
5983
|
+
const keys = Object.keys(a);
|
|
5984
|
+
for (const k of keys) {
|
|
5985
|
+
if (k in b) {
|
|
5730
5986
|
return true;
|
|
5731
|
-
} catch {
|
|
5732
|
-
return false;
|
|
5733
5987
|
}
|
|
5734
5988
|
}
|
|
5735
5989
|
return false;
|
|
5736
5990
|
}
|
|
5737
|
-
function
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
}
|
|
5755
|
-
function isTruthy(val) {
|
|
5756
|
-
return !FALSY_VALUES2.includes(val);
|
|
5757
|
-
}
|
|
5758
|
-
function isTypeSubtype(val) {
|
|
5759
|
-
return isString(val) && val.split("/").length === 2;
|
|
5760
|
-
}
|
|
5761
|
-
function isTypeTuple(value) {
|
|
5762
|
-
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
5763
|
-
}
|
|
5764
|
-
function isUnset(val) {
|
|
5765
|
-
return isObject(val) && val.kind === "Unset";
|
|
5766
|
-
}
|
|
5767
|
-
function isUri(val, ...protocols) {
|
|
5768
|
-
const p = protocols.length === 0 ? valuesOf(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i) : protocols;
|
|
5769
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
5991
|
+
function uniqueKeys(left, right) {
|
|
5992
|
+
const isNumeric = !!(isArray(left) && isArray(right));
|
|
5993
|
+
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
5994
|
+
throw new Error("uniqueKeys(l,r) given invalid comparison; both left and right values should be an object or an array but not one of each!");
|
|
5995
|
+
}
|
|
5996
|
+
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
5997
|
+
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
5998
|
+
if (isNumeric) {
|
|
5999
|
+
throw new Error("uniqueKeys does not yet work with tuples");
|
|
6000
|
+
}
|
|
6001
|
+
const leftKeys = l.filter((i) => !r.includes(i));
|
|
6002
|
+
const rightKeys = r.filter((i) => !l.includes(i));
|
|
6003
|
+
return [
|
|
6004
|
+
"LeftRight",
|
|
6005
|
+
leftKeys,
|
|
6006
|
+
rightKeys
|
|
6007
|
+
];
|
|
5770
6008
|
}
|
|
5771
|
-
function
|
|
5772
|
-
|
|
5773
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6009
|
+
function asChars(str) {
|
|
6010
|
+
return str.split("");
|
|
5774
6011
|
}
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
...NUMERIC_CHAR2,
|
|
5778
|
-
"_",
|
|
5779
|
-
"."
|
|
5780
|
-
];
|
|
5781
|
-
var alpha = null;
|
|
5782
|
-
function valid(chars) {
|
|
5783
|
-
return chars.every((i) => VALID.includes(i));
|
|
6012
|
+
function asRecord(obj) {
|
|
6013
|
+
return obj;
|
|
5784
6014
|
}
|
|
5785
|
-
function
|
|
5786
|
-
return isString(
|
|
6015
|
+
function asString(value) {
|
|
6016
|
+
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
5787
6017
|
}
|
|
5788
|
-
function
|
|
5789
|
-
return
|
|
6018
|
+
function isFunction(value) {
|
|
6019
|
+
return typeof value === "function";
|
|
5790
6020
|
}
|
|
5791
|
-
function
|
|
5792
|
-
return
|
|
6021
|
+
function isObject(value) {
|
|
6022
|
+
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
5793
6023
|
}
|
|
5794
|
-
function
|
|
5795
|
-
return
|
|
6024
|
+
function isNarrowableObject(value) {
|
|
6025
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
5796
6026
|
}
|
|
5797
|
-
function
|
|
5798
|
-
return
|
|
6027
|
+
function isEscapeFunction(val) {
|
|
6028
|
+
return isFunction(val) && "escape" in val && val.escape === true;
|
|
5799
6029
|
}
|
|
5800
|
-
function
|
|
5801
|
-
return
|
|
6030
|
+
function isOptionalParamFunction(val) {
|
|
6031
|
+
return isFunction(val) && "optionalParams" in val && val.optionalParams === true;
|
|
5802
6032
|
}
|
|
5803
|
-
function
|
|
5804
|
-
return
|
|
6033
|
+
function isApi(api2) {
|
|
6034
|
+
return isObject(api2) && "surface" in api2 && "_kind" in api2 && api2._kind === "api";
|
|
5805
6035
|
}
|
|
5806
|
-
function
|
|
5807
|
-
return
|
|
6036
|
+
function isApiSurface(val) {
|
|
6037
|
+
return isObject(val) && Object.keys(val).some((k) => isEscapeFunction(val[k]));
|
|
5808
6038
|
}
|
|
5809
|
-
function
|
|
5810
|
-
return
|
|
6039
|
+
function isDate(val) {
|
|
6040
|
+
return val instanceof Date;
|
|
5811
6041
|
}
|
|
5812
|
-
function
|
|
5813
|
-
|
|
6042
|
+
function isIsoDateTime(val) {
|
|
6043
|
+
if (!isString(val)) {
|
|
6044
|
+
return false;
|
|
6045
|
+
}
|
|
6046
|
+
const ISO_DATETIME_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
6047
|
+
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
6048
|
+
return false;
|
|
6049
|
+
}
|
|
6050
|
+
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
6051
|
+
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
6052
|
+
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
6053
|
+
return false;
|
|
6054
|
+
}
|
|
6055
|
+
if (month < 1 || month > 12) {
|
|
6056
|
+
return false;
|
|
6057
|
+
}
|
|
6058
|
+
;
|
|
6059
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
6060
|
+
if (day < 1 || day > daysInMonth) {
|
|
6061
|
+
return false;
|
|
6062
|
+
}
|
|
6063
|
+
;
|
|
6064
|
+
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
6065
|
+
if (tzMatch) {
|
|
6066
|
+
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
6067
|
+
const numHours = Number.parseInt(tzHours, 10);
|
|
6068
|
+
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
6069
|
+
if (numHours > 14 || numMinutes > 59) {
|
|
6070
|
+
return false;
|
|
6071
|
+
}
|
|
6072
|
+
if (numHours === 14 && numMinutes > 0) {
|
|
6073
|
+
return false;
|
|
6074
|
+
}
|
|
6075
|
+
}
|
|
6076
|
+
return true;
|
|
5814
6077
|
}
|
|
5815
|
-
function
|
|
5816
|
-
|
|
6078
|
+
function isIsoExplicitDate(val) {
|
|
6079
|
+
if (isString(val)) {
|
|
6080
|
+
const parts = val.split("-").map((i) => Number(i));
|
|
6081
|
+
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
6082
|
+
} else {
|
|
6083
|
+
return false;
|
|
6084
|
+
}
|
|
5817
6085
|
}
|
|
5818
|
-
function
|
|
5819
|
-
|
|
6086
|
+
function isIsoImplicitDate(val) {
|
|
6087
|
+
if (isString(val) && val.length === 8 && isNumberLike(val)) {
|
|
6088
|
+
const year = Number(val.slice(0, 4));
|
|
6089
|
+
const month = Number(val.slice(4, 6));
|
|
6090
|
+
const date = Number(val.slice(6, 8));
|
|
6091
|
+
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
6092
|
+
} else {
|
|
6093
|
+
return false;
|
|
6094
|
+
}
|
|
5820
6095
|
}
|
|
5821
|
-
function
|
|
5822
|
-
|
|
6096
|
+
function isIsoDate(val) {
|
|
6097
|
+
if (isString(val)) {
|
|
6098
|
+
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
6099
|
+
} else {
|
|
6100
|
+
return false;
|
|
6101
|
+
}
|
|
5823
6102
|
}
|
|
5824
|
-
function
|
|
5825
|
-
|
|
6103
|
+
function isIsoExplicitTime(val) {
|
|
6104
|
+
if (isString(val)) {
|
|
6105
|
+
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
6106
|
+
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
6107
|
+
} else {
|
|
6108
|
+
return false;
|
|
6109
|
+
}
|
|
5826
6110
|
}
|
|
5827
|
-
function
|
|
5828
|
-
|
|
6111
|
+
function isIsoImplicitTime(val) {
|
|
6112
|
+
if (isString(val)) {
|
|
6113
|
+
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
6114
|
+
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
6115
|
+
} else {
|
|
6116
|
+
return false;
|
|
6117
|
+
}
|
|
5829
6118
|
}
|
|
5830
|
-
function
|
|
5831
|
-
|
|
5832
|
-
return isString(val) && speed.includes(separate(val));
|
|
6119
|
+
function isIsoTime(val) {
|
|
6120
|
+
return isIsoExplicitTime(val) || isIsoImplicitTime(val);
|
|
5833
6121
|
}
|
|
5834
|
-
function
|
|
5835
|
-
return isString(val) &&
|
|
6122
|
+
function isIsoYear(val) {
|
|
6123
|
+
return !!(isString(val) && val.length === 4 && isNumber(Number(val)) && Number(val) >= 0 && Number(val) <= 9999);
|
|
5836
6124
|
}
|
|
5837
|
-
function
|
|
5838
|
-
return
|
|
6125
|
+
function isLuxonDateTime(val) {
|
|
6126
|
+
return isObject(val) && typeof val === "object" && val !== null && "isValid" in val && "invalidReason" in val && "invalidExplanation" in val && "toISO" in val && "toFormat" in val && "toMillis" in val && "year" in val && "month" in val && "day" in val && "hour" in val && "minute" in val && "second" in val && "millisecond" in val && typeof val.isValid === "boolean" && typeof val.toISO === "function";
|
|
5839
6127
|
}
|
|
5840
|
-
function
|
|
5841
|
-
|
|
6128
|
+
function isMoment(val) {
|
|
6129
|
+
if (val instanceof Date) {
|
|
6130
|
+
return false;
|
|
6131
|
+
}
|
|
6132
|
+
return isObject(val) && typeof val.format === "function" && typeof val.year === "function" && typeof val.month === "function" && typeof val.date === "function" && "_isAMomentObject" in val && "_isValid" in val && typeof val.add === "function" && typeof val.subtract === "function" && typeof val.toISOString === "function" && typeof val.isValid === "function";
|
|
5842
6133
|
}
|
|
5843
|
-
function
|
|
5844
|
-
|
|
6134
|
+
function isThisMonth(val) {
|
|
6135
|
+
const now = /* @__PURE__ */ new Date();
|
|
6136
|
+
const currentYear = now.getFullYear();
|
|
6137
|
+
const currentMonth = now.getMonth() + 1;
|
|
6138
|
+
if (val instanceof Date) {
|
|
6139
|
+
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
6140
|
+
}
|
|
6141
|
+
if (isMoment(val)) {
|
|
6142
|
+
const monthValue = val.month();
|
|
6143
|
+
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
6144
|
+
}
|
|
6145
|
+
if (isLuxonDateTime(val)) {
|
|
6146
|
+
return val.year === currentYear && val.month === currentMonth;
|
|
6147
|
+
}
|
|
6148
|
+
if (typeof val === "string") {
|
|
6149
|
+
const isoDateRegex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(?:T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[-+][01]\d:[0-5]\d))?$/;
|
|
6150
|
+
if (!isoDateRegex.test(val)) {
|
|
6151
|
+
return false;
|
|
6152
|
+
}
|
|
6153
|
+
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
6154
|
+
if (dateMatch) {
|
|
6155
|
+
const year = Number.parseInt(dateMatch[1], 10);
|
|
6156
|
+
const month = Number.parseInt(dateMatch[2], 10);
|
|
6157
|
+
return year === currentYear && month === currentMonth;
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
return false;
|
|
5845
6161
|
}
|
|
5846
|
-
function
|
|
5847
|
-
|
|
6162
|
+
function isThisWeek(date) {
|
|
6163
|
+
const targetDate = asDate(date);
|
|
6164
|
+
if (!targetDate) {
|
|
6165
|
+
return false;
|
|
6166
|
+
}
|
|
6167
|
+
const currentWeek = getWeekNumber();
|
|
6168
|
+
const targetWeek = getWeekNumber(targetDate);
|
|
6169
|
+
return currentWeek === targetWeek;
|
|
5848
6170
|
}
|
|
5849
|
-
function
|
|
5850
|
-
|
|
6171
|
+
function isThisYear(val) {
|
|
6172
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
6173
|
+
if (isObject(val) || isNumber(val) || isString(val)) {
|
|
6174
|
+
const date = asDate(val);
|
|
6175
|
+
if (date) {
|
|
6176
|
+
return date.getFullYear() === currentYear;
|
|
6177
|
+
} else {
|
|
6178
|
+
return false;
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
return false;
|
|
5851
6182
|
}
|
|
5852
|
-
function
|
|
5853
|
-
|
|
6183
|
+
function isToday(test) {
|
|
6184
|
+
if (isString(test)) {
|
|
6185
|
+
const justDate = stripAfter(test, "T");
|
|
6186
|
+
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
6187
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6188
|
+
return stripAfter(test.toISOString(), "T") === getToday();
|
|
6189
|
+
} else if (isLuxonDateTime(test)) {
|
|
6190
|
+
return stripAfter(test.toISO(), "T") === getToday();
|
|
6191
|
+
}
|
|
6192
|
+
return false;
|
|
5854
6193
|
}
|
|
5855
|
-
function
|
|
5856
|
-
|
|
6194
|
+
function isTomorrow(test) {
|
|
6195
|
+
if (isString(test)) {
|
|
6196
|
+
const justDate = stripAfter(test, "T");
|
|
6197
|
+
return isIsoExplicitDate(justDate) && justDate === getTomorrow();
|
|
6198
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6199
|
+
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
6200
|
+
} else if (isLuxonDateTime(test)) {
|
|
6201
|
+
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
6202
|
+
}
|
|
6203
|
+
return false;
|
|
5857
6204
|
}
|
|
5858
|
-
function
|
|
5859
|
-
|
|
6205
|
+
function isYesterday(test) {
|
|
6206
|
+
if (isString(test)) {
|
|
6207
|
+
const justDate = stripAfter(test, "T");
|
|
6208
|
+
return isIsoExplicitDate(justDate) && justDate === getYesterday();
|
|
6209
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6210
|
+
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
6211
|
+
} else if (isLuxonDateTime(test)) {
|
|
6212
|
+
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
6213
|
+
}
|
|
6214
|
+
return false;
|
|
5860
6215
|
}
|
|
5861
|
-
function
|
|
5862
|
-
return
|
|
6216
|
+
function isString(value) {
|
|
6217
|
+
return typeof value === "string";
|
|
5863
6218
|
}
|
|
5864
|
-
function
|
|
5865
|
-
|
|
6219
|
+
function isIso3166Alpha2(val) {
|
|
6220
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
6221
|
+
return isString(val) && codes.includes(val);
|
|
5866
6222
|
}
|
|
5867
|
-
function
|
|
5868
|
-
|
|
6223
|
+
function isCountryCode2(val) {
|
|
6224
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
6225
|
+
return isString(val) && codes.includes(val);
|
|
5869
6226
|
}
|
|
5870
|
-
function
|
|
5871
|
-
|
|
6227
|
+
function isIso3166Alpha3(val) {
|
|
6228
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
6229
|
+
return isString(val) && codes.includes(val);
|
|
5872
6230
|
}
|
|
5873
|
-
function
|
|
5874
|
-
|
|
6231
|
+
function isCountryCode3(val) {
|
|
6232
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
6233
|
+
return isString(val) && codes.includes(val);
|
|
5875
6234
|
}
|
|
5876
|
-
function
|
|
5877
|
-
|
|
6235
|
+
function isIso3166CountryCode(val) {
|
|
6236
|
+
const codes = ISO3166_12.map((i) => i.countryCode);
|
|
6237
|
+
return isString(val) && codes.includes(val);
|
|
5878
6238
|
}
|
|
5879
|
-
function
|
|
5880
|
-
return
|
|
6239
|
+
function isCountryAbbrev(val) {
|
|
6240
|
+
return isCountryCode2(val) || isCountryCode3(val);
|
|
5881
6241
|
}
|
|
5882
|
-
function
|
|
5883
|
-
|
|
6242
|
+
function isIso3166CountryName(val) {
|
|
6243
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
6244
|
+
return isString(val) && codes.includes(val);
|
|
5884
6245
|
}
|
|
5885
|
-
function
|
|
5886
|
-
|
|
6246
|
+
function isCountryName(val) {
|
|
6247
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
6248
|
+
return isString(val) && codes.includes(val);
|
|
5887
6249
|
}
|
|
5888
|
-
|
|
5889
|
-
|
|
6250
|
+
var ABBREV = US_STATE_LOOKUP2.map((i) => i.abbrev);
|
|
6251
|
+
var NAME = US_STATE_LOOKUP2.map((i) => i.name);
|
|
6252
|
+
function isUsStateAbbreviation(val) {
|
|
6253
|
+
return isString(val) && ABBREV.includes(val);
|
|
5890
6254
|
}
|
|
5891
|
-
function
|
|
5892
|
-
return
|
|
6255
|
+
function isUsStateName(val) {
|
|
6256
|
+
return isString(val) && NAME.includes(val);
|
|
5893
6257
|
}
|
|
5894
|
-
function
|
|
5895
|
-
|
|
6258
|
+
function isNumericString(value) {
|
|
6259
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
6260
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
5896
6261
|
}
|
|
5897
|
-
function
|
|
5898
|
-
const
|
|
5899
|
-
return
|
|
6262
|
+
function isNumberLike(value) {
|
|
6263
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
6264
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i)) ? true : typeof value === "number";
|
|
5900
6265
|
}
|
|
5901
|
-
function
|
|
5902
|
-
return
|
|
6266
|
+
function isNumber(value) {
|
|
6267
|
+
return typeof value === "number";
|
|
5903
6268
|
}
|
|
5904
|
-
function
|
|
5905
|
-
|
|
6269
|
+
function isZipCode5(val) {
|
|
6270
|
+
if (isNumber(val)) {
|
|
6271
|
+
return isZipCode5(`${val}`);
|
|
6272
|
+
}
|
|
6273
|
+
return isString(val) && val.trim().length === 5 && isNumberLike(val.trim());
|
|
5906
6274
|
}
|
|
5907
|
-
function
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
6275
|
+
function isZipPlus4(val) {
|
|
6276
|
+
if (isString(val)) {
|
|
6277
|
+
const first = retainWhile(val.trim(), ...NUMERIC_CHAR2);
|
|
6278
|
+
const next = stripChars(val.trim().replace(first, "").trim(), "-");
|
|
6279
|
+
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
6280
|
+
}
|
|
6281
|
+
return false;
|
|
5911
6282
|
}
|
|
5912
|
-
function
|
|
5913
|
-
return
|
|
5914
|
-
(i) => isAlpha(i) || isNumberLike(i) || i === "-" || i === "_"
|
|
5915
|
-
);
|
|
6283
|
+
function isZipCode(val) {
|
|
6284
|
+
return isZipCode5(val) || isZipPlus4(val);
|
|
5916
6285
|
}
|
|
5917
|
-
function
|
|
5918
|
-
return
|
|
6286
|
+
function isSpecificConstant(kind) {
|
|
6287
|
+
return (value) => {
|
|
6288
|
+
return !!(isConstant(value) && value.kind === kind);
|
|
6289
|
+
};
|
|
5919
6290
|
}
|
|
5920
|
-
function
|
|
5921
|
-
|
|
6291
|
+
function hasDefaultValue(value) {
|
|
6292
|
+
const noDefault = isSpecificConstant("no-default-value");
|
|
6293
|
+
return !noDefault(value);
|
|
5922
6294
|
}
|
|
5923
|
-
function
|
|
5924
|
-
|
|
6295
|
+
function hasIndexOf(value, idx) {
|
|
6296
|
+
const result2 = isObject(value) ? String(idx) in value : Array.isArray(value) ? Number(idx) in value : false;
|
|
6297
|
+
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
5925
6298
|
}
|
|
5926
|
-
function
|
|
5927
|
-
return
|
|
6299
|
+
function hasKeys(...props) {
|
|
6300
|
+
return (val) => {
|
|
6301
|
+
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
6302
|
+
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
6303
|
+
};
|
|
5928
6304
|
}
|
|
5929
|
-
function
|
|
5930
|
-
return isString(val) &&
|
|
6305
|
+
function hasWhiteSpace(val) {
|
|
6306
|
+
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS2.includes(c));
|
|
5931
6307
|
}
|
|
5932
|
-
function
|
|
5933
|
-
return
|
|
6308
|
+
function endsWith(endingIn2) {
|
|
6309
|
+
return (val) => {
|
|
6310
|
+
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
6311
|
+
};
|
|
5934
6312
|
}
|
|
5935
|
-
function
|
|
5936
|
-
return
|
|
6313
|
+
function isEqual(base) {
|
|
6314
|
+
return (value) => isSameTypeOf(base)(value) ? value === base : false;
|
|
5937
6315
|
}
|
|
5938
|
-
function
|
|
5939
|
-
|
|
5940
|
-
const stripped = stripSurround("<<", ">>")(val);
|
|
5941
|
-
if (TT_KIND_VARIANTS2.some((k) => stripped.startsWith(k))) {
|
|
5942
|
-
if (kind) {
|
|
5943
|
-
if (isAtomicKind(kind)) {
|
|
5944
|
-
return val === `<<${kind}>>`;
|
|
5945
|
-
} else if (isSetBasedKind(kind)) {
|
|
5946
|
-
return val.startsWith(`<<${kind}::`);
|
|
5947
|
-
} else {
|
|
5948
|
-
return val === `<<${kind}>>` || val.startsWith(`<<${kind}::`);
|
|
5949
|
-
}
|
|
5950
|
-
} else {
|
|
5951
|
-
return true;
|
|
5952
|
-
}
|
|
5953
|
-
}
|
|
5954
|
-
return false;
|
|
5955
|
-
}
|
|
5956
|
-
return false;
|
|
6316
|
+
function isLength(value, len) {
|
|
6317
|
+
return isArray(value) ? !!isEqual(value.length)(len) : isString(value) ? !!isEqual(value.length)(len) : isObject(value) ? !!isEqual(keysOf(value))(len) : false;
|
|
5957
6318
|
}
|
|
5958
|
-
function
|
|
5959
|
-
return
|
|
6319
|
+
function isSameTypeOf(base) {
|
|
6320
|
+
return (compare) => {
|
|
6321
|
+
return typeof base === typeof compare;
|
|
6322
|
+
};
|
|
5960
6323
|
}
|
|
5961
|
-
function
|
|
5962
|
-
|
|
6324
|
+
function isTuple(...tuple3) {
|
|
6325
|
+
const results = tuple3.map((i) => i(ShapeApiImplementation)).map((i) => isDoneFn(i) ? i.done() : i);
|
|
6326
|
+
return (v) => {
|
|
6327
|
+
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
6328
|
+
};
|
|
5963
6329
|
}
|
|
5964
|
-
function
|
|
5965
|
-
return
|
|
6330
|
+
function isTypeOf(type) {
|
|
6331
|
+
return (value) => {
|
|
6332
|
+
return typeof value === type;
|
|
6333
|
+
};
|
|
5966
6334
|
}
|
|
5967
|
-
function
|
|
5968
|
-
return
|
|
6335
|
+
function startsWith(startingWith) {
|
|
6336
|
+
return (val) => {
|
|
6337
|
+
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
6338
|
+
};
|
|
5969
6339
|
}
|
|
5970
|
-
function
|
|
5971
|
-
return
|
|
6340
|
+
function isHtmlElement(val) {
|
|
6341
|
+
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
5972
6342
|
}
|
|
5973
|
-
function
|
|
5974
|
-
return
|
|
6343
|
+
function isAlpha(value) {
|
|
6344
|
+
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
5975
6345
|
}
|
|
5976
|
-
function
|
|
5977
|
-
return
|
|
6346
|
+
function isArray(value) {
|
|
6347
|
+
return Array.isArray(value) === true;
|
|
5978
6348
|
}
|
|
5979
|
-
function
|
|
5980
|
-
return
|
|
6349
|
+
function isBoolean(value) {
|
|
6350
|
+
return typeof value === "boolean";
|
|
5981
6351
|
}
|
|
5982
|
-
function
|
|
5983
|
-
return
|
|
6352
|
+
function isBooleanLike(val) {
|
|
6353
|
+
return isBoolean(val) || isString(val) && ["true", "false", "boolean"].includes(val);
|
|
5984
6354
|
}
|
|
5985
|
-
function
|
|
5986
|
-
return
|
|
6355
|
+
function isConstant(value) {
|
|
6356
|
+
return !!(isObject(value) && "_type" in value && "kind" in value && value._type === "Constant");
|
|
5987
6357
|
}
|
|
5988
|
-
function
|
|
5989
|
-
return
|
|
6358
|
+
function isContainer(value) {
|
|
6359
|
+
return !!(Array.isArray(value) || isObject(value));
|
|
5990
6360
|
}
|
|
5991
|
-
var
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
6361
|
+
var tokens = [
|
|
6362
|
+
"1",
|
|
6363
|
+
"inherit",
|
|
6364
|
+
"initial",
|
|
6365
|
+
"revert",
|
|
6366
|
+
"revert-layer",
|
|
6367
|
+
"unset",
|
|
6368
|
+
"auto"
|
|
5997
6369
|
];
|
|
5998
|
-
|
|
5999
|
-
|
|
6370
|
+
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
6371
|
+
function isCssAspectRatio(val) {
|
|
6372
|
+
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6000
6373
|
}
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
function isSimpleToken(val) {
|
|
6004
|
-
return isString(val) && split_tokens.some(
|
|
6005
|
-
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6006
|
-
);
|
|
6374
|
+
function isCsv(val) {
|
|
6375
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
6007
6376
|
}
|
|
6008
|
-
function
|
|
6009
|
-
return
|
|
6010
|
-
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6011
|
-
);
|
|
6377
|
+
function isDefined(value) {
|
|
6378
|
+
return typeof value !== "undefined";
|
|
6012
6379
|
}
|
|
6013
|
-
function
|
|
6014
|
-
return
|
|
6015
|
-
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6016
|
-
);
|
|
6380
|
+
function isDoneFn(val) {
|
|
6381
|
+
return hasKeys("done")(val) && typeof val.done === "function";
|
|
6017
6382
|
}
|
|
6018
|
-
function
|
|
6019
|
-
|
|
6383
|
+
function isEmail(val) {
|
|
6384
|
+
if (!isString(val)) {
|
|
6385
|
+
return false;
|
|
6386
|
+
}
|
|
6387
|
+
const parts = val?.split("@");
|
|
6388
|
+
const domain = parts[1]?.split(".");
|
|
6389
|
+
const tld = domain ? domain.pop() : "";
|
|
6390
|
+
const firstChar = val[0].toLowerCase();
|
|
6391
|
+
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
6020
6392
|
}
|
|
6021
|
-
function
|
|
6022
|
-
return
|
|
6393
|
+
function isEmpty(val) {
|
|
6394
|
+
return isUndefined(val) || isNull(val) || isString(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isArray(val) && val.length === 0;
|
|
6023
6395
|
}
|
|
6024
|
-
function
|
|
6025
|
-
return
|
|
6396
|
+
function isErrorCondition(value, kind = null) {
|
|
6397
|
+
return isObject(value) && "__kind" in value && value.__kind === "ErrorCondition" && "kind" in value ? kind !== null ? value.kind === kind : true : false;
|
|
6026
6398
|
}
|
|
6027
|
-
function
|
|
6028
|
-
return
|
|
6029
|
-
(key) => isSimpleToken(val[key]) || isShapeToken(val) || isShapeCallback(val)
|
|
6030
|
-
);
|
|
6399
|
+
function isFalse(i) {
|
|
6400
|
+
return typeof i === "boolean" && !i;
|
|
6031
6401
|
}
|
|
6032
|
-
function
|
|
6033
|
-
|
|
6034
|
-
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6035
|
-
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6036
|
-
}
|
|
6402
|
+
function isFalsy(val) {
|
|
6403
|
+
return FALSY_VALUES2.includes(val);
|
|
6037
6404
|
}
|
|
6038
|
-
function
|
|
6039
|
-
|
|
6040
|
-
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6041
|
-
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6042
|
-
}
|
|
6043
|
-
return false;
|
|
6405
|
+
function isFnWithParams(input, ...params) {
|
|
6406
|
+
return params.length === 0 ? typeof input === "function" && input?.length > 0 : typeof input === "function" && input?.length === params.length;
|
|
6044
6407
|
}
|
|
6045
|
-
function
|
|
6046
|
-
|
|
6047
|
-
const kind = getTokenKind(val);
|
|
6048
|
-
return kind.endsWith(`-set`);
|
|
6049
|
-
}
|
|
6050
|
-
return false;
|
|
6408
|
+
function isHexadecimal(val) {
|
|
6409
|
+
return isString(val) && asChars(val).every((i) => isNumericString(i) || ["a", "b", "c", "d", "e", "f"].includes(i.toLowerCase()));
|
|
6051
6410
|
}
|
|
6052
|
-
function
|
|
6053
|
-
return
|
|
6411
|
+
function isIndexable(value) {
|
|
6412
|
+
return !!(Array.isArray(value) || typeof value === "object" && keysOf(value).length > 0);
|
|
6054
6413
|
}
|
|
6055
|
-
function
|
|
6056
|
-
return isString(
|
|
6414
|
+
function isInlineSvg(v) {
|
|
6415
|
+
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
6057
6416
|
}
|
|
6058
|
-
function
|
|
6059
|
-
return
|
|
6417
|
+
function isMap(val) {
|
|
6418
|
+
return val instanceof Map;
|
|
6060
6419
|
}
|
|
6061
|
-
function
|
|
6062
|
-
return
|
|
6420
|
+
function isNever(val) {
|
|
6421
|
+
return isConstant(val) && val.kind === "never";
|
|
6063
6422
|
}
|
|
6064
|
-
function
|
|
6065
|
-
return
|
|
6423
|
+
function isNothing(val) {
|
|
6424
|
+
return !!(val === null || val === void 0);
|
|
6066
6425
|
}
|
|
6067
|
-
function
|
|
6068
|
-
return
|
|
6426
|
+
function isNotNull(value) {
|
|
6427
|
+
return value === null;
|
|
6069
6428
|
}
|
|
6070
|
-
function
|
|
6071
|
-
return
|
|
6429
|
+
function isNull(value) {
|
|
6430
|
+
return value === null;
|
|
6072
6431
|
}
|
|
6073
|
-
function
|
|
6074
|
-
|
|
6432
|
+
function isPhoneNumber(val) {
|
|
6433
|
+
const svelte = String(val).trim();
|
|
6434
|
+
const chars = svelte.split("");
|
|
6435
|
+
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
6436
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
6437
|
+
const nothing = stripChars(svelte, ...[
|
|
6438
|
+
...NUMERIC_CHAR2,
|
|
6439
|
+
...WHITESPACE_CHARS2,
|
|
6440
|
+
"(",
|
|
6441
|
+
")",
|
|
6442
|
+
"+",
|
|
6443
|
+
".",
|
|
6444
|
+
"-"
|
|
6445
|
+
]);
|
|
6446
|
+
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
6075
6447
|
}
|
|
6076
|
-
function
|
|
6077
|
-
return
|
|
6448
|
+
function isReadonlyArray(value) {
|
|
6449
|
+
return Array.isArray(value) === true;
|
|
6078
6450
|
}
|
|
6079
|
-
function
|
|
6451
|
+
function isRef(value) {
|
|
6452
|
+
return isObject(value) && "value" in value && Array.from(Object.keys(value)).includes("_value");
|
|
6453
|
+
}
|
|
6454
|
+
function isRegExp(val) {
|
|
6455
|
+
return val instanceof RegExp;
|
|
6456
|
+
}
|
|
6457
|
+
function isLikeRegExp(val) {
|
|
6458
|
+
if (isRegExp(val)) {
|
|
6459
|
+
return true;
|
|
6460
|
+
}
|
|
6080
6461
|
if (isString(val)) {
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6462
|
+
try {
|
|
6463
|
+
const _re = new RegExp(val);
|
|
6464
|
+
return true;
|
|
6465
|
+
} catch {
|
|
6466
|
+
return false;
|
|
6467
|
+
}
|
|
6086
6468
|
}
|
|
6087
6469
|
return false;
|
|
6088
6470
|
}
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
6471
|
+
function isSymbol(value) {
|
|
6472
|
+
return typeof value === "symbol";
|
|
6092
6473
|
}
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
return isString(val) && val.startsWith("https://") && (URL2.includes(val) || URL2.some((i) => i.startsWith(`${i}/`)));
|
|
6474
|
+
function isScalar(value) {
|
|
6475
|
+
return isString(value) || isNumber(value) || isSymbol(value) || isNull(value);
|
|
6096
6476
|
}
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
return isString(val) && val.startsWith("https://") && (URL3.includes(val) || URL3.some((i) => i.startsWith(`${i}/`)));
|
|
6477
|
+
function isSet(val) {
|
|
6478
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
6100
6479
|
}
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
return isString(val) && val.startsWith("https://") && (URL4.includes(val) || URL4.some((i) => i.startsWith(`${i}/`)));
|
|
6480
|
+
function isSetContainer(val) {
|
|
6481
|
+
return val instanceof Set;
|
|
6104
6482
|
}
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
return isString(val) && val.startsWith("https://") && (URL5.includes(val) || URL5.some((i) => i.startsWith(`${i}/`)));
|
|
6483
|
+
function isStringArray(val) {
|
|
6484
|
+
return Array.isArray(val) && val.every((i) => isString(i));
|
|
6108
6485
|
}
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
return isString(val) && val.startsWith("https://") && (URL6.includes(val) || URL6.some((i) => i.startsWith(`${i}/`)));
|
|
6486
|
+
function isThenable(val) {
|
|
6487
|
+
return isObject(val) && "then" in val && "catch" in val && typeof val.then === "function";
|
|
6112
6488
|
}
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
return isString(val) && val.startsWith("https://") && (URL7.includes(val) || URL7.some((i) => i.startsWith(`${i}/`)));
|
|
6489
|
+
function isTrimable(val) {
|
|
6490
|
+
return isString(val) && val !== val.trim();
|
|
6116
6491
|
}
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
6492
|
+
function isTrue(value) {
|
|
6493
|
+
return value === true;
|
|
6120
6494
|
}
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
return isString(val) && val.startsWith("https://") && (URL9.includes(val) || URL9.some((i) => i.startsWith(`${i}/`)));
|
|
6495
|
+
function isTruthy(val) {
|
|
6496
|
+
return !FALSY_VALUES2.includes(val);
|
|
6124
6497
|
}
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
return isString(val) && val.startsWith("https://") && (URL10.includes(val) || URL10.some((i) => i.startsWith(`${i}/`)));
|
|
6498
|
+
function isTypeSubtype(val) {
|
|
6499
|
+
return isString(val) && val.split("/").length === 2;
|
|
6128
6500
|
}
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
return isString(val) && val.startsWith("https://") && (URL11.includes(val) || URL11.some((i) => i.startsWith(`${i}/`)));
|
|
6501
|
+
function isTypeTuple(value) {
|
|
6502
|
+
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
6132
6503
|
}
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
6504
|
+
function isUndefined(value) {
|
|
6505
|
+
return typeof value === "undefined";
|
|
6136
6506
|
}
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
return isString(val) && val.startsWith("https://") && (URL13.includes(val) || URL13.some((i) => i.startsWith(`${i}/`)));
|
|
6507
|
+
function isUnset(val) {
|
|
6508
|
+
return isObject(val) && val.kind === "Unset";
|
|
6140
6509
|
}
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
return isString(val) &&
|
|
6510
|
+
function isUri(val, ...protocols) {
|
|
6511
|
+
const p = protocols.length === 0 ? valuesOf(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i) : protocols;
|
|
6512
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6144
6513
|
}
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
return isString(val) &&
|
|
6514
|
+
function isUrl(val, ...protocols) {
|
|
6515
|
+
const p = protocols.length === 0 ? ["http", "https"] : protocols;
|
|
6516
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6148
6517
|
}
|
|
6149
|
-
var
|
|
6150
|
-
|
|
6151
|
-
|
|
6518
|
+
var VALID = [
|
|
6519
|
+
...ALPHA_CHARS2,
|
|
6520
|
+
...NUMERIC_CHAR2,
|
|
6521
|
+
"_",
|
|
6522
|
+
"."
|
|
6523
|
+
];
|
|
6524
|
+
var alpha = null;
|
|
6525
|
+
function valid(chars) {
|
|
6526
|
+
return chars.every((i) => VALID.includes(i));
|
|
6152
6527
|
}
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
6528
|
+
function isVariable(val) {
|
|
6529
|
+
return isString(val) && startsWith(alpha)(val) && valid(asChars(val));
|
|
6156
6530
|
}
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
6531
|
+
function separate(s) {
|
|
6532
|
+
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR2).trim();
|
|
6160
6533
|
}
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
6534
|
+
function isAreaMetric(val) {
|
|
6535
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6164
6536
|
}
|
|
6165
|
-
function
|
|
6166
|
-
return
|
|
6537
|
+
function isLuminosityMetric(val) {
|
|
6538
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6167
6539
|
}
|
|
6168
|
-
function
|
|
6169
|
-
|
|
6170
|
-
return isString(val) && valid2.some(
|
|
6171
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6172
|
-
);
|
|
6540
|
+
function isResistance(val) {
|
|
6541
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6173
6542
|
}
|
|
6174
|
-
function
|
|
6175
|
-
|
|
6176
|
-
return isString(val) && valid2.some(
|
|
6177
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6178
|
-
);
|
|
6543
|
+
function isCurrentMetric(val) {
|
|
6544
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6179
6545
|
}
|
|
6180
|
-
function
|
|
6181
|
-
|
|
6182
|
-
"https://github.com",
|
|
6183
|
-
"https://www.github.com",
|
|
6184
|
-
"https://github.io"
|
|
6185
|
-
];
|
|
6186
|
-
return isString(val) && valid2.some(
|
|
6187
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6188
|
-
);
|
|
6546
|
+
function isVoltageMetric(val) {
|
|
6547
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6189
6548
|
}
|
|
6190
|
-
function
|
|
6191
|
-
return isString(val) &&
|
|
6549
|
+
function isFrequencyMetric(val) {
|
|
6550
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6192
6551
|
}
|
|
6193
|
-
function
|
|
6194
|
-
return
|
|
6195
|
-
stripLeading(s, "https://github.com/"),
|
|
6196
|
-
"/"
|
|
6197
|
-
);
|
|
6552
|
+
function isPowerMetric(val) {
|
|
6553
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6198
6554
|
}
|
|
6199
|
-
function
|
|
6200
|
-
return
|
|
6555
|
+
function isTimeMetric(val) {
|
|
6556
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6201
6557
|
}
|
|
6202
|
-
function
|
|
6203
|
-
return isString(val) &&
|
|
6558
|
+
function isEnergyMetric(val) {
|
|
6559
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6204
6560
|
}
|
|
6205
|
-
function
|
|
6206
|
-
return isString(val) &&
|
|
6561
|
+
function isPressureMetric(val) {
|
|
6562
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6207
6563
|
}
|
|
6208
|
-
function
|
|
6209
|
-
return isString(val) &&
|
|
6564
|
+
function isTemperatureMetric(val) {
|
|
6565
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6210
6566
|
}
|
|
6211
|
-
function
|
|
6212
|
-
return isString(val) &&
|
|
6567
|
+
function isVolumeMetric(val) {
|
|
6568
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6213
6569
|
}
|
|
6214
|
-
function
|
|
6215
|
-
return isString(val) &&
|
|
6570
|
+
function isAccelerationMetric(val) {
|
|
6571
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6216
6572
|
}
|
|
6217
|
-
function
|
|
6218
|
-
|
|
6573
|
+
function isSpeedMetric(val) {
|
|
6574
|
+
const speed = SPEED_METRICS_LOOKUP2.map((i) => i.abbrev);
|
|
6575
|
+
return isString(val) && speed.includes(separate(val));
|
|
6219
6576
|
}
|
|
6220
|
-
function
|
|
6221
|
-
return isString(val) &&
|
|
6577
|
+
function isMassMetric(val) {
|
|
6578
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6222
6579
|
}
|
|
6223
|
-
function
|
|
6224
|
-
return isString(val) &&
|
|
6580
|
+
function isDistanceMetric(val) {
|
|
6581
|
+
return isString(val) && DISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6225
6582
|
}
|
|
6226
|
-
function
|
|
6227
|
-
return
|
|
6583
|
+
function isMetric(val) {
|
|
6584
|
+
return isDistanceMetric(val) || isMassMetric(val) || isSpeedMetric(val) || isAccelerationMetric(val) || isVoltageMetric(val) || isTemperatureMetric(val) || isPressureMetric(val) || isEnergyMetric(val) || isTimeMetric(val) || isPowerMetric(val) || isFrequencyMetric(val) || isVoltageMetric(val) || isCurrentMetric(val) || isLuminosityMetric(val) || isAreaMetric(val);
|
|
6228
6585
|
}
|
|
6229
|
-
function
|
|
6230
|
-
return isString(
|
|
6586
|
+
function isAreaUom(val) {
|
|
6587
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6231
6588
|
}
|
|
6232
|
-
function
|
|
6233
|
-
return
|
|
6589
|
+
function isLuminosityUom(val) {
|
|
6590
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6234
6591
|
}
|
|
6235
|
-
function
|
|
6236
|
-
return isString(val) &&
|
|
6592
|
+
function isResistanceUom(val) {
|
|
6593
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6237
6594
|
}
|
|
6238
|
-
function
|
|
6239
|
-
return isString(val) &&
|
|
6595
|
+
function isCurrentUom(val) {
|
|
6596
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6240
6597
|
}
|
|
6241
|
-
function
|
|
6242
|
-
return isString(val) &&
|
|
6598
|
+
function isVoltageUom(val) {
|
|
6599
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6243
6600
|
}
|
|
6244
|
-
function
|
|
6245
|
-
return isString(val) &&
|
|
6601
|
+
function isFrequencyUom(val) {
|
|
6602
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6246
6603
|
}
|
|
6247
|
-
function
|
|
6248
|
-
return isString(val) &&
|
|
6604
|
+
function isPowerUom(val) {
|
|
6605
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6249
6606
|
}
|
|
6250
|
-
function
|
|
6251
|
-
return isString(val) &&
|
|
6607
|
+
function isTimeUom(val) {
|
|
6608
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6252
6609
|
}
|
|
6253
|
-
function
|
|
6254
|
-
return isString(val) &&
|
|
6610
|
+
function isEnergyUom(val) {
|
|
6611
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6255
6612
|
}
|
|
6256
|
-
function
|
|
6257
|
-
return isString(val) &&
|
|
6613
|
+
function isPressureUom(val) {
|
|
6614
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6258
6615
|
}
|
|
6259
|
-
function
|
|
6260
|
-
return isString(val) &&
|
|
6616
|
+
function isTemperatureUom(val) {
|
|
6617
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6261
6618
|
}
|
|
6262
|
-
function
|
|
6263
|
-
return isString(val) &&
|
|
6619
|
+
function isVolumeUom(val) {
|
|
6620
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6621
|
+
}
|
|
6622
|
+
function isAccelerationUom(val) {
|
|
6623
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6624
|
+
}
|
|
6625
|
+
function isSpeedUom(val) {
|
|
6626
|
+
return isString(val) && SPEED_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6627
|
+
}
|
|
6628
|
+
function isMassUom(val) {
|
|
6629
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6264
6630
|
}
|
|
6265
|
-
function
|
|
6266
|
-
return isString(val) &&
|
|
6631
|
+
function isDistanceUom(val) {
|
|
6632
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6267
6633
|
}
|
|
6268
|
-
function
|
|
6269
|
-
return
|
|
6634
|
+
function isUom(val) {
|
|
6635
|
+
return isDistanceUom(val) || isMassUom(val) || isSpeedUom(val) || isAccelerationUom(val) || isVoltageUom(val) || isTemperatureUom(val) || isPressureUom(val) || isEnergyUom(val) || isTimeUom(val) || isPowerUom(val) || isFrequencyUom(val) || isVoltageUom(val) || isCurrentUom(val) || isLuminosityUom(val) || isAreaUom(val);
|
|
6270
6636
|
}
|
|
6271
|
-
function
|
|
6272
|
-
return isString(val) &&
|
|
6637
|
+
function isIp4Address(val) {
|
|
6638
|
+
return isString(val) && val.split(".").length === 4 && val.split(".").every((i) => isNumberLike(i)) && val.split(".").every((i) => Number(i) >= 0 && Number(i) <= 255);
|
|
6273
6639
|
}
|
|
6274
|
-
function
|
|
6275
|
-
|
|
6640
|
+
function isIp6Address(val) {
|
|
6641
|
+
const expanded = isString(val) ? ip6GroupExpansion(val) : "";
|
|
6642
|
+
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
6276
6643
|
}
|
|
6277
|
-
function
|
|
6278
|
-
return
|
|
6644
|
+
function isIpAddress(val) {
|
|
6645
|
+
return isIp4Address(val) || isIp6Address(val);
|
|
6279
6646
|
}
|
|
6280
|
-
function
|
|
6281
|
-
return isString(val) &&
|
|
6647
|
+
function hasUrlPort(val) {
|
|
6648
|
+
return isString(val) && asChars(removeUrlProtocol(val)).includes(":");
|
|
6282
6649
|
}
|
|
6283
|
-
function
|
|
6284
|
-
return isString(val) &&
|
|
6650
|
+
function isUrlPath(val) {
|
|
6651
|
+
return isString(val) && (val === "" || val.startsWith("/")) && asChars(val).every(
|
|
6652
|
+
(c) => isAlpha(c) || isNumberLike(c) || c === "_" || c === "@" || c === "." || c === "-"
|
|
6653
|
+
);
|
|
6285
6654
|
}
|
|
6286
|
-
function
|
|
6287
|
-
return isString(val) &&
|
|
6655
|
+
function isDomainName(val) {
|
|
6656
|
+
return isString(val) && val.split(".").filter((i) => i).length > 1 && isString(val.split(".").filter((i) => i).pop()) && asChars(val.split(".").filter((i) => i).pop()).length > 1 && val.split(".").filter((i) => i).every(
|
|
6657
|
+
(i) => isAlpha(i) || isNumberLike(i) || i === "-" || i === "_"
|
|
6658
|
+
);
|
|
6288
6659
|
}
|
|
6289
|
-
function
|
|
6290
|
-
return
|
|
6660
|
+
function isUrlSource(val) {
|
|
6661
|
+
return isDomainName(val) || isIpAddress(val);
|
|
6291
6662
|
}
|
|
6292
|
-
function
|
|
6293
|
-
return isString(val
|
|
6663
|
+
function hasUrlQueryParameter(val, prop) {
|
|
6664
|
+
return isString(getUrlQueryParams(val, prop));
|
|
6294
6665
|
}
|
|
6295
|
-
function
|
|
6296
|
-
return
|
|
6666
|
+
function isNumericArray(val) {
|
|
6667
|
+
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
6297
6668
|
}
|
|
6298
|
-
function
|
|
6299
|
-
return
|
|
6669
|
+
function hasProtocol(val, ...protocols) {
|
|
6670
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.some((i) => val.startsWith(i)) : protocols.some((i) => val.startsWith(i));
|
|
6300
6671
|
}
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
function isSocialMediaUrl(val) {
|
|
6304
|
-
return isString(val) && URL20.some((i) => val.startsWith(i));
|
|
6672
|
+
function isProtocol(val, ...protocols) {
|
|
6673
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.includes(val) : protocols.includes(val);
|
|
6305
6674
|
}
|
|
6306
|
-
function
|
|
6307
|
-
return isString(val) &&
|
|
6675
|
+
function hasProtocolPrefix(val, ...protocols) {
|
|
6676
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).some((i) => val.startsWith(i)) : protocols.map((i) => `${i}://`).some((i) => val.startsWith(i));
|
|
6308
6677
|
}
|
|
6309
|
-
function
|
|
6310
|
-
return isString(val) && (
|
|
6678
|
+
function isProtocolPrefix(val, ...protocols) {
|
|
6679
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).includes(val) : protocols.map((i) => `${i}://`).includes(val);
|
|
6311
6680
|
}
|
|
6312
|
-
function
|
|
6313
|
-
|
|
6681
|
+
function isTypeToken(val, kind) {
|
|
6682
|
+
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
6683
|
+
const stripped = stripSurround("<<", ">>")(val);
|
|
6684
|
+
if (TT_KIND_VARIANTS2.some((k) => stripped.startsWith(k))) {
|
|
6685
|
+
if (kind) {
|
|
6686
|
+
if (isAtomicKind(kind)) {
|
|
6687
|
+
return val === `<<${kind}>>`;
|
|
6688
|
+
} else if (isSetBasedKind(kind)) {
|
|
6689
|
+
return val.startsWith(`<<${kind}::`);
|
|
6690
|
+
} else {
|
|
6691
|
+
return val === `<<${kind}>>` || val.startsWith(`<<${kind}::`);
|
|
6692
|
+
}
|
|
6693
|
+
} else {
|
|
6694
|
+
return true;
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
return false;
|
|
6698
|
+
}
|
|
6699
|
+
return false;
|
|
6314
6700
|
}
|
|
6315
|
-
function
|
|
6316
|
-
return isString(val) &&
|
|
6701
|
+
function isTypeTokenKind(val) {
|
|
6702
|
+
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
6317
6703
|
}
|
|
6318
|
-
function
|
|
6319
|
-
return isString(val) &&
|
|
6704
|
+
function isAtomicToken(val) {
|
|
6705
|
+
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
6320
6706
|
}
|
|
6321
|
-
function
|
|
6322
|
-
return
|
|
6707
|
+
function isAtomicKind(val) {
|
|
6708
|
+
return isString(val) && TT_ATOMICS2.includes(val);
|
|
6323
6709
|
}
|
|
6324
|
-
function
|
|
6325
|
-
return
|
|
6710
|
+
function isObjectToken(val) {
|
|
6711
|
+
return isTypeToken(val, "obj");
|
|
6326
6712
|
}
|
|
6327
|
-
function
|
|
6328
|
-
return
|
|
6713
|
+
function isRecordToken(val) {
|
|
6714
|
+
return isTypeToken(val, "rec");
|
|
6329
6715
|
}
|
|
6330
|
-
function
|
|
6331
|
-
return
|
|
6716
|
+
function isTupleToken(val) {
|
|
6717
|
+
return isTypeToken(val, "tuple");
|
|
6332
6718
|
}
|
|
6333
|
-
function
|
|
6334
|
-
return
|
|
6719
|
+
function isArrayToken(val) {
|
|
6720
|
+
return isTypeToken(val, "arr");
|
|
6335
6721
|
}
|
|
6336
|
-
function
|
|
6337
|
-
return
|
|
6722
|
+
function isMapToken(val) {
|
|
6723
|
+
return isTypeToken(val, "map");
|
|
6338
6724
|
}
|
|
6339
|
-
function
|
|
6340
|
-
return
|
|
6725
|
+
function isSetToken(val) {
|
|
6726
|
+
return isTypeToken(val, "set");
|
|
6341
6727
|
}
|
|
6342
|
-
function
|
|
6343
|
-
return
|
|
6728
|
+
function isContainerToken(val) {
|
|
6729
|
+
return isObjectToken(val) || isRecordToken(val) || isTupleToken(val) || isArrayToken(val) || isMapToken(val) || isSetToken(val);
|
|
6344
6730
|
}
|
|
6345
|
-
function
|
|
6346
|
-
|
|
6347
|
-
const [t, st] = str.split("/");
|
|
6348
|
-
return [t, st];
|
|
6349
|
-
} else {
|
|
6350
|
-
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
6351
|
-
err.name = "InvalidTypeSubtype";
|
|
6352
|
-
throw err;
|
|
6353
|
-
}
|
|
6731
|
+
function isShapeCallback(val) {
|
|
6732
|
+
return isFunction(val) && val.kind === "shape";
|
|
6354
6733
|
}
|
|
6355
|
-
|
|
6356
|
-
|
|
6734
|
+
var token_types = [
|
|
6735
|
+
...TT_ATOMICS2,
|
|
6736
|
+
...TT_CONTAINERS2,
|
|
6737
|
+
...TT_FUNCTIONS2,
|
|
6738
|
+
...TT_SETS2,
|
|
6739
|
+
...TT_SINGLETONS2
|
|
6740
|
+
];
|
|
6741
|
+
function isShapeToken(val) {
|
|
6742
|
+
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
6357
6743
|
}
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6744
|
+
var split_tokens = SIMPLE_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6745
|
+
var scalar_split_tokens = SIMPLE_SCALAR_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6746
|
+
function isSimpleToken(val) {
|
|
6747
|
+
return isString(val) && split_tokens.some(
|
|
6748
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6749
|
+
);
|
|
6363
6750
|
}
|
|
6364
|
-
function
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
6751
|
+
function isSimpleScalarToken(val) {
|
|
6752
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6753
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6754
|
+
);
|
|
6369
6755
|
}
|
|
6370
|
-
function
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
const segments = [];
|
|
6375
|
-
while (match = pattern.exec(template)) {
|
|
6376
|
-
const [fullMatch, varName, asType2] = match;
|
|
6377
|
-
const staticPart = template.slice(lastIndex, match.index);
|
|
6378
|
-
if (staticPart) {
|
|
6379
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
6380
|
-
}
|
|
6381
|
-
segments.push({
|
|
6382
|
-
dynamic: true,
|
|
6383
|
-
varName,
|
|
6384
|
-
type: asType2 ? asType2 : "string"
|
|
6385
|
-
});
|
|
6386
|
-
lastIndex = match.index + fullMatch.length;
|
|
6387
|
-
}
|
|
6388
|
-
const remainder = template.slice(lastIndex);
|
|
6389
|
-
if (remainder) {
|
|
6390
|
-
segments.push({ dynamic: false, text: remainder });
|
|
6391
|
-
}
|
|
6392
|
-
return segments;
|
|
6756
|
+
function isSimpleContainerToken(val) {
|
|
6757
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6758
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6759
|
+
);
|
|
6393
6760
|
}
|
|
6394
|
-
function
|
|
6395
|
-
return
|
|
6761
|
+
function isSimpleTokenTuple(val) {
|
|
6762
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleToken);
|
|
6396
6763
|
}
|
|
6397
|
-
function
|
|
6398
|
-
|
|
6399
|
-
for (const seg of segments) {
|
|
6400
|
-
if (!seg.dynamic) {
|
|
6401
|
-
regexStr += escapeRegex(seg.text);
|
|
6402
|
-
} else {
|
|
6403
|
-
switch (seg.type) {
|
|
6404
|
-
case "string":
|
|
6405
|
-
regexStr += "(.*?)";
|
|
6406
|
-
break;
|
|
6407
|
-
case "number":
|
|
6408
|
-
regexStr += "(\\d+)";
|
|
6409
|
-
break;
|
|
6410
|
-
case "boolean":
|
|
6411
|
-
regexStr += "(true|false)";
|
|
6412
|
-
break;
|
|
6413
|
-
}
|
|
6414
|
-
}
|
|
6415
|
-
}
|
|
6416
|
-
regexStr += "$";
|
|
6417
|
-
return new RegExp(regexStr);
|
|
6764
|
+
function isSimpleScalarTokenTuple(val) {
|
|
6765
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleScalarToken);
|
|
6418
6766
|
}
|
|
6419
|
-
function
|
|
6420
|
-
|
|
6421
|
-
case "string":
|
|
6422
|
-
return value;
|
|
6423
|
-
case "number":
|
|
6424
|
-
return Number(value);
|
|
6425
|
-
case "boolean":
|
|
6426
|
-
return value === "true";
|
|
6427
|
-
}
|
|
6767
|
+
function isSimpleContainerTokenTuple(val) {
|
|
6768
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleContainerToken);
|
|
6428
6769
|
}
|
|
6429
|
-
function
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
if (seg.dynamic) {
|
|
6439
|
-
const rawVal = match[captureIndex++];
|
|
6440
|
-
if (rawVal === void 0)
|
|
6441
|
-
return false;
|
|
6442
|
-
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
6443
|
-
}
|
|
6770
|
+
function isDefineObject(val) {
|
|
6771
|
+
return isObject(val) && Object.keys(val).some(
|
|
6772
|
+
(key) => isSimpleToken(val[key]) || isShapeToken(val) || isShapeCallback(val)
|
|
6773
|
+
);
|
|
6774
|
+
}
|
|
6775
|
+
function isFnBasedToken(val) {
|
|
6776
|
+
if (isString(val) && val.startsWith(TT_START2) && val.endsWith(TT_STOP2)) {
|
|
6777
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6778
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6444
6779
|
}
|
|
6445
|
-
return result2;
|
|
6446
6780
|
}
|
|
6447
|
-
function
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6781
|
+
function isFnBasedKind(val) {
|
|
6782
|
+
if (isString(val) && isTypeTokenKind(val)) {
|
|
6783
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6784
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6785
|
+
}
|
|
6786
|
+
return false;
|
|
6451
6787
|
}
|
|
6452
|
-
function
|
|
6453
|
-
|
|
6788
|
+
function isSetBasedToken(val) {
|
|
6789
|
+
if (isTypeToken(val)) {
|
|
6790
|
+
const kind = getTokenKind(val);
|
|
6791
|
+
return kind.endsWith(`-set`);
|
|
6792
|
+
}
|
|
6793
|
+
return false;
|
|
6454
6794
|
}
|
|
6455
|
-
function
|
|
6456
|
-
return
|
|
6795
|
+
function isSetBasedKind(val) {
|
|
6796
|
+
return isString(val) && val.endsWith(`-set`);
|
|
6457
6797
|
}
|
|
6458
|
-
function
|
|
6459
|
-
return
|
|
6798
|
+
function isSingletonKind(val) {
|
|
6799
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
6460
6800
|
}
|
|
6461
|
-
function
|
|
6462
|
-
return
|
|
6801
|
+
function isSingletonToken(val) {
|
|
6802
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
6463
6803
|
}
|
|
6464
|
-
function
|
|
6465
|
-
return
|
|
6804
|
+
function isTailwindColorName(val) {
|
|
6805
|
+
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
6466
6806
|
}
|
|
6467
|
-
function
|
|
6468
|
-
return
|
|
6807
|
+
function isTailwindColorWithLuminosity(val) {
|
|
6808
|
+
return isString(val) && isTailwindColorName(val.split("-")[0]) && (!["white", "black"].includes(val.split("-")[0]) || val.split("-").length === 1) && (!val.includes("-") || Object.keys(TW_LUMINOSITY2).includes(retainAfter(val, "-")));
|
|
6469
6809
|
}
|
|
6470
|
-
function
|
|
6471
|
-
return
|
|
6810
|
+
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
6811
|
+
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
6472
6812
|
}
|
|
6473
|
-
function
|
|
6474
|
-
|
|
6475
|
-
const original_path = segments.join("/");
|
|
6476
|
-
const pre = original_path.startsWith("/") ? "/" : "";
|
|
6477
|
-
const post = original_path.endsWith("/") ? "/" : "";
|
|
6478
|
-
return `${pre}${clean_path}${post}`;
|
|
6813
|
+
function isTailwindColor(val) {
|
|
6814
|
+
return isTailwindColorWithLuminosity(val) || isTailwindColorWithLuminosityAndOpacity(val);
|
|
6479
6815
|
}
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
6483
|
-
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
6484
|
-
...NUMERIC_CHAR2
|
|
6485
|
-
) : "";
|
|
6816
|
+
function isTailwindModifier(val) {
|
|
6817
|
+
return isString(val) && TW_MODIFIERS2.includes(val);
|
|
6486
6818
|
}
|
|
6487
|
-
function
|
|
6488
|
-
|
|
6489
|
-
return countryCode !== "" ? stripLeading(stripLeading(
|
|
6490
|
-
phone.trim(),
|
|
6491
|
-
"+",
|
|
6492
|
-
"00"
|
|
6493
|
-
), countryCode).trim() : phone.trim();
|
|
6819
|
+
function isTailwindColorTarget(val) {
|
|
6820
|
+
return isString(val) && TW_COLOR_TARGETS2.includes(val);
|
|
6494
6821
|
}
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
case "f":
|
|
6503
|
-
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
6504
|
-
case "y":
|
|
6505
|
-
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
6506
|
-
default:
|
|
6507
|
-
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
6822
|
+
function isTailwindColorClass(val, ...allowedModifiers) {
|
|
6823
|
+
if (isString(val)) {
|
|
6824
|
+
const mods = getTailwindModifiers(val);
|
|
6825
|
+
const targetted = removeTailwindModifiers(val);
|
|
6826
|
+
const target = targetted.split("-")[0];
|
|
6827
|
+
const color = targetted.split("-").slice(1).join("-");
|
|
6828
|
+
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
6508
6829
|
}
|
|
6830
|
+
return false;
|
|
6509
6831
|
}
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
6514
|
-
return `${result2}${right}`;
|
|
6832
|
+
var URL = AUSTRALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6833
|
+
function isAustralianNewsUrl(val) {
|
|
6834
|
+
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
6515
6835
|
}
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
);
|
|
6520
|
-
const min = Math.min(...find2.map((i) => i.length));
|
|
6521
|
-
let len = Math.max(...find2.map((i) => i.length));
|
|
6522
|
-
if (min !== len) {
|
|
6523
|
-
if (!find2.includes(content.slice(idx, len))) {
|
|
6524
|
-
len = min;
|
|
6525
|
-
}
|
|
6526
|
-
}
|
|
6527
|
-
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
6836
|
+
var URL2 = BELGIUM_NEWS2.flatMap((i) => i.baseUrls);
|
|
6837
|
+
function isBelgiumNewsUrl(val) {
|
|
6838
|
+
return isString(val) && val.startsWith("https://") && (URL2.includes(val) || URL2.some((i) => i.startsWith(`${i}/`)));
|
|
6528
6839
|
}
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
);
|
|
6533
|
-
return minFound > 0 ? content.slice(minFound) : "";
|
|
6840
|
+
var URL3 = CANADIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6841
|
+
function isCanadianNewsUrl(val) {
|
|
6842
|
+
return isString(val) && val.startsWith("https://") && (URL3.includes(val) || URL3.some((i) => i.startsWith(`${i}/`)));
|
|
6534
6843
|
}
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
return
|
|
6844
|
+
var URL4 = DANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6845
|
+
function isDanishNewsUrl(val) {
|
|
6846
|
+
return isString(val) && val.startsWith("https://") && (URL4.includes(val) || URL4.some((i) => i.startsWith(`${i}/`)));
|
|
6538
6847
|
}
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6543
|
-
idx = idx + 1;
|
|
6544
|
-
}
|
|
6545
|
-
return idx === 0 ? "" : content.slice(0, idx);
|
|
6848
|
+
var URL5 = DUTCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6849
|
+
function isDutchNewsUrl(val) {
|
|
6850
|
+
return isString(val) && val.startsWith("https://") && (URL5.includes(val) || URL5.some((i) => i.startsWith(`${i}/`)));
|
|
6546
6851
|
}
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6551
|
-
idx = idx + 1;
|
|
6552
|
-
}
|
|
6553
|
-
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
6852
|
+
var URL6 = FRENCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6853
|
+
function isFrenchNewsUrl(val) {
|
|
6854
|
+
return isString(val) && val.startsWith("https://") && (URL6.includes(val) || URL6.some((i) => i.startsWith(`${i}/`)));
|
|
6554
6855
|
}
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
return
|
|
6856
|
+
var URL7 = GERMAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6857
|
+
function isGermanNewsUrl(val) {
|
|
6858
|
+
return isString(val) && val.startsWith("https://") && (URL7.includes(val) || URL7.some((i) => i.startsWith(`${i}/`)));
|
|
6558
6859
|
}
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
return
|
|
6562
|
-
trimmed,
|
|
6563
|
-
...WHITESPACE_CHARS2
|
|
6564
|
-
);
|
|
6860
|
+
var URL8 = INDIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6861
|
+
function isIndianNewsUrl(val) {
|
|
6862
|
+
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
6565
6863
|
}
|
|
6566
|
-
|
|
6567
|
-
|
|
6864
|
+
var URL9 = ITALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6865
|
+
function isItalianNewsUrl(val) {
|
|
6866
|
+
return isString(val) && val.startsWith("https://") && (URL9.includes(val) || URL9.some((i) => i.startsWith(`${i}/`)));
|
|
6568
6867
|
}
|
|
6569
|
-
|
|
6570
|
-
|
|
6868
|
+
var URL10 = JAPANESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
6869
|
+
function isJapaneseNewsUrl(val) {
|
|
6870
|
+
return isString(val) && val.startsWith("https://") && (URL10.includes(val) || URL10.some((i) => i.startsWith(`${i}/`)));
|
|
6571
6871
|
}
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
return
|
|
6872
|
+
var URL11 = MEXICAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6873
|
+
function isMexicanNewsUrl(val) {
|
|
6874
|
+
return isString(val) && val.startsWith("https://") && (URL11.includes(val) || URL11.some((i) => i.startsWith(`${i}/`)));
|
|
6575
6875
|
}
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
if (output.startsWith(String(s))) {
|
|
6580
|
-
output = output.slice(String(s).length);
|
|
6581
|
-
}
|
|
6582
|
-
}
|
|
6583
|
-
return isNumber(content) ? Number(output) : output;
|
|
6876
|
+
var URL12 = NORWEGIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6877
|
+
function isNorwegianNewsUrl(val) {
|
|
6878
|
+
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
6584
6879
|
}
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
for (const s of chars) {
|
|
6589
|
-
if (output.startsWith(String(s))) {
|
|
6590
|
-
output = output.slice(String(s).length);
|
|
6591
|
-
}
|
|
6592
|
-
if (output.endsWith(String(s))) {
|
|
6593
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6594
|
-
}
|
|
6595
|
-
}
|
|
6596
|
-
return isNumber(input) ? Number(output) : output;
|
|
6597
|
-
};
|
|
6880
|
+
var URL13 = SOUTH_KOREAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6881
|
+
function isSouthKoreanNewsUrl(val) {
|
|
6882
|
+
return isString(val) && val.startsWith("https://") && (URL13.includes(val) || URL13.some((i) => i.startsWith(`${i}/`)));
|
|
6598
6883
|
}
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
return
|
|
6884
|
+
var URL14 = SPANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6885
|
+
function isSpanishNewsUrl(val) {
|
|
6886
|
+
return isString(val) && val.startsWith("https://") && (URL14.includes(val) || URL14.some((i) => i.startsWith(`${i}/`)));
|
|
6602
6887
|
}
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
return
|
|
6888
|
+
var URL15 = SWISS_NEWS2.flatMap((i) => i.baseUrls);
|
|
6889
|
+
function isSwissNewsUrl(val) {
|
|
6890
|
+
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
6606
6891
|
}
|
|
6607
|
-
|
|
6608
|
-
|
|
6892
|
+
var URL16 = TURKISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6893
|
+
function isTurkishNewsUrl(val) {
|
|
6894
|
+
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
6609
6895
|
}
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
return
|
|
6896
|
+
var URL17 = UK_NEWS2.flatMap((i) => i.baseUrls);
|
|
6897
|
+
function isUkNewsUrl(val) {
|
|
6898
|
+
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
6613
6899
|
}
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
pascal
|
|
6618
|
-
);
|
|
6619
|
-
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
6620
|
-
return camel;
|
|
6900
|
+
var URL18 = US_NEWS2.flatMap((i) => i.baseUrls);
|
|
6901
|
+
function isUsNewsUrl(val) {
|
|
6902
|
+
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
6621
6903
|
}
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
6626
|
-
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
6627
|
-
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
6628
|
-
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
6629
|
-
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
6630
|
-
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
6631
|
-
replaceTrailingDash(
|
|
6632
|
-
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
6633
|
-
)
|
|
6634
|
-
)}${postWhite}`);
|
|
6904
|
+
var URL19 = CHINESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
6905
|
+
function isChineseNewsUrl(val) {
|
|
6906
|
+
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
6635
6907
|
}
|
|
6636
|
-
function
|
|
6637
|
-
return
|
|
6908
|
+
function isNewsUrl(val) {
|
|
6909
|
+
return isAustralianNewsUrl(val) || isBelgiumNewsUrl(val) || isCanadianNewsUrl(val) || isDanishNewsUrl(val) || isDutchNewsUrl(val) || isFrenchNewsUrl(val) || isGermanNewsUrl(val) || isIndianNewsUrl(val) || isItalianNewsUrl(val) || isJapaneseNewsUrl(val) || isMexicanNewsUrl(val) || isNorwegianNewsUrl(val) || isSouthKoreanNewsUrl(val) || isSpanishNewsUrl(val) || isSwissNewsUrl(val) || isTurkishNewsUrl(val) || isUkNewsUrl(val) || isUsNewsUrl(val);
|
|
6638
6910
|
}
|
|
6639
|
-
function
|
|
6640
|
-
const
|
|
6641
|
-
|
|
6911
|
+
function isBitbucketUrl(val) {
|
|
6912
|
+
const valid2 = REPO_SOURCE_LOOKUP2.bitbucket;
|
|
6913
|
+
return isString(val) && valid2.some(
|
|
6914
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6642
6915
|
);
|
|
6643
|
-
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
6644
|
-
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
6645
|
-
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
6646
|
-
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
6647
|
-
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
6648
|
-
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
6649
|
-
)}${preserveWhitespace ? postWhite : ""}`;
|
|
6650
|
-
return pascal;
|
|
6651
6916
|
}
|
|
6652
|
-
function
|
|
6653
|
-
const
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
const removeLeadingUnderscore = (input2) => input2.startsWith("_") ? input2.slice(1) : input2;
|
|
6658
|
-
return ((preserveWhitespace ? preWhite : "") + removeLeadingUnderscore(
|
|
6659
|
-
injectUnderscoreBeforeCaps(convertDashes(convertInteriorSpace(focus)))
|
|
6660
|
-
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
6917
|
+
function isCodeCommitUrl(val) {
|
|
6918
|
+
const valid2 = REPO_SOURCE_LOOKUP2.codecommit;
|
|
6919
|
+
return isString(val) && valid2.some(
|
|
6920
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6921
|
+
);
|
|
6661
6922
|
}
|
|
6662
|
-
function
|
|
6663
|
-
|
|
6923
|
+
function isGithubUrl(val) {
|
|
6924
|
+
const valid2 = [
|
|
6925
|
+
"https://github.com",
|
|
6926
|
+
"https://www.github.com",
|
|
6927
|
+
"https://github.io"
|
|
6928
|
+
];
|
|
6929
|
+
return isString(val) && valid2.some(
|
|
6930
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6931
|
+
);
|
|
6664
6932
|
}
|
|
6665
|
-
function
|
|
6666
|
-
return
|
|
6933
|
+
function isGithubOrgUrl(val) {
|
|
6934
|
+
return isString(val) && (val.startsWith("https://github.com/") && stripper(val).length === 2);
|
|
6667
6935
|
}
|
|
6668
|
-
function
|
|
6669
|
-
return
|
|
6936
|
+
function stripper(s) {
|
|
6937
|
+
return stripTrailing(
|
|
6938
|
+
stripLeading(s, "https://github.com/"),
|
|
6939
|
+
"/"
|
|
6940
|
+
);
|
|
6670
6941
|
}
|
|
6671
|
-
function
|
|
6672
|
-
return
|
|
6942
|
+
function isGithubRepoUrl(val) {
|
|
6943
|
+
return !!(isString(val) && (val.startsWith("https://github.com/") && stripper(val).split("/").length === 2));
|
|
6673
6944
|
}
|
|
6674
|
-
function
|
|
6675
|
-
return
|
|
6945
|
+
function isGithubRepoReleasesUrl(val) {
|
|
6946
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases") && stripper(val).split("/").length === 3);
|
|
6676
6947
|
}
|
|
6677
|
-
function
|
|
6678
|
-
return
|
|
6948
|
+
function isGithubRepoReleaseTagUrl(val) {
|
|
6949
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).length === 4);
|
|
6679
6950
|
}
|
|
6680
|
-
function
|
|
6681
|
-
return
|
|
6951
|
+
function isGithubIssuesListUrl(val) {
|
|
6952
|
+
return isString(val) && val.startsWith("https://github.com/") && val.includes("/issues");
|
|
6682
6953
|
}
|
|
6683
|
-
function
|
|
6684
|
-
|
|
6685
|
-
return overLimit ? ellipsis ? `${content.slice(0, maxLength)}${typeof ellipsis === "string" ? ellipsis : "..."}` : content.slice(0, maxLength) : content;
|
|
6954
|
+
function isGithubIssueUrl(val) {
|
|
6955
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/issues/"));
|
|
6686
6956
|
}
|
|
6687
|
-
function
|
|
6688
|
-
|
|
6689
|
-
return asArray(arr);
|
|
6957
|
+
function isGithubProjectsListUrl(val) {
|
|
6958
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/projects?") || val.trim().endsWith("/projects")) && stripper(val).split("/").length === 3);
|
|
6690
6959
|
}
|
|
6691
|
-
function
|
|
6692
|
-
return
|
|
6960
|
+
function isGithubProjectUrl(val) {
|
|
6961
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/projects/") && stripper(val).split("/").length === 4);
|
|
6693
6962
|
}
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
return str.toUpperCase();
|
|
6963
|
+
function isGithubReleasesListUrl(val) {
|
|
6964
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/releases?") || val.trim().endsWith("/releases")) && stripper(val).split("/").length === 3);
|
|
6697
6965
|
}
|
|
6698
|
-
function
|
|
6699
|
-
return
|
|
6966
|
+
function isGithubReleaseTagUrl(val) {
|
|
6967
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).split("/").length === 5);
|
|
6700
6968
|
}
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
const proto = PROTOCOLS.find((p) => url.startsWith(`${p}://`));
|
|
6704
|
-
return proto;
|
|
6969
|
+
function isRepoSource(v) {
|
|
6970
|
+
return isString(v) && REPO_SOURCES2.includes(v);
|
|
6705
6971
|
}
|
|
6706
|
-
function
|
|
6707
|
-
return
|
|
6972
|
+
function isSemanticVersion(v, allowPrefix = false) {
|
|
6973
|
+
return isString(v) && v.split(".").length === 3 && !Number.isNaN(Number(v.split(".")[1])) && !Number.isNaN(Number(v.split(".")[2])) && (!Number.isNaN(Number(v.split(".")[0])) || allowPrefix && !Number.isNaN(Number(stripLeading(v.split(".")[0], "v").trim())));
|
|
6708
6974
|
}
|
|
6709
|
-
function
|
|
6710
|
-
|
|
6711
|
-
return val === "" ? "" : stripTrailing(val2, "/");
|
|
6975
|
+
function isRepoUrl(val) {
|
|
6976
|
+
return isGithubUrl(val) || isBitbucketUrl(val) || isCodeCommitUrl(val);
|
|
6712
6977
|
}
|
|
6713
|
-
function
|
|
6714
|
-
return
|
|
6715
|
-
stripAfter(stripBefore(removeUrlProtocol(url), "/"), "?")
|
|
6716
|
-
) : Never2;
|
|
6978
|
+
function isWholeFoodsUrl(val) {
|
|
6979
|
+
return isString(val) && WHOLE_FOODS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6717
6980
|
}
|
|
6718
|
-
function
|
|
6719
|
-
|
|
6720
|
-
if (specific) {
|
|
6721
|
-
return qp.includes(`${specific}=`) ? decodeURIComponent(
|
|
6722
|
-
stripAfter(
|
|
6723
|
-
stripBefore(qp, `${specific}=`),
|
|
6724
|
-
"&"
|
|
6725
|
-
).replace(/\+/g, "%20")
|
|
6726
|
-
) : void 0;
|
|
6727
|
-
}
|
|
6728
|
-
return qp === "" ? qp : `?${qp}`;
|
|
6981
|
+
function isCvsUrl(val) {
|
|
6982
|
+
return isString(val) && CVS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6729
6983
|
}
|
|
6730
|
-
function
|
|
6731
|
-
|
|
6732
|
-
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
6984
|
+
function isWalgreensUrl(val) {
|
|
6985
|
+
return isString(val) && WALGREENS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6733
6986
|
}
|
|
6734
|
-
function
|
|
6735
|
-
|
|
6736
|
-
const match = url.match(re);
|
|
6737
|
-
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
6987
|
+
function isKrogersUrl(val) {
|
|
6988
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6738
6989
|
}
|
|
6739
|
-
function
|
|
6740
|
-
|
|
6741
|
-
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
6990
|
+
function isZaraUrl(val) {
|
|
6991
|
+
return isString(val) && ZARA_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6742
6992
|
}
|
|
6743
|
-
function
|
|
6744
|
-
|
|
6745
|
-
const remaining = stripAfter(url, path);
|
|
6746
|
-
return remaining;
|
|
6993
|
+
function isHmUrl(val) {
|
|
6994
|
+
return isString(val) && HM_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6747
6995
|
}
|
|
6748
|
-
function
|
|
6749
|
-
|
|
6750
|
-
const qp = getUrlQueryParams(url);
|
|
6751
|
-
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
6752
|
-
const segmentTypes = [
|
|
6753
|
-
"string",
|
|
6754
|
-
"number",
|
|
6755
|
-
"boolean",
|
|
6756
|
-
"Opt<string>",
|
|
6757
|
-
"Opt<number>",
|
|
6758
|
-
"Opt<boolean>"
|
|
6759
|
-
];
|
|
6760
|
-
const pathVars = {};
|
|
6761
|
-
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
6762
|
-
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
6763
|
-
const findPathNamed = infer(`<{{infer name}}>`);
|
|
6764
|
-
for (const part of pathParts) {
|
|
6765
|
-
const union4 = findPathUnion(part);
|
|
6766
|
-
const typed = findPathTyped(part);
|
|
6767
|
-
const named = findPathNamed(part);
|
|
6768
|
-
if (union4) {
|
|
6769
|
-
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
6770
|
-
pathVars[union4.name] = `string(${union4.union})`;
|
|
6771
|
-
}
|
|
6772
|
-
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
6773
|
-
pathVars[typed.name] = typed.type;
|
|
6774
|
-
} else if (named && isVariable(named.name)) {
|
|
6775
|
-
pathVars[named.name] = "string";
|
|
6776
|
-
}
|
|
6777
|
-
}
|
|
6778
|
-
const qpVars = {};
|
|
6779
|
-
const qpParts = stripLeading(qp, "?").split("&");
|
|
6780
|
-
for (const p of qpParts) {
|
|
6781
|
-
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
6782
|
-
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
6783
|
-
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
6784
|
-
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
6785
|
-
qpVars[union4.var] = `string(${union4.params})`;
|
|
6786
|
-
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
6787
|
-
qpVars[dynamic.var] = dynamic.val;
|
|
6788
|
-
} else if (fixed && isVariable(fixed.var)) {
|
|
6789
|
-
qpVars[fixed.var] = fixed.val;
|
|
6790
|
-
}
|
|
6791
|
-
}
|
|
6792
|
-
return {
|
|
6793
|
-
pathVars,
|
|
6794
|
-
qpVars,
|
|
6795
|
-
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
6796
|
-
...pathVars,
|
|
6797
|
-
...qpVars
|
|
6798
|
-
}
|
|
6799
|
-
};
|
|
6996
|
+
function isDellUrl(val) {
|
|
6997
|
+
return isString(val) && DELL_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6800
6998
|
}
|
|
6801
|
-
function
|
|
6802
|
-
return {
|
|
6803
|
-
url,
|
|
6804
|
-
isUrl: isUrl(url),
|
|
6805
|
-
protocol: getUrlProtocol(url),
|
|
6806
|
-
path: getUrlPath(url),
|
|
6807
|
-
queryParameters: getUrlQueryParams(url),
|
|
6808
|
-
params: getUrlDynamics,
|
|
6809
|
-
port: getUrlPort(url),
|
|
6810
|
-
source: getUrlSource(url),
|
|
6811
|
-
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
6812
|
-
isIp4Address: isIp4Address(getUrlSource(url)),
|
|
6813
|
-
isIp6Address: isIp6Address(getUrlSource(url))
|
|
6814
|
-
};
|
|
6999
|
+
function isIkeaUrl(val) {
|
|
7000
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6815
7001
|
}
|
|
6816
|
-
function
|
|
6817
|
-
return
|
|
7002
|
+
function isLowesUrl(val) {
|
|
7003
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6818
7004
|
}
|
|
6819
|
-
function
|
|
6820
|
-
|
|
6821
|
-
const id = getUrlQueryParams(url, "v");
|
|
6822
|
-
return `https://www.youtube.com/embed/${id}`;
|
|
6823
|
-
} else if (isYouTubeShareUrl(url)) {
|
|
6824
|
-
const id = url.split("/").pop();
|
|
6825
|
-
if (id) {
|
|
6826
|
-
return `https://www.youtube.com/embed/${id}`;
|
|
6827
|
-
} else {
|
|
6828
|
-
throw new Error(`Unexpected problem parsing share URL -- "${url}" -- into a YouTube embed URL`);
|
|
6829
|
-
}
|
|
6830
|
-
} else {
|
|
6831
|
-
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
6832
|
-
}
|
|
7005
|
+
function isNikeUrl(val) {
|
|
7006
|
+
return isString(val) && NIKE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6833
7007
|
}
|
|
6834
|
-
function
|
|
6835
|
-
return
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
isYouTubeUrl: false
|
|
6843
|
-
};
|
|
7008
|
+
function isWayfairUrl(val) {
|
|
7009
|
+
return isString(val) && WAYFAIR_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7010
|
+
}
|
|
7011
|
+
function isBestBuyUrl(val) {
|
|
7012
|
+
return isString(val) && BEST_BUY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7013
|
+
}
|
|
7014
|
+
function isCostCoUrl(val) {
|
|
7015
|
+
return isString(val) && COSTCO_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6844
7016
|
}
|
|
6845
|
-
function
|
|
6846
|
-
return {
|
|
6847
|
-
queue: state,
|
|
6848
|
-
size: state.length,
|
|
6849
|
-
isEmpty() {
|
|
6850
|
-
return state.length === 0;
|
|
6851
|
-
},
|
|
6852
|
-
clear() {
|
|
6853
|
-
state.slice(0, 0);
|
|
6854
|
-
},
|
|
6855
|
-
drain() {
|
|
6856
|
-
const old_state = [...state];
|
|
6857
|
-
state.slice(0, 0);
|
|
6858
|
-
return old_state;
|
|
6859
|
-
},
|
|
6860
|
-
push(...add) {
|
|
6861
|
-
state.push(...add);
|
|
6862
|
-
},
|
|
6863
|
-
drop(quantity) {
|
|
6864
|
-
if (quantity && quantity > state.length) {
|
|
6865
|
-
throw new Error("Cannot drop more elements than present in the queue");
|
|
6866
|
-
}
|
|
6867
|
-
state.splice(0, quantity || 1);
|
|
6868
|
-
},
|
|
6869
|
-
take(quantity) {
|
|
6870
|
-
if (quantity && quantity > state.length) {
|
|
6871
|
-
throw new Error("Cannot take more elements than present in the queue");
|
|
6872
|
-
}
|
|
6873
|
-
const result2 = state.slice(0, quantity || 1);
|
|
6874
|
-
state.splice(0, quantity || 1);
|
|
6875
|
-
return result2;
|
|
6876
|
-
},
|
|
6877
|
-
*[Symbol.iterator]() {
|
|
6878
|
-
for (let i = 0; i < state.length; i++) {
|
|
6879
|
-
yield state[i];
|
|
6880
|
-
}
|
|
6881
|
-
}
|
|
6882
|
-
};
|
|
7017
|
+
function isEtsyUrl(val) {
|
|
7018
|
+
return isString(val) && ETSY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6883
7019
|
}
|
|
6884
|
-
function
|
|
6885
|
-
return
|
|
7020
|
+
function isTargetUrl(val) {
|
|
7021
|
+
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6886
7022
|
}
|
|
6887
|
-
function
|
|
6888
|
-
return {
|
|
6889
|
-
queue: state,
|
|
6890
|
-
size: state.length,
|
|
6891
|
-
isEmpty() {
|
|
6892
|
-
return state.length === 0;
|
|
6893
|
-
},
|
|
6894
|
-
push(...add) {
|
|
6895
|
-
state.push(...add);
|
|
6896
|
-
},
|
|
6897
|
-
drop(quantity) {
|
|
6898
|
-
state.splice(-quantity);
|
|
6899
|
-
},
|
|
6900
|
-
clear() {
|
|
6901
|
-
state.slice(0, 0);
|
|
6902
|
-
},
|
|
6903
|
-
drain() {
|
|
6904
|
-
const old_state = [...state];
|
|
6905
|
-
state.slice(0, 0);
|
|
6906
|
-
return old_state;
|
|
6907
|
-
},
|
|
6908
|
-
take(quantity) {
|
|
6909
|
-
const result2 = state.slice(-quantity);
|
|
6910
|
-
state.splice(-quantity);
|
|
6911
|
-
return result2;
|
|
6912
|
-
},
|
|
6913
|
-
*[Symbol.iterator]() {
|
|
6914
|
-
for (let i = state.length - 1; i >= 0; i--) {
|
|
6915
|
-
yield state[i];
|
|
6916
|
-
}
|
|
6917
|
-
}
|
|
6918
|
-
};
|
|
7023
|
+
function isEbayUrl(val) {
|
|
7024
|
+
return isString(val) && EBAY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6919
7025
|
}
|
|
6920
|
-
function
|
|
6921
|
-
return
|
|
7026
|
+
function isHomeDepotUrl(val) {
|
|
7027
|
+
return isString(val) && HOME_DEPOT_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6922
7028
|
}
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
number: "<<number>>",
|
|
6926
|
-
boolean: "<<boolean>>",
|
|
6927
|
-
true: "<<true>>",
|
|
6928
|
-
false: "<<false>>",
|
|
6929
|
-
null: "<<null>>",
|
|
6930
|
-
undefined: "<<undefined>>",
|
|
6931
|
-
unknown: "<<unknown>>",
|
|
6932
|
-
any: "<<any>>",
|
|
6933
|
-
never: "<<never>>"
|
|
6934
|
-
});
|
|
6935
|
-
function stringLiteral(str) {
|
|
6936
|
-
return stripAfter(stripBefore(str, "string("), ")");
|
|
7029
|
+
function isMacysUrl(val) {
|
|
7030
|
+
return isString(val) && MACYS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6937
7031
|
}
|
|
6938
|
-
function
|
|
6939
|
-
return
|
|
7032
|
+
function isAppleUrl(val) {
|
|
7033
|
+
return isString(val) && APPLE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6940
7034
|
}
|
|
6941
|
-
function
|
|
6942
|
-
|
|
6943
|
-
return bare.startsWith("string") ? `<<union::[ <<string>>, <<undefined>> ]>>` : bare.startsWith("number") ? `<<union::[ <<number>>, <<undefined>> ]>>` : bare.startsWith("boolean") ? `<<union::[ <<boolean>>, <<undefined>> ]>>` : bare.startsWith("unknown") ? `<<union::[ <<unknown>>, <<undefined>> ]>>` : `<<never>>`;
|
|
7035
|
+
function isWalmartUrl(val) {
|
|
7036
|
+
return isString(val) && WALMART_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6944
7037
|
}
|
|
6945
|
-
function
|
|
6946
|
-
return
|
|
7038
|
+
function isAmazonUrl(val) {
|
|
7039
|
+
return isString(val) && AMAZON_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6947
7040
|
}
|
|
6948
|
-
function
|
|
6949
|
-
return
|
|
7041
|
+
function isRetailUrl(val) {
|
|
7042
|
+
return isAmazonUrl(val) || isWalgreensUrl(val) || isAppleUrl(val) || isMacysUrl(val) || isEbayUrl(val) || isHomeDepotUrl(val) || isTargetUrl(val) || isEtsyUrl(val) || isCostCoUrl(val) || isBestBuyUrl(val) || isWayfairUrl(val) || isNikeUrl(val) || isLowesUrl(val) || isIkeaUrl(val) || isDellUrl(val) || isHmUrl(val) || isZaraUrl(val) || isKrogersUrl(val) || isWalgreensUrl(val) || isCvsUrl(val) || isWholeFoodsUrl(val);
|
|
6950
7043
|
}
|
|
6951
|
-
|
|
6952
|
-
|
|
7044
|
+
var URL20 = SOCIAL_MEDIA2.flatMap((i) => i.baseUrls);
|
|
7045
|
+
var PROFILE = SOCIAL_MEDIA2.map((i) => i.profileUrl);
|
|
7046
|
+
function isSocialMediaUrl(val) {
|
|
7047
|
+
return isString(val) && URL20.some((i) => val.startsWith(i));
|
|
6953
7048
|
}
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
return val.startsWith(`Union(`) && val.endsWith(`)`) ? `<<union::[ ${union2(stripUnion(val))} ]>>` : Never2;
|
|
7049
|
+
function isSocialMediaProfileUrl(val) {
|
|
7050
|
+
return isString(val) && PROFILE.some((i) => i.startsWith(`${i}`));
|
|
6957
7051
|
}
|
|
6958
|
-
function
|
|
7052
|
+
function isYouTubeUrl(val) {
|
|
7053
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
6959
7054
|
}
|
|
6960
|
-
function
|
|
6961
|
-
return
|
|
7055
|
+
function isYouTubeShareUrl(val) {
|
|
7056
|
+
return isString(val) && val.startsWith(`https://youtu.be`);
|
|
6962
7057
|
}
|
|
6963
|
-
function
|
|
6964
|
-
return
|
|
7058
|
+
function isYouTubeVideoUrl(val) {
|
|
7059
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
6965
7060
|
}
|
|
6966
|
-
function
|
|
6967
|
-
return
|
|
7061
|
+
function isYouTubePlaylistUrl(val) {
|
|
7062
|
+
return isString(val) && (val === `https://www.youtube.com/feed/playlists` || val === `https://youtube.com/feed/playlists` || val === `https://www.youtube.com/channel/playlists` || val === `https://youtube.com/channel/playlists` || val.startsWith(`https://www.youtube.com/@`) && val.endsWith(`/playlists`) || val.startsWith(`https://youtube.com/@`) && val.endsWith(`/playlists`));
|
|
6968
7063
|
}
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
var nullType = () => "<<null>>";
|
|
6972
|
-
function fn(..._args) {
|
|
6973
|
-
return {
|
|
6974
|
-
returns: (_rtn) => ({
|
|
6975
|
-
addProperties: (_kv) => {
|
|
6976
|
-
return null;
|
|
6977
|
-
},
|
|
6978
|
-
done: () => {
|
|
6979
|
-
return null;
|
|
6980
|
-
}
|
|
6981
|
-
}),
|
|
6982
|
-
done: () => {
|
|
6983
|
-
const result2 = null;
|
|
6984
|
-
return result2;
|
|
6985
|
-
}
|
|
6986
|
-
};
|
|
7064
|
+
function feed_map(type) {
|
|
7065
|
+
return isUndefined(type) ? `/feed` : type === "liked" ? `/playlist?list=LL` : ["history", "playlists", "trending", "subscriptions"].includes(type) ? `/feed/${type}` : `/feed/`;
|
|
6987
7066
|
}
|
|
6988
|
-
function
|
|
6989
|
-
return
|
|
7067
|
+
function isYouTubeFeedUrl(val, type) {
|
|
7068
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com${feed_map(type)}`) || val.startsWith(`https://youtube.com${feed_map(type)}`));
|
|
6990
7069
|
}
|
|
6991
|
-
function
|
|
6992
|
-
return
|
|
7070
|
+
function isYouTubeFeedHistoryUrl(val) {
|
|
7071
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/history`) || val.startsWith(`https://youtube.com/feed/history`));
|
|
6993
7072
|
}
|
|
6994
|
-
function
|
|
6995
|
-
|
|
6996
|
-
if (isString(re)) {
|
|
6997
|
-
try {
|
|
6998
|
-
const test = new RegExp(re);
|
|
6999
|
-
if (!isRegExp(test)) {
|
|
7000
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
7001
|
-
err.name = "InvalidRegEx";
|
|
7002
|
-
throw err;
|
|
7003
|
-
} else {
|
|
7004
|
-
exp = re;
|
|
7005
|
-
}
|
|
7006
|
-
} catch {
|
|
7007
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
7008
|
-
err.name = "InvalidRegEx";
|
|
7009
|
-
throw err;
|
|
7010
|
-
}
|
|
7011
|
-
} else if (isRegExp(re)) {
|
|
7012
|
-
exp = re.toString();
|
|
7013
|
-
}
|
|
7014
|
-
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
7015
|
-
return token;
|
|
7073
|
+
function isYouTubePlaylistsUrl(val) {
|
|
7074
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/playlists`) || val.startsWith(`https://youtube.com/feed/playlists`));
|
|
7016
7075
|
}
|
|
7017
|
-
function
|
|
7018
|
-
return (
|
|
7019
|
-
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
7020
|
-
"union",
|
|
7021
|
-
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
7022
|
-
);
|
|
7023
|
-
};
|
|
7076
|
+
function isYouTubeTrendingUrl(val) {
|
|
7077
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/trending`) || val.startsWith(`https://youtube.com/feed/trending`));
|
|
7024
7078
|
}
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
7028
|
-
zip: () => addToken("string-set", "Zip5"),
|
|
7029
|
-
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
7030
|
-
zipCode: () => addToken("string-set", "ZipCode"),
|
|
7031
|
-
militaryTime: (resolution) => {
|
|
7032
|
-
return addToken(
|
|
7033
|
-
"string-set",
|
|
7034
|
-
"militaryTime",
|
|
7035
|
-
resolution || "HH:MM"
|
|
7036
|
-
);
|
|
7037
|
-
},
|
|
7038
|
-
civilianTime: (resolution) => {
|
|
7039
|
-
return addToken(
|
|
7040
|
-
"string-set",
|
|
7041
|
-
"militaryTime",
|
|
7042
|
-
resolution || "HH:MM"
|
|
7043
|
-
);
|
|
7044
|
-
},
|
|
7045
|
-
numericString: () => addToken("string-set", "numeric"),
|
|
7046
|
-
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
7047
|
-
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
7048
|
-
regex: (exp, ...literalRepresentation) => {
|
|
7049
|
-
const token = regexToken(exp, ...literalRepresentation);
|
|
7050
|
-
return token;
|
|
7051
|
-
},
|
|
7052
|
-
done: () => addToken("string")
|
|
7053
|
-
};
|
|
7054
|
-
var string22 = addSingleton("string", stringApi);
|
|
7055
|
-
var number = addSingleton("number");
|
|
7056
|
-
function union3(...elements) {
|
|
7057
|
-
const result2 = elements.map((_el) => {
|
|
7058
|
-
});
|
|
7059
|
-
return result2;
|
|
7079
|
+
function isYouTubeSubscriptionsUrl(val) {
|
|
7080
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/subscriptions`) || val.startsWith(`https://youtube.com/feed/subscriptions`));
|
|
7060
7081
|
}
|
|
7061
|
-
function
|
|
7062
|
-
return
|
|
7082
|
+
function isYouTubeCreatorUrl(url) {
|
|
7083
|
+
return isString(url) && (url.startsWith(`https://www.youtube.com/@`) || url.startsWith(`https://youtube.com/@`) || url.startsWith(`https://www.youtube.com/channel/`));
|
|
7063
7084
|
}
|
|
7064
|
-
function
|
|
7065
|
-
return
|
|
7085
|
+
function isYouTubeVideosInPlaylist(val) {
|
|
7086
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
|
|
7066
7087
|
}
|
|
7067
|
-
function
|
|
7068
|
-
|
|
7088
|
+
function isVueRef(val) {
|
|
7089
|
+
if (isObject(val)) {
|
|
7090
|
+
const keys = Object.keys(val);
|
|
7091
|
+
return !!["dep", "__v_isRef"].every((i) => keys.includes(i));
|
|
7092
|
+
}
|
|
7093
|
+
return false;
|
|
7094
|
+
}
|
|
7095
|
+
function csv(csv2, format = `string-numeric-tuple`) {
|
|
7096
|
+
const tuple3 = [];
|
|
7097
|
+
csv2.split(/,\s?/).forEach((v) => {
|
|
7098
|
+
tuple3.push(
|
|
7099
|
+
format === "string-numeric-tuple" ? isNumberLike(v) ? Number(v) : v : format === "json-tuple" ? isNumberLike(v) ? Number(v) : v === "true" ? true : v === "false" ? false : `"${v}"` : format === "string-tuple" ? `${v}` : Never2
|
|
7100
|
+
);
|
|
7101
|
+
});
|
|
7102
|
+
return tuple3;
|
|
7069
7103
|
}
|
|
7070
|
-
function
|
|
7071
|
-
|
|
7104
|
+
function fromKeyValue(kvs) {
|
|
7105
|
+
const obj = {};
|
|
7106
|
+
for (const kv of kvs) {
|
|
7107
|
+
obj[kv.key] = kv.value;
|
|
7108
|
+
}
|
|
7109
|
+
return obj;
|
|
7072
7110
|
}
|
|
7073
|
-
function
|
|
7074
|
-
return
|
|
7111
|
+
function intersect(value, _intersectedWith) {
|
|
7112
|
+
return value;
|
|
7075
7113
|
}
|
|
7076
|
-
function
|
|
7077
|
-
return
|
|
7114
|
+
function ip6GroupExpansion(ip) {
|
|
7115
|
+
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
7078
7116
|
}
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
number,
|
|
7082
|
-
boolean,
|
|
7083
|
-
unknown,
|
|
7084
|
-
undefined: undefinedType,
|
|
7085
|
-
null: nullType,
|
|
7086
|
-
union: union3,
|
|
7087
|
-
fn,
|
|
7088
|
-
record,
|
|
7089
|
-
array,
|
|
7090
|
-
set,
|
|
7091
|
-
map,
|
|
7092
|
-
weakMap,
|
|
7093
|
-
dictionary,
|
|
7094
|
-
tuple: tuple2
|
|
7095
|
-
};
|
|
7096
|
-
function shape(cb) {
|
|
7097
|
-
const rtn = cb(ShapeApiImplementation);
|
|
7098
|
-
return handleDoneFn(
|
|
7099
|
-
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
7100
|
-
);
|
|
7117
|
+
function jsonValue(val) {
|
|
7118
|
+
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
7101
7119
|
}
|
|
7102
|
-
function
|
|
7103
|
-
return
|
|
7120
|
+
function jsonValues(...val) {
|
|
7121
|
+
return val.map((i) => jsonValue(i));
|
|
7104
7122
|
}
|
|
7105
|
-
function
|
|
7106
|
-
const
|
|
7107
|
-
|
|
7108
|
-
...acc,
|
|
7109
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
7110
|
-
} : isFunction(defn[i]) ? {
|
|
7111
|
-
...acc,
|
|
7112
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
7113
|
-
} : Never2,
|
|
7114
|
-
{}
|
|
7115
|
-
);
|
|
7116
|
-
return result2;
|
|
7123
|
+
function lookupAlpha2Code(code, prop) {
|
|
7124
|
+
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
7125
|
+
return found ? found[prop] : void 0;
|
|
7117
7126
|
}
|
|
7118
|
-
function
|
|
7119
|
-
|
|
7127
|
+
function lookupAlpha3Code(code, prop) {
|
|
7128
|
+
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
7129
|
+
return found ? found[prop] : void 0;
|
|
7120
7130
|
}
|
|
7121
|
-
function
|
|
7122
|
-
|
|
7131
|
+
function lookupName(name, prop) {
|
|
7132
|
+
const found = ISO3166_12.find((i) => i.name === name);
|
|
7133
|
+
return found ? found[prop] : void 0;
|
|
7123
7134
|
}
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
fillIn.push(empty);
|
|
7135
|
+
function lookupNumericCode(code, prop) {
|
|
7136
|
+
let num = isNumber(code) ? `${code}` : code;
|
|
7137
|
+
if (num.length === 1) {
|
|
7138
|
+
num = `00${num}`;
|
|
7139
|
+
} else if (num.length === 2) {
|
|
7140
|
+
num = `0${num}`;
|
|
7131
7141
|
}
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
[
|
|
7135
|
-
groups.join(":"),
|
|
7136
|
-
fillIn.join(":")
|
|
7137
|
-
].join(":"),
|
|
7138
|
-
">>"
|
|
7139
|
-
].join("");
|
|
7142
|
+
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
7143
|
+
return found ? found[prop] : void 0;
|
|
7140
7144
|
}
|
|
7141
|
-
function
|
|
7142
|
-
const
|
|
7143
|
-
|
|
7144
|
-
const proxy = new Proxy(state, {});
|
|
7145
|
-
Object.defineProperty(proxy, "id", {
|
|
7146
|
-
enumerable: false
|
|
7147
|
-
});
|
|
7148
|
-
return proxy;
|
|
7145
|
+
function lookupCountryName(code) {
|
|
7146
|
+
const uc = uppercase(code);
|
|
7147
|
+
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
7149
7148
|
}
|
|
7150
|
-
function
|
|
7151
|
-
|
|
7149
|
+
function lookupCountryAlpha2(code) {
|
|
7150
|
+
const uc = uppercase(code);
|
|
7151
|
+
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
7152
7152
|
}
|
|
7153
|
-
function
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
literal: (val) => `<<${kind}::${val}>>`
|
|
7157
|
-
};
|
|
7153
|
+
function lookupCountryAlpha3(token) {
|
|
7154
|
+
const uc = uppercase(token);
|
|
7155
|
+
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
7158
7156
|
}
|
|
7159
|
-
function
|
|
7160
|
-
|
|
7157
|
+
function lookupCountryCode(token) {
|
|
7158
|
+
const uc = uppercase(token);
|
|
7159
|
+
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
7161
7160
|
}
|
|
7162
|
-
function
|
|
7163
|
-
|
|
7164
|
-
|
|
7161
|
+
function asMapper(fn2) {
|
|
7162
|
+
const props = {
|
|
7163
|
+
kind: "Mapper",
|
|
7164
|
+
map: (from) => {
|
|
7165
|
+
return from.map(fn2);
|
|
7166
|
+
}
|
|
7165
7167
|
};
|
|
7168
|
+
return createFnWithPropsExplicit(fn2, props);
|
|
7166
7169
|
}
|
|
7167
|
-
function
|
|
7168
|
-
return
|
|
7169
|
-
|
|
7170
|
+
function createObjectMap() {
|
|
7171
|
+
return (map2) => {
|
|
7172
|
+
const fn2 = (input) => {
|
|
7173
|
+
return Object.keys(map2).reduce(
|
|
7174
|
+
(acc, key) => {
|
|
7175
|
+
const val = map2[key];
|
|
7176
|
+
return {
|
|
7177
|
+
...acc,
|
|
7178
|
+
[key]: isFunction(val) ? val(input) : val
|
|
7179
|
+
};
|
|
7180
|
+
},
|
|
7181
|
+
{}
|
|
7182
|
+
);
|
|
7183
|
+
};
|
|
7184
|
+
return fn2;
|
|
7170
7185
|
};
|
|
7171
7186
|
}
|
|
7172
|
-
function
|
|
7173
|
-
return
|
|
7187
|
+
function createMapper() {
|
|
7188
|
+
return (fn2) => {
|
|
7189
|
+
return asMapper(fn2);
|
|
7190
|
+
};
|
|
7174
7191
|
}
|
|
7175
|
-
function
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7192
|
+
function mergeObjects(defVal, override) {
|
|
7193
|
+
const intersectingKeys = sharedKeys(defVal, override);
|
|
7194
|
+
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
7195
|
+
const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
7196
|
+
const merged = {
|
|
7197
|
+
...intersectingKeys.reduce(
|
|
7198
|
+
(acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
|
|
7199
|
+
{}
|
|
7200
|
+
),
|
|
7201
|
+
...defUnique,
|
|
7202
|
+
...overrideUnique
|
|
7180
7203
|
};
|
|
7204
|
+
return merged;
|
|
7181
7205
|
}
|
|
7182
|
-
function
|
|
7183
|
-
return
|
|
7206
|
+
function mergeScalars(a, b) {
|
|
7207
|
+
return isUndefined(b) ? a : b;
|
|
7184
7208
|
}
|
|
7185
|
-
function
|
|
7186
|
-
return
|
|
7209
|
+
function mergeTuples(a, b) {
|
|
7210
|
+
return b.length > a.length ? b.map((v, idx) => v !== void 0 ? v : a[idx]) : [...b, ...a.slice(b.length)].map((v, idx) => v !== void 0 ? v : a[idx]);
|
|
7187
7211
|
}
|
|
7188
|
-
function
|
|
7189
|
-
|
|
7190
|
-
const parts = bare.split("::");
|
|
7191
|
-
const kind = parts.pop();
|
|
7192
|
-
return kind;
|
|
7212
|
+
function never(val) {
|
|
7213
|
+
return val;
|
|
7193
7214
|
}
|
|
7194
|
-
|
|
7195
|
-
var simpleScalarToken = (token) => token;
|
|
7196
|
-
var simpleContainerToken = (token) => token;
|
|
7197
|
-
function simpleScalarType(token) {
|
|
7198
|
-
const value = simpleScalarToken(token);
|
|
7215
|
+
function optional(value) {
|
|
7199
7216
|
return value;
|
|
7200
7217
|
}
|
|
7201
|
-
function
|
|
7202
|
-
const value = simpleContainerToken(token);
|
|
7218
|
+
function orNull(value) {
|
|
7203
7219
|
return value;
|
|
7204
7220
|
}
|
|
7205
|
-
function
|
|
7206
|
-
const value = isSimpleScalarToken(token) ? simpleScalarType(token) : isSimpleContainerToken(token) ? simpleContainerToken(token) : Never2;
|
|
7221
|
+
function optionalOrNull(value) {
|
|
7207
7222
|
return value;
|
|
7208
7223
|
}
|
|
7209
|
-
function
|
|
7210
|
-
|
|
7224
|
+
function stripParenthesis(val) {
|
|
7225
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
7226
|
+
}
|
|
7227
|
+
function sortKeyApi(order) {
|
|
7228
|
+
return {
|
|
7229
|
+
order,
|
|
7230
|
+
toTop: (...keys) => sortKeyApi(
|
|
7231
|
+
[
|
|
7232
|
+
...keys.toReversed(),
|
|
7233
|
+
...order.filter((i) => !keys.includes(i))
|
|
7234
|
+
]
|
|
7235
|
+
),
|
|
7236
|
+
toBottom: (...keys) => sortKeyApi(
|
|
7237
|
+
[
|
|
7238
|
+
...order.filter((i) => !keys.includes(i)),
|
|
7239
|
+
...keys
|
|
7240
|
+
]
|
|
7241
|
+
),
|
|
7242
|
+
done: () => order
|
|
7243
|
+
};
|
|
7244
|
+
}
|
|
7245
|
+
function toKeyValue(obj, sort) {
|
|
7246
|
+
let keys = keysOf(obj);
|
|
7247
|
+
const tuple3 = [];
|
|
7248
|
+
if (sort) {
|
|
7249
|
+
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
7250
|
+
}
|
|
7211
7251
|
for (const k of keys) {
|
|
7212
|
-
|
|
7213
|
-
return true;
|
|
7214
|
-
}
|
|
7252
|
+
tuple3.push({ key: k, value: obj[k] });
|
|
7215
7253
|
}
|
|
7216
|
-
return
|
|
7254
|
+
return tuple3;
|
|
7217
7255
|
}
|
|
7218
|
-
function
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7256
|
+
function convertScalar(val) {
|
|
7257
|
+
switch (typeof val) {
|
|
7258
|
+
case "number":
|
|
7259
|
+
return val;
|
|
7260
|
+
case "string":
|
|
7261
|
+
return Number(val);
|
|
7262
|
+
case "boolean":
|
|
7263
|
+
return val ? 1 : 0;
|
|
7264
|
+
default:
|
|
7265
|
+
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
7227
7266
|
}
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7267
|
+
}
|
|
7268
|
+
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
7269
|
+
function toNumber(value) {
|
|
7270
|
+
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
7271
|
+
}
|
|
7272
|
+
var MODS = TW_MODIFIERS2.map((i) => `${i}:`);
|
|
7273
|
+
function removeTailwindModifiers(val) {
|
|
7274
|
+
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
7275
|
+
}
|
|
7276
|
+
function getTailwindModifiers(val) {
|
|
7277
|
+
return val.split(":").filter((i) => isTailwindModifier(i));
|
|
7278
|
+
}
|
|
7279
|
+
function union3(..._options) {
|
|
7280
|
+
return (value) => value;
|
|
7281
|
+
}
|
|
7282
|
+
function unionize(value, _inUnionWith) {
|
|
7283
|
+
return value;
|
|
7235
7284
|
}
|
|
7236
7285
|
function asVueRef(value) {
|
|
7237
7286
|
return {
|
|
@@ -7672,6 +7721,7 @@ export {
|
|
|
7672
7721
|
defineObject,
|
|
7673
7722
|
defineObjectApi,
|
|
7674
7723
|
defineTuple,
|
|
7724
|
+
doesExtend,
|
|
7675
7725
|
endsWith,
|
|
7676
7726
|
ensureLeading,
|
|
7677
7727
|
ensureSurround,
|
|
@@ -7682,6 +7732,7 @@ export {
|
|
|
7682
7732
|
find,
|
|
7683
7733
|
fnMeta,
|
|
7684
7734
|
fromDefineObject,
|
|
7735
|
+
fromKeyValue,
|
|
7685
7736
|
get,
|
|
7686
7737
|
getDaysBetween,
|
|
7687
7738
|
getEach,
|
|
@@ -7964,6 +8015,7 @@ export {
|
|
|
7964
8015
|
isVoltageUom,
|
|
7965
8016
|
isVolumeMetric,
|
|
7966
8017
|
isVolumeUom,
|
|
8018
|
+
isVueRef,
|
|
7967
8019
|
isWalgreensUrl,
|
|
7968
8020
|
isWalmartUrl,
|
|
7969
8021
|
isWayfairUrl,
|
|
@@ -8057,6 +8109,7 @@ export {
|
|
|
8057
8109
|
takeProp,
|
|
8058
8110
|
toCamelCase,
|
|
8059
8111
|
toKebabCase,
|
|
8112
|
+
toKeyValue,
|
|
8060
8113
|
toNumber,
|
|
8061
8114
|
toNumericArray,
|
|
8062
8115
|
toPascalCase,
|
|
@@ -8073,7 +8126,7 @@ export {
|
|
|
8073
8126
|
twColor,
|
|
8074
8127
|
unbox,
|
|
8075
8128
|
uncapitalize,
|
|
8076
|
-
union,
|
|
8129
|
+
union3 as union,
|
|
8077
8130
|
unionize,
|
|
8078
8131
|
unique,
|
|
8079
8132
|
uniqueKeys,
|