@scalar/helpers 0.0.7 → 0.0.9
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/CHANGELOG.md +13 -0
- package/dist/array/is-defined.d.ts.map +1 -1
- package/dist/dom/freeze-at-top.d.ts.map +1 -1
- package/dist/dom/freeze-element.d.ts.map +1 -1
- package/dist/dom/scroll-to-id.d.ts.map +1 -1
- package/dist/file/json2xml.d.ts +5 -1
- package/dist/file/json2xml.d.ts.map +1 -1
- package/dist/file/json2xml.js +35 -22
- package/dist/file/json2xml.js.map +2 -2
- package/dist/http/can-method-have-body.d.ts.map +1 -1
- package/dist/http/http-info.d.ts.map +1 -1
- package/dist/http/http-methods.d.ts +1 -1
- package/dist/http/http-methods.d.ts.map +1 -1
- package/dist/http/http-methods.js +1 -1
- package/dist/http/http-methods.js.map +2 -2
- package/dist/http/is-http-method.d.ts.map +1 -1
- package/dist/http/normalize-http-method.d.ts.map +1 -1
- package/dist/object/object-keys.d.ts.map +1 -1
- package/dist/object/object-replace.d.ts.map +1 -1
- package/dist/object/omit-undefined-values.d.ts.map +1 -1
- package/dist/regex/find-variables.d.ts.map +1 -1
- package/dist/string/camel-to-title.d.ts.map +1 -1
- package/dist/string/capitalize.d.ts.map +1 -1
- package/dist/string/create-hash.d.ts.map +1 -1
- package/dist/string/iterate-title.d.ts.map +1 -1
- package/dist/testing/measure.d.ts +20 -15
- package/dist/testing/measure.d.ts.map +1 -1
- package/dist/testing/measure.js +11 -2
- package/dist/testing/measure.js.map +2 -2
- package/dist/testing/sleep.d.ts.map +1 -1
- package/dist/url/is-relative-path.d.ts.map +1 -1
- package/dist/url/make-url-absolute.d.ts.map +1 -1
- package/dist/url/merge-urls.d.ts +3 -1
- package/dist/url/merge-urls.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @scalar/helpers
|
|
2
2
|
|
|
3
|
+
## 0.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 98c55d0: feat: better xml rendering
|
|
8
|
+
- 0e747c7: fix: initial scroll to id lands in random positions
|
|
9
|
+
|
|
10
|
+
## 0.0.8
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 66b18fc: feat: update the references to handle $refs from the magic proxy
|
|
15
|
+
|
|
3
16
|
## 0.0.7
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-defined.d.ts","sourceRoot":"","sources":["../../src/array/is-defined.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"is-defined.d.ts","sourceRoot":"","sources":["../../src/array/is-defined.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAC1C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeze-at-top.d.ts","sourceRoot":"","sources":["../../src/dom/freeze-at-top.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"freeze-at-top.d.ts","sourceRoot":"","sources":["../../src/dom/freeze-at-top.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,eAyCrC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeze-element.d.ts","sourceRoot":"","sources":["../../src/dom/freeze-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"freeze-element.d.ts","sourceRoot":"","sources":["../../src/dom/freeze-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,WAAW,eA4DjD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-to-id.d.ts","sourceRoot":"","sources":["../../src/dom/scroll-to-id.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"scroll-to-id.d.ts","sourceRoot":"","sources":["../../src/dom/scroll-to-id.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,IAAI,MAAM,EAAE,QAAQ,OAAO,kBAkC3D,CAAA"}
|
package/dist/file/json2xml.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This function converts an object to XML.
|
|
3
3
|
*/
|
|
4
|
-
export declare function json2xml(data: Record<string, any>,
|
|
4
|
+
export declare function json2xml(data: Record<string, any>, options?: {
|
|
5
|
+
indent?: string;
|
|
6
|
+
format?: boolean;
|
|
7
|
+
xmlDeclaration?: boolean;
|
|
8
|
+
}): string;
|
|
5
9
|
//# sourceMappingURL=json2xml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json2xml.d.ts","sourceRoot":"","sources":["../../src/file/json2xml.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,
|
|
1
|
+
{"version":3,"file":"json2xml.d.ts","sourceRoot":"","sources":["../../src/file/json2xml.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;CACpB,UAyEP"}
|
package/dist/file/json2xml.js
CHANGED
|
@@ -1,45 +1,58 @@
|
|
|
1
|
-
function json2xml(data,
|
|
2
|
-
const
|
|
1
|
+
function json2xml(data, options = {}) {
|
|
2
|
+
const { indent = " ", format = true, xmlDeclaration = true } = options;
|
|
3
|
+
const toXml = (value, key, currentIndent) => {
|
|
3
4
|
let xml2 = "";
|
|
4
5
|
if (Array.isArray(value)) {
|
|
5
6
|
for (let i = 0, n = value.length; i < n; i++) {
|
|
6
|
-
xml2 +=
|
|
7
|
+
xml2 += toXml(value[i], key, currentIndent);
|
|
7
8
|
}
|
|
8
|
-
} else if (typeof value === "object") {
|
|
9
|
+
} else if (typeof value === "object" && value !== null) {
|
|
9
10
|
let hasChild = false;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
let attributes = "";
|
|
12
|
+
let children = "";
|
|
13
|
+
for (const attr in value) {
|
|
14
|
+
if (attr.charAt(0) === "@") {
|
|
15
|
+
attributes += " " + attr.substr(1) + '="' + value[attr].toString() + '"';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (const child in value) {
|
|
19
|
+
if (child === "#text") {
|
|
20
|
+
children += value[child];
|
|
21
|
+
} else if (child === "#cdata") {
|
|
22
|
+
children += "<![CDATA[" + value[child] + "]]>";
|
|
23
|
+
} else if (child.charAt(0) !== "@") {
|
|
15
24
|
hasChild = true;
|
|
25
|
+
children += toXml(value[child], child, currentIndent + indent);
|
|
16
26
|
}
|
|
17
27
|
}
|
|
18
|
-
xml2 += hasChild ? ">" : "/>";
|
|
19
28
|
if (hasChild) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} else if (m.charAt(0) !== "@") {
|
|
26
|
-
xml2 += toXml(value[m], m, indentation + " ");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
xml2 += (xml2.charAt(xml2.length - 1) === "\n" ? indentation : "") + "</" + key + ">";
|
|
29
|
+
xml2 += currentIndent + "<" + key + attributes + ">\n";
|
|
30
|
+
xml2 += children;
|
|
31
|
+
xml2 += currentIndent + "</" + key + ">\n";
|
|
32
|
+
} else {
|
|
33
|
+
xml2 += currentIndent + "<" + key + attributes + "/>\n";
|
|
30
34
|
}
|
|
31
35
|
} else {
|
|
32
|
-
xml2 +=
|
|
36
|
+
xml2 += currentIndent + "<" + key + ">" + (value?.toString() || "") + "</" + key + ">\n";
|
|
33
37
|
}
|
|
34
38
|
return xml2;
|
|
35
39
|
};
|
|
36
40
|
let xml = "";
|
|
41
|
+
if (xmlDeclaration) {
|
|
42
|
+
xml += '<?xml version="1.0" encoding="UTF-8"?>';
|
|
43
|
+
if (format) {
|
|
44
|
+
xml += "\n";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
37
47
|
for (const key in data) {
|
|
38
48
|
if (Object.hasOwn(data, key)) {
|
|
39
49
|
xml += toXml(data[key], key, "");
|
|
40
50
|
}
|
|
41
51
|
}
|
|
42
|
-
|
|
52
|
+
if (format) {
|
|
53
|
+
return xml.trim();
|
|
54
|
+
}
|
|
55
|
+
return xml.replace(/\n/g, "").replace(/>\s+</g, "><").trim();
|
|
43
56
|
}
|
|
44
57
|
export {
|
|
45
58
|
json2xml
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/file/json2xml.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * This function converts an object to XML.\n */\nexport function json2xml(data: Record<string, any
|
|
5
|
-
"mappings": "AAGO,SAAS,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * This function converts an object to XML.\n */\nexport function json2xml(\n data: Record<string, any>,\n options: {\n indent?: string\n format?: boolean\n xmlDeclaration?: boolean\n } = {},\n) {\n const { indent = ' ', format = true, xmlDeclaration = true } = options\n\n const toXml = (value: any, key: string, currentIndent: string): string => {\n let xml = ''\n\n if (Array.isArray(value)) {\n for (let i = 0, n = value.length; i < n; i++) {\n xml += toXml(value[i], key, currentIndent)\n }\n } else if (typeof value === 'object' && value !== null) {\n let hasChild = false\n let attributes = ''\n let children = ''\n\n // Handle attributes (keys starting with @)\n for (const attr in value) {\n if (attr.charAt(0) === '@') {\n attributes += ' ' + attr.substr(1) + '=\"' + value[attr].toString() + '\"'\n }\n }\n\n // Handle children and special content\n for (const child in value) {\n if (child === '#text') {\n children += value[child]\n } else if (child === '#cdata') {\n children += '<![CDATA[' + value[child] + ']]>'\n } else if (child.charAt(0) !== '@') {\n hasChild = true\n children += toXml(value[child], child, currentIndent + indent)\n }\n }\n\n if (hasChild) {\n xml += currentIndent + '<' + key + attributes + '>\\n'\n xml += children\n xml += currentIndent + '</' + key + '>\\n'\n } else {\n xml += currentIndent + '<' + key + attributes + '/>\\n'\n }\n } else {\n xml += currentIndent + '<' + key + '>' + (value?.toString() || '') + '</' + key + '>\\n'\n }\n\n return xml\n }\n\n let xml = ''\n\n // Add XML declaration if requested\n if (xmlDeclaration) {\n xml += '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n if (format) {\n xml += '\\n'\n }\n }\n\n // Convert data to XML\n for (const key in data) {\n if (Object.hasOwn(data, key)) {\n xml += toXml(data[key], key, '')\n }\n }\n\n // Format or compact the output\n if (format) {\n return xml.trim()\n }\n\n // Remove all newlines and extra spaces, but keep the XML declaration clean\n return xml.replace(/\\n/g, '').replace(/>\\s+</g, '><').trim()\n}\n"],
|
|
5
|
+
"mappings": "AAGO,SAAS,SACd,MACA,UAII,CAAC,GACL;AACA,QAAM,EAAE,SAAS,MAAM,SAAS,MAAM,iBAAiB,KAAK,IAAI;AAEhE,QAAM,QAAQ,CAAC,OAAY,KAAa,kBAAkC;AACxE,QAAIA,OAAM;AAEV,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,IAAI,GAAG,KAAK;AAC5C,QAAAA,QAAO,MAAM,MAAM,CAAC,GAAG,KAAK,aAAa;AAAA,MAC3C;AAAA,IACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACtD,UAAI,WAAW;AACf,UAAI,aAAa;AACjB,UAAI,WAAW;AAGf,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,OAAO,CAAC,MAAM,KAAK;AAC1B,wBAAc,MAAM,KAAK,OAAO,CAAC,IAAI,OAAO,MAAM,IAAI,EAAE,SAAS,IAAI;AAAA,QACvE;AAAA,MACF;AAGA,iBAAW,SAAS,OAAO;AACzB,YAAI,UAAU,SAAS;AACrB,sBAAY,MAAM,KAAK;AAAA,QACzB,WAAW,UAAU,UAAU;AAC7B,sBAAY,cAAc,MAAM,KAAK,IAAI;AAAA,QAC3C,WAAW,MAAM,OAAO,CAAC,MAAM,KAAK;AAClC,qBAAW;AACX,sBAAY,MAAM,MAAM,KAAK,GAAG,OAAO,gBAAgB,MAAM;AAAA,QAC/D;AAAA,MACF;AAEA,UAAI,UAAU;AACZ,QAAAA,QAAO,gBAAgB,MAAM,MAAM,aAAa;AAChD,QAAAA,QAAO;AACP,QAAAA,QAAO,gBAAgB,OAAO,MAAM;AAAA,MACtC,OAAO;AACL,QAAAA,QAAO,gBAAgB,MAAM,MAAM,aAAa;AAAA,MAClD;AAAA,IACF,OAAO;AACL,MAAAA,QAAO,gBAAgB,MAAM,MAAM,OAAO,OAAO,SAAS,KAAK,MAAM,OAAO,MAAM;AAAA,IACpF;AAEA,WAAOA;AAAA,EACT;AAEA,MAAI,MAAM;AAGV,MAAI,gBAAgB;AAClB,WAAO;AACP,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAAA,EACF;AAGA,aAAW,OAAO,MAAM;AACtB,QAAI,OAAO,OAAO,MAAM,GAAG,GAAG;AAC5B,aAAO,MAAM,KAAK,GAAG,GAAG,KAAK,EAAE;AAAA,IACjC;AAAA,EACF;AAGA,MAAI,QAAQ;AACV,WAAO,IAAI,KAAK;AAAA,EAClB;AAGA,SAAO,IAAI,QAAQ,OAAO,EAAE,EAAE,QAAQ,UAAU,IAAI,EAAE,KAAK;AAC7D;",
|
|
6
6
|
"names": ["xml"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can-method-have-body.d.ts","sourceRoot":"","sources":["../../src/http/can-method-have-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,yCAAyC;AACzC,QAAA,MAAM,YAAY,oCAAqE,CAAA;AACvF,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"can-method-have-body.d.ts","sourceRoot":"","sources":["../../src/http/can-method-have-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,yCAAyC;AACzC,QAAA,MAAM,YAAY,oCAAqE,CAAA;AACvF,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,GAAI,QAAQ,UAAU,KAAG,MAAM,IAAI,UACN,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-info.d.ts","sourceRoot":"","sources":["../../src/http/http-info.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,QAAQ,MAAM,EAAE,CAAA;IAC5B,QAAQ,EAAE,sBAAsB,MAAM,GAAG,CAAA;IACzC,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDqB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"http-info.d.ts","sourceRoot":"","sources":["../../src/http/http-info.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,QAAQ,MAAM,EAAE,CAAA;IAC5B,QAAQ,EAAE,sBAAsB,MAAM,GAAG,CAAA;IACzC,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDqB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASnD,CAAA"}
|
|
@@ -3,5 +3,5 @@ export declare const HTTP_METHODS: readonly ["connect", "delete", "get", "head",
|
|
|
3
3
|
/** All http methods we support */
|
|
4
4
|
export type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
5
5
|
/** Set of all http methods we support */
|
|
6
|
-
export declare const httpMethods: Set<"connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace"
|
|
6
|
+
export declare const httpMethods: Readonly<Set<"connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace">>;
|
|
7
7
|
//# sourceMappingURL=http-methods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-methods.d.ts","sourceRoot":"","sources":["../../src/http/http-methods.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,eAAO,MAAM,YAAY,2FAA4F,CAAA;AAErH,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD,yCAAyC;AACzC,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"http-methods.d.ts","sourceRoot":"","sources":["../../src/http/http-methods.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,eAAO,MAAM,YAAY,2FAA4F,CAAA;AAErH,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD,yCAAyC;AACzC,eAAO,MAAM,WAAW,uGAAuC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/http/http-methods.ts"],
|
|
4
|
-
"sourcesContent": ["/** All OpenAPI HTTP methods plus connect */\nexport const HTTP_METHODS = ['connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'] as const\n\n/** All http methods we support */\nexport type HttpMethod = (typeof HTTP_METHODS)[number]\n\n/** Set of all http methods we support */\nexport const httpMethods = new Set(HTTP_METHODS)\n"],
|
|
5
|
-
"mappings": "AACO,MAAM,eAAe,CAAC,WAAW,UAAU,OAAO,QAAQ,WAAW,SAAS,QAAQ,OAAO,OAAO;AAMpG,MAAM,cAAc,IAAI,IAAI,YAAY;",
|
|
4
|
+
"sourcesContent": ["/** All OpenAPI HTTP methods plus connect */\nexport const HTTP_METHODS = ['connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'] as const\n\n/** All http methods we support */\nexport type HttpMethod = (typeof HTTP_METHODS)[number]\n\n/** Set of all http methods we support */\nexport const httpMethods = Object.freeze(new Set(HTTP_METHODS))\n"],
|
|
5
|
+
"mappings": "AACO,MAAM,eAAe,CAAC,WAAW,UAAU,OAAO,QAAQ,WAAW,SAAS,QAAQ,OAAO,OAAO;AAMpG,MAAM,cAAc,OAAO,OAAO,IAAI,IAAI,YAAY,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-http-method.d.ts","sourceRoot":"","sources":["../../src/http/is-http-method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE7D,yFAAyF;AACzF,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"is-http-method.d.ts","sourceRoot":"","sources":["../../src/http/is-http-method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE7D,yFAAyF;AACzF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,GAAG,SAAS,KAAG,MAAM,IAAI,UAC+B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-http-method.d.ts","sourceRoot":"","sources":["../../src/http/normalize-http-method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAKhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"normalize-http-method.d.ts","sourceRoot":"","sources":["../../src/http/normalize-http-method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAKhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,UAoBrD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-keys.d.ts","sourceRoot":"","sources":["../../src/object/object-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"object-keys.d.ts","sourceRoot":"","sources":["../../src/object/object-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,KAAG,CAAC,MAAM,CAAC,CAAC,EAAqC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-replace.d.ts","sourceRoot":"","sources":["../../src/object/object-replace.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"object-replace.d.ts","sourceRoot":"","sources":["../../src/object/object-replace.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,KAU7D,CAC7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omit-undefined-values.d.ts","sourceRoot":"","sources":["../../src/object/omit-undefined-values.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"omit-undefined-values.d.ts","sourceRoot":"","sources":["../../src/object/omit-undefined-values.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,CAkB/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-variables.d.ts","sourceRoot":"","sources":["../../src/regex/find-variables.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"find-variables.d.ts","sourceRoot":"","sources":["../../src/regex/find-variables.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,2BACiE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camel-to-title.d.ts","sourceRoot":"","sources":["../../src/string/camel-to-title.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"camel-to-title.d.ts","sourceRoot":"","sources":["../../src/string/camel-to-title.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,iBAAa,WAKpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/string/capitalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/string/capitalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,YAAQ,WAAiD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-hash.d.ts","sourceRoot":"","sources":["../../src/string/create-hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"create-hash.d.ts","sourceRoot":"","sources":["../../src/string/create-hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,MAe3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterate-title.d.ts","sourceRoot":"","sources":["../../src/string/iterate-title.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"iterate-title.d.ts","sourceRoot":"","sources":["../../src/string/iterate-title.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EAAE,kBAAgB,KAAG,MAa3G,CAAA"}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
/** Function overload for createApiReference to allow multiple different signatures */
|
|
2
|
-
export type Measure = {
|
|
3
|
-
<T>(name: string, fn: () => T): T;
|
|
4
|
-
<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
5
|
-
<T>(name: string, fn: () => T | Promise<T>): T | Promise<T>;
|
|
6
|
-
};
|
|
7
1
|
/**
|
|
8
2
|
* Measures the execution time of a function and logs it.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Works only with sync functions and returns the result of the measured function.
|
|
11
5
|
*
|
|
12
6
|
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* // Async function
|
|
15
|
-
* const result = await measure('api-call', async () => {
|
|
16
|
-
* return await fetchData()
|
|
17
|
-
* })
|
|
18
7
|
*
|
|
8
|
+
* ```ts
|
|
19
9
|
* // Sync function
|
|
20
|
-
* const result =
|
|
10
|
+
* const result = measureSync('computation', () => {
|
|
21
11
|
* return heavyComputation()
|
|
22
12
|
* })
|
|
23
13
|
* ```
|
|
24
14
|
*/
|
|
25
|
-
export declare const
|
|
15
|
+
export declare const measureSync: <T>(name: string, fn: () => T) => T;
|
|
16
|
+
/**
|
|
17
|
+
* Measures the execution time of an async function and logs it.
|
|
18
|
+
*
|
|
19
|
+
* Works only with async functions and returns the result of the measured function.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* // Async function
|
|
25
|
+
* const result = await measure('api-call', async () => {
|
|
26
|
+
* return await fetchData()
|
|
27
|
+
* })
|
|
28
|
+
* ````
|
|
29
|
+
*/
|
|
30
|
+
export declare const measureAsync: <T>(name: string, fn: () => Promise<T>) => Promise<T>;
|
|
26
31
|
//# sourceMappingURL=measure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/testing/measure.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/testing/measure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,MAAM,MAAM,EAAE,IAAI,MAAM,CAAC,KAAG,CAW1D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,EAAE,MAAM,MAAM,EAAE,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAWnF,CAAA"}
|
package/dist/testing/measure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const measureSync = (name, fn) => {
|
|
2
2
|
const start = performance.now();
|
|
3
3
|
const result = fn();
|
|
4
4
|
const end = performance.now();
|
|
@@ -6,7 +6,16 @@ const measure = (name, fn) => {
|
|
|
6
6
|
console.info(`${name}: ${duration} ms`);
|
|
7
7
|
return result;
|
|
8
8
|
};
|
|
9
|
+
const measureAsync = async (name, fn) => {
|
|
10
|
+
const start = performance.now();
|
|
11
|
+
const result = await fn();
|
|
12
|
+
const end = performance.now();
|
|
13
|
+
const duration = Math.round(end - start);
|
|
14
|
+
console.info(`${name}: ${duration} ms`);
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
9
17
|
export {
|
|
10
|
-
|
|
18
|
+
measureAsync,
|
|
19
|
+
measureSync
|
|
11
20
|
};
|
|
12
21
|
//# sourceMappingURL=measure.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/testing/measure.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Measures the execution time of a function and logs it.\n *\n * Works only with sync functions and returns the result of the measured function.\n *\n * @example\n *\n * ```ts\n * // Sync function\n * const result = measureSync('computation', () => {\n * return heavyComputation()\n * })\n * ```\n */\nexport const measureSync = <T>(name: string, fn: () => T): T => {\n const start = performance.now()\n\n const result = fn()\n\n const end = performance.now()\n const duration = Math.round(end - start)\n\n console.info(`${name}: ${duration} ms`)\n\n return result\n}\n\n/**\n * Measures the execution time of an async function and logs it.\n *\n * Works only with async functions and returns the result of the measured function.\n *\n * @example\n *\n * ```ts\n * // Async function\n * const result = await measure('api-call', async () => {\n * return await fetchData()\n * })\n * ````\n */\nexport const measureAsync = async <T>(name: string, fn: () => Promise<T>): Promise<T> => {\n const start = performance.now()\n\n const result = await fn()\n\n const end = performance.now()\n const duration = Math.round(end - start)\n\n console.info(`${name}: ${duration} ms`)\n\n return result\n}\n"],
|
|
5
|
+
"mappings": "AAcO,MAAM,cAAc,CAAI,MAAc,OAAmB;AAC9D,QAAM,QAAQ,YAAY,IAAI;AAE9B,QAAM,SAAS,GAAG;AAElB,QAAM,MAAM,YAAY,IAAI;AAC5B,QAAM,WAAW,KAAK,MAAM,MAAM,KAAK;AAEvC,UAAQ,KAAK,GAAG,IAAI,KAAK,QAAQ,KAAK;AAEtC,SAAO;AACT;AAgBO,MAAM,eAAe,OAAU,MAAc,OAAqC;AACvF,QAAM,QAAQ,YAAY,IAAI;AAE9B,QAAM,SAAS,MAAM,GAAG;AAExB,QAAM,MAAM,YAAY,IAAI;AAC5B,QAAM,WAAW,KAAK,MAAM,MAAM,KAAK;AAEvC,UAAQ,KAAK,GAAG,IAAI,KAAK,QAAQ,KAAK;AAEtC,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/testing/sleep.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/testing/sleep.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,qBAA0C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-relative-path.d.ts","sourceRoot":"","sources":["../../src/url/is-relative-path.ts"],"names":[],"mappings":"AAEA;;IAEI;AACJ,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"is-relative-path.d.ts","sourceRoot":"","sources":["../../src/url/is-relative-path.ts"],"names":[],"mappings":"AAEA;;IAEI;AACJ,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,YAazC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-url-absolute.d.ts","sourceRoot":"","sources":["../../src/url/make-url-absolute.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"make-url-absolute.d.ts","sourceRoot":"","sources":["../../src/url/make-url-absolute.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,MAAM,EACX,yBAKG;IACD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACb,KACL,MA6BF,CAAA"}
|
package/dist/url/merge-urls.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ export declare const combineUrlAndPath: (url: string, path: string) => string;
|
|
|
11
11
|
* also optionally merges query params if you include urlSearchParams
|
|
12
12
|
* This was re-written without using URL to support variables in the scheme
|
|
13
13
|
*/
|
|
14
|
-
export declare const mergeUrls: (url: string, path: string, urlParams?: URLSearchParams,
|
|
14
|
+
export declare const mergeUrls: (url: string, path: string, urlParams?: URLSearchParams,
|
|
15
|
+
/** To disable prefixing the url with the origin or a scheme*/
|
|
16
|
+
disableOriginPrefix?: boolean) => string;
|
|
15
17
|
//# sourceMappingURL=merge-urls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-urls.d.ts","sourceRoot":"","sources":["../../src/url/merge-urls.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"merge-urls.d.ts","sourceRoot":"","sources":["../../src/url/merge-urls.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,eAAe,EAAE,KAAG,eA6BhE,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,WAU1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,YAAW,eAAuC;AAClD,8DAA8D;AAC9D,6BAA2B,WAiC5B,CAAA"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"helpers",
|
|
15
15
|
"js"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.0.
|
|
17
|
+
"version": "0.0.9",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=20"
|
|
20
20
|
},
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"vite": "6.1.6",
|
|
82
82
|
"vitest": "^3.2.4",
|
|
83
|
-
"@scalar/build-tooling": "0.2.
|
|
83
|
+
"@scalar/build-tooling": "0.2.6"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "scalar-build-esbuild",
|