@scalar/helpers 0.0.7 → 0.0.8

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/helpers
2
2
 
3
+ ## 0.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 66b18fc: feat: update the references to handle $refs from the magic proxy
8
+
3
9
  ## 0.0.7
4
10
 
5
11
  ### Patch Changes
@@ -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,6FAAwB,CAAA"}
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,5 +1,5 @@
1
1
  const HTTP_METHODS = ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"];
2
- const httpMethods = new Set(HTTP_METHODS);
2
+ const httpMethods = Object.freeze(new Set(HTTP_METHODS));
3
3
  export {
4
4
  HTTP_METHODS,
5
5
  httpMethods
@@ -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,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
- * Works with both async and sync functions.
10
- * Returns the result of the measured function.
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 = measure('computation', () => {
10
+ * const result = measureSync('computation', () => {
21
11
  * return heavyComputation()
22
12
  * })
23
13
  * ```
24
14
  */
25
- export declare const measure: Measure;
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,sFAAsF;AACtF,MAAM,MAAM,OAAO,GAAG;IACpB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;IACjC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CAC5D,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,OAAO,EAAE,OAWrB,CAAA"}
1
+ {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/testing/measure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,QAAQ,MAAM,MAAM,MAAM,CAAC,KAAG,CAW1D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,QAAQ,MAAM,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAWnF,CAAA"}
@@ -1,4 +1,4 @@
1
- const measure = (name, fn) => {
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
- measure
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": ["/** Function overload for createApiReference to allow multiple different signatures */\nexport type Measure = {\n <T>(name: string, fn: () => T): T\n <T>(name: string, fn: () => Promise<T>): Promise<T>\n <T>(name: string, fn: () => T | Promise<T>): T | Promise<T>\n}\n\n/**\n * Measures the execution time of a function and logs it.\n * Works with both async and sync functions.\n * Returns the result of the measured function.\n *\n * @example\n * ```ts\n * // Async function\n * const result = await measure('api-call', async () => {\n * return await fetchData()\n * })\n *\n * // Sync function\n * const result = measure('computation', () => {\n * return heavyComputation()\n * })\n * ```\n */\nexport const measure: Measure = (name, fn) => {\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"],
5
- "mappings": "AAyBO,MAAM,UAAmB,CAAC,MAAM,OAAO;AAC5C,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;",
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
  }
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "helpers",
15
15
  "js"
16
16
  ],
17
- "version": "0.0.7",
17
+ "version": "0.0.8",
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.4"
83
+ "@scalar/build-tooling": "0.2.6"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "scalar-build-esbuild",