foxts 5.4.2 → 5.5.1

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.
@@ -0,0 +1,18 @@
1
+ declare class Counter<K extends string> {
2
+ private readonly map;
3
+ constructor(init?: Array<[K, number]> | Record<K, number>);
4
+ forEach(callbackfn: (value: number, key: K, map: Map<K, number>) => void, thisArg?: any): void;
5
+ [Symbol.toStringTag]: string;
6
+ get size(): number;
7
+ clear(): void;
8
+ delete(key: K): boolean;
9
+ has(key: K): boolean;
10
+ get(key: K): number;
11
+ incr(key: K, n?: number): this;
12
+ decr(key: K, n?: number): this;
13
+ entries(): MapIterator<[K, number]>;
14
+ [Symbol.iterator](): MapIterator<[K, number]>;
15
+ keys(): MapIterator<K>;
16
+ }
17
+
18
+ export { Counter };
@@ -0,0 +1 @@
1
+ "use strict";var t,r;t=Symbol.toStringTag,r=Symbol.iterator;class e{map=new Map;constructor(t){if(Array.isArray(t))for(const[r,e]of t)this.incr(r,e);else if(void 0!==t)for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.incr(r,t[r])}forEach(t,r){this.map.forEach(t,r)}[t]="Counter";get size(){return this.map.size}clear(){this.map.clear()}delete(t){return this.map.delete(t)}has(t){return this.map.has(t)}get(t){const r=this.map.get(t);return void 0===r?0:r}incr(t,r=1){if(r<0)throw TypeError(`Counter#incr only accepts positive values: ${r}`);return this.map.set(t,this.get(t)+r),this}decr(t,r=1){if(r<0)throw TypeError(`Counter#decr only accepts positive values: ${r}`);const e=this.get(t);return e<=r?this.map.delete(t):this.map.set(t,e-r),this}entries(){return this.map.entries()}[r](){return this.map[Symbol.iterator]()}keys(){return this.map.keys()}}exports.Counter=e;
@@ -0,0 +1 @@
1
+ var t,r;t=Symbol.toStringTag,r=Symbol.iterator;class e{map=new Map;constructor(t){if(Array.isArray(t))for(const[r,e]of t)this.incr(r,e);else if(void 0!==t)for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.incr(r,t[r])}forEach(t,r){this.map.forEach(t,r)}[t]="Counter";get size(){return this.map.size}clear(){this.map.clear()}delete(t){return this.map.delete(t)}has(t){return this.map.has(t)}get(t){const r=this.map.get(t);return void 0===r?0:r}incr(t,r=1){if(r<0)throw TypeError(`Counter#incr only accepts positive values: ${r}`);return this.map.set(t,this.get(t)+r),this}decr(t,r=1){if(r<0)throw TypeError(`Counter#decr only accepts positive values: ${r}`);const e=this.get(t);return e<=r?this.map.delete(t):this.map.set(t,e-r),this}entries(){return this.map.entries()}[r](){return this.map[Symbol.iterator]()}keys(){return this.map.keys()}}export{e as Counter};
@@ -1 +1 @@
1
- "use strict";const e=Object.prototype.toString,t=new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]),r=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT"]);exports.isNetworkError=function(o){if("object"!=typeof o||null==o)return!1;if("code"in o&&"string"==typeof o.code){if("ERR_UNESCAPED_CHARACTERS"===o.code)return!1;if(r.has(o.code))return!0}if(!(o&&"[object Error]"===e.call(o)&&"TypeError"===o.name&&"string"==typeof o.message))return!1;const{message:n,stack:E}=o;return"Load failed"===n?void 0===E||"__sentry_captured__"in o:!!(n.startsWith("error sending request for url")||"Failed to fetch"===n||n.startsWith("Failed to fetch (")&&n.endsWith(")"))||t.has(n)};
1
+ "use strict";const e=Object.prototype.toString,t=new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]),r=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT"]);exports.isNetworkError=function(o){if("object"!=typeof o||null==o)return!1;if("code"in o&&"string"==typeof o.code){if("ERR_UNESCAPED_CHARACTERS"===o.code)return!1;if(r.has(o.code))return!0}if(!(o&&"[object Error]"===e.call(o)&&"TypeError"===o.name&&"string"==typeof o.message))return!1;const{message:n,stack:E}=o;return"Load failed"===n||n.startsWith("Load failed (")&&n.endsWith(")")?void 0===E||"__sentry_captured__"in o:!!(n.startsWith("error sending request for url")||"Failed to fetch"===n||n.startsWith("Failed to fetch (")&&n.endsWith(")"))||t.has(n)};
@@ -1 +1 @@
1
- const e=Object.prototype.toString,t=new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]),r=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT"]);function o(o){if("object"!=typeof o||null==o)return!1;if("code"in o&&"string"==typeof o.code){if("ERR_UNESCAPED_CHARACTERS"===o.code)return!1;if(r.has(o.code))return!0}if(!(o&&"[object Error]"===e.call(o)&&"TypeError"===o.name&&"string"==typeof o.message))return!1;const{message:n,stack:E}=o;return"Load failed"===n?void 0===E||"__sentry_captured__"in o:!!(n.startsWith("error sending request for url")||"Failed to fetch"===n||n.startsWith("Failed to fetch (")&&n.endsWith(")"))||t.has(n)}export{o as isNetworkError};
1
+ const e=Object.prototype.toString,t=new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]),r=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT"]);function o(o){if("object"!=typeof o||null==o)return!1;if("code"in o&&"string"==typeof o.code){if("ERR_UNESCAPED_CHARACTERS"===o.code)return!1;if(r.has(o.code))return!0}if(!(o&&"[object Error]"===e.call(o)&&"TypeError"===o.name&&"string"==typeof o.message))return!1;const{message:n,stack:E}=o;return"Load failed"===n||n.startsWith("Load failed (")&&n.endsWith(")")?void 0===E||"__sentry_captured__"in o:!!(n.startsWith("error sending request for url")||"Failed to fetch"===n||n.startsWith("Failed to fetch (")&&n.endsWith(")"))||t.has(n)}export{o as isNetworkError};
@@ -1 +1 @@
1
- "use strict";class e extends Promise{executor;promise;constructor(e){super(e=>e()),this.executor=e}static from(t){return new e(e=>{e(t())})}static resolve(t){return new e(e=>e(t))}static reject(t){return new e((e,r)=>r(t))}then(e,t){return this.promise??=new Promise(this.executor),this.promise.then(e,t)}catch(e){return this.promise??=new Promise(this.executor),this.promise.catch(e)}finally(e){return this.promise??=new Promise(this.executor),this.promise.finally(e)}}exports.LazyPromise=e;
1
+ "use strict";exports.LazyPromise=class e extends Promise{executor;promise;constructor(e){super(e=>e()),this.executor=e}static from(t){return new e(e=>{e(t())})}static resolve(t){return new e(e=>e(t))}static reject(t){return new e((e,r)=>r(t))}then(e,t){return this.promise??=new Promise(this.executor),this.promise.then(e,t)}catch(e){return this.promise??=new Promise(this.executor),this.promise.catch(e)}finally(e){return this.promise??=new Promise(this.executor),this.promise.finally(e)}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "5.4.2",
3
+ "version": "5.5.1",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -100,6 +100,12 @@
100
100
  "require": "./dist/compare-source/index.js",
101
101
  "default": "./dist/compare-source/index.js"
102
102
  },
103
+ "./counter": {
104
+ "types": "./dist/counter/index.d.ts",
105
+ "import": "./dist/counter/index.mjs",
106
+ "require": "./dist/counter/index.js",
107
+ "default": "./dist/counter/index.js"
108
+ },
103
109
  "./create-fixed-array": {
104
110
  "types": "./dist/create-fixed-array/index.d.ts",
105
111
  "import": "./dist/create-fixed-array/index.mjs",
@@ -332,35 +338,36 @@
332
338
  "author": "SukkaW <https://skk.moe>",
333
339
  "license": "MIT",
334
340
  "devDependencies": {
335
- "@eslint-sukka/node": "^8.10.1",
336
- "@happy-dom/global-registrator": "^20.9.0",
341
+ "@eslint-sukka/node": "^8.10.4",
342
+ "@happy-dom/global-registrator": "^20.10.2",
337
343
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
338
344
  "@mitata/counters": "^0.0.8",
339
- "@monyone/aho-corasick": "^1.1.10",
345
+ "@monyone/aho-corasick": "^1.1.11",
340
346
  "@package-json/types": "^0.0.13",
341
347
  "@swc-node/register": "^1.11.1",
342
- "@swc/core": "^1.15.32",
348
+ "@swc/core": "^1.15.40",
343
349
  "@types/mocha": "^10.0.10",
344
- "@types/node": "^22.19.17",
350
+ "@types/node": "^22.19.20",
345
351
  "@types/sinon": "^21.0.1",
346
352
  "bumpp": "^10.4.1",
347
353
  "earl": "^2.0.0",
348
- "eslint": "^10.3.0",
349
- "eslint-config-sukka": "^8.10.1",
350
- "eslint-formatter-sukka": "^8.10.1",
354
+ "eslint": "^10.4.1",
355
+ "eslint-config-sukka": "^8.10.4",
356
+ "eslint-formatter-sukka": "^8.10.4",
351
357
  "fastscan": "^1.0.6",
352
- "happy-dom": "^20.9.0",
358
+ "happy-dom": "^20.10.2",
353
359
  "is-ci": "^4.1.0",
354
- "is-network-error": "^1.3.1",
360
+ "is-network-error": "^1.3.2",
355
361
  "mitata": "^1.0.34",
356
- "mocha": "^11.7.5",
362
+ "mocha": "^11.7.6",
357
363
  "modern-ahocorasick": "^2.0.4",
358
364
  "nyc": "^18.0.0",
359
- "rollup": "^4.60.2",
365
+ "rollup": "^4.61.1",
360
366
  "rollup-plugin-dts": "^6.4.1",
361
367
  "rollup-plugin-oxc-resolve": "^0.0.5",
362
368
  "rollup-plugin-swc3": "^0.12.1",
363
369
  "sinon": "^21.1.2",
370
+ "ts-dedent": "^2.2.0",
364
371
  "typescript": "^6.0.3",
365
372
  "word-list": "3.0.0"
366
373
  },