foxts 1.5.0 → 1.6.0

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.
@@ -1 +1 @@
1
- "use strict";const e=new Map;function t(e){return Array.from(Array(e).keys())}function r(r){if(e.has(r))return e.get(r);const n=t(r);return e.set(r,n),n}const n=new Map;function a(e){let r,a;return n.has(e)&&(a=(r=n.get(e)).deref()),a||(r=new WeakRef(a=t(e)),n.set(e,r)),a}const o="function"==typeof WeakRef?a:r;exports.createFixedArray=o,exports.createFixedArrayWithGC=a,exports.createFixedArrayWithoutGC=r;
1
+ "use strict";const e=new Map;function t(e){return Array.from(Array(e).keys())}function r(r){if(e.has(r))return e.get(r);const n=t(r);return e.set(r,n),n}const n=new Map;function o(e){let r,o;return n.has(e)&&(o=(r=n.get(e)).deref()),o||(r=new WeakRef(o=t(e)),n.set(e,r)),o}const s="function"==typeof WeakRef?o:r,a=s(0);exports.EMPTY_ARRAY=a,exports.createFixedArray=s,exports.createFixedArrayWithGC=o,exports.createFixedArrayWithoutGC=r;
@@ -1,5 +1,6 @@
1
1
  declare function createFixedArrayWithoutGC(length: number): readonly number[];
2
2
  declare function createFixedArrayWithGC(length: number): readonly number[];
3
3
  declare const createFixedArray: typeof createFixedArrayWithGC;
4
+ declare const EMPTY_ARRAY: readonly number[];
4
5
 
5
- export { createFixedArray, createFixedArrayWithGC, createFixedArrayWithoutGC };
6
+ export { EMPTY_ARRAY, createFixedArray, createFixedArrayWithGC, createFixedArrayWithoutGC };
@@ -1 +1 @@
1
- const e=new Map;function t(e){return Array.from(Array(e).keys())}function r(r){if(e.has(r))return e.get(r);const n=t(r);return e.set(r,n),n}const n=new Map;function a(e){let r,a;return n.has(e)&&(a=(r=n.get(e)).deref()),a||(r=new WeakRef(a=t(e)),n.set(e,r)),a}const o="function"==typeof WeakRef?a:r;export{o as createFixedArray,a as createFixedArrayWithGC,r as createFixedArrayWithoutGC};
1
+ const e=new Map;function t(e){return Array.from(Array(e).keys())}function r(r){if(e.has(r))return e.get(r);const n=t(r);return e.set(r,n),n}const n=new Map;function a(e){let r,a;return n.has(e)&&(a=(r=n.get(e)).deref()),a||(r=new WeakRef(a=t(e)),n.set(e,r)),a}const o="function"==typeof WeakRef?a:r,c=o(0);export{c as EMPTY_ARRAY,o as createFixedArray,a as createFixedArrayWithGC,r as createFixedArrayWithoutGC};
@@ -0,0 +1 @@
1
+ "use strict";const e=/["&'<>]/;exports.escapeHTML=function(t){const c=e.exec(t);if(null===c)return t;let s="",a="",r=c.index,n=0;for(const e=t.length;r<e;r++){switch(t.charCodeAt(r)){case 34:s="&quot;";break;case 38:s="&amp;";break;case 39:s="&#39;";break;case 60:s="&lt;";break;case 62:s="&gt;";break;default:continue}n!==r&&(a+=t.slice(n,r)),n=r+1,a+=s}return n===r?a:a+t.slice(n,r)};
@@ -0,0 +1,3 @@
1
+ declare function escapeHTML(str: string): string;
2
+
3
+ export { escapeHTML };
@@ -0,0 +1 @@
1
+ const e=/["&'<>]/;function c(c){const t=e.exec(c);if(null===t)return c;let a="",n="",r=t.index,s=0;for(const e=c.length;r<e;r++){switch(c.charCodeAt(r)){case 34:a="&quot;";break;case 38:a="&amp;";break;case 39:a="&#39;";break;case 60:a="&lt;";break;case 62:a="&gt;";break;default:continue}s!==r&&(n+=c.slice(s,r)),s=r+1,n+=a}return s===r?n:n+c.slice(s,r)}export{c as escapeHTML};
package/guard/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";function r(r){switch(r){case null:return r=>null!==r;case void 0:return r=>void 0!==r;case!1:return r=>!1!==r;case"nullish":return r=>null!=r;case"falsy":return r=>!!r;default:throw TypeError("Invalid argument")}}function n(r){switch(r){case null:return r=>null===r;case void 0:return r=>void 0===r;case!1:return r=>!1===r;case"nullish":return r=>null==r;case"falsy":return r=>!r;case"truthy":return r=>!!r;default:throw TypeError("Invalid argument")}}const e=n("truthy"),t=n("falsy"),u=r(null),l=r("nullish");exports.invariant=function(r,n='[foxts/invariant] "value" is null or undefined'){if(null==r)throw TypeError(n)},exports.is=n,exports.isFalsy=t,exports.isNonNull=u,exports.isNonNullish=l,exports.isTruthy=e,exports.never=function(r){throw TypeError(`Unexpected value: ${r} as ${JSON.stringify(typeof r)}, should be "never"`)},exports.not=r,exports.nullthrow=function(r,n='[foxts/invariant] "value" is null or undefined'){if(null==r)throw TypeError(n);return r};
1
+ "use strict";function r(r){switch(r){case null:return r=>null!==r;case void 0:return r=>void 0!==r;case!1:return r=>!1!==r;case"nullish":return r=>null!=r;case"falsy":return r=>!!r;default:l(r,"argument")}}function n(r){switch(r){case null:return r=>null===r;case void 0:return r=>void 0===r;case!1:return r=>!1===r;case"nullish":return r=>null==r;case"falsy":return r=>!r;case"truthy":return r=>!!r;default:l(r,"argument")}}const e=n("truthy"),t=n("falsy"),u=r(null),s=r("nullish");function l(r,n="value"){throw TypeError(`Unexpected ${n}: ${r} as ${JSON.stringify(typeof r)}, should be "never"`)}exports.invariant=function(r,n='[foxts/invariant] "value" is null or undefined'){if(null==r)throw TypeError(n)},exports.is=n,exports.isFalsy=t,exports.isNonNull=u,exports.isNonNullish=s,exports.isTruthy=e,exports.never=l,exports.not=r,exports.nullthrow=function(r,n='[foxts/invariant] "value" is null or undefined'){if(null==r)throw TypeError(n);return r};
package/guard/index.d.ts CHANGED
@@ -15,6 +15,6 @@ declare const isNonNull: <T>(i: T | null) => i is T;
15
15
  declare const isNonNullish: <T>(i: T | null | undefined) => i is T;
16
16
  declare function nullthrow<T>(value: T | null | undefined, message?: string): T;
17
17
  declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
18
- declare function never(value: never): never;
18
+ declare function never(value: never, valueMetaName?: string): never;
19
19
 
20
20
  export { invariant, is, isFalsy, isNonNull, isNonNullish, isTruthy, never, not, nullthrow };
package/guard/index.mjs CHANGED
@@ -1 +1 @@
1
- function n(n){switch(n){case null:return n=>null!==n;case void 0:return n=>void 0!==n;case!1:return n=>!1!==n;case"nullish":return n=>null!=n;case"falsy":return n=>!!n;default:throw TypeError("Invalid argument")}}function r(n){switch(n){case null:return n=>null===n;case void 0:return n=>void 0===n;case!1:return n=>!1===n;case"nullish":return n=>null==n;case"falsy":return n=>!n;case"truthy":return n=>!!n;default:throw TypeError("Invalid argument")}}const e=r("truthy"),u=r("falsy"),l=n(null),t=n("nullish");function i(n,r='[foxts/invariant] "value" is null or undefined'){if(null==n)throw TypeError(r);return n}function s(n,r='[foxts/invariant] "value" is null or undefined'){if(null==n)throw TypeError(r)}function a(n){throw TypeError(`Unexpected value: ${n} as ${JSON.stringify(typeof n)}, should be "never"`)}export{s as invariant,r as is,u as isFalsy,l as isNonNull,t as isNonNullish,e as isTruthy,a as never,n as not,i as nullthrow};
1
+ function n(n){switch(n){case null:return n=>null!==n;case void 0:return n=>void 0!==n;case!1:return n=>!1!==n;case"nullish":return n=>null!=n;case"falsy":return n=>!!n;default:a(n,"argument")}}function r(n){switch(n){case null:return n=>null===n;case void 0:return n=>void 0===n;case!1:return n=>!1===n;case"nullish":return n=>null==n;case"falsy":return n=>!n;case"truthy":return n=>!!n;default:a(n,"argument")}}const e=r("truthy"),u=r("falsy"),l=n(null),t=n("nullish");function i(n,r='[foxts/invariant] "value" is null or undefined'){if(null==n)throw TypeError(r);return n}function s(n,r='[foxts/invariant] "value" is null or undefined'){if(null==n)throw TypeError(r)}function a(n,r="value"){throw TypeError(`Unexpected ${r}: ${n} as ${JSON.stringify(typeof n)}, should be "never"`)}export{s as invariant,r as is,u as isFalsy,l as isNonNull,t as isNonNullish,e as isTruthy,a as never,n as not,i as nullthrow};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -59,15 +59,6 @@
59
59
  "require": "./async-write-to-stream/index.cjs",
60
60
  "default": "./async-write-to-stream/index.cjs"
61
61
  },
62
- "./bitwise": {
63
- "types": "./bitwise/index.d.ts",
64
- "import": {
65
- "types": "./bitwise/index.d.ts",
66
- "default": "./bitwise/index.mjs"
67
- },
68
- "require": "./bitwise/index.cjs",
69
- "default": "./bitwise/index.cjs"
70
- },
71
62
  "./create-fixed-array": {
72
63
  "types": "./create-fixed-array/index.d.ts",
73
64
  "import": {
@@ -77,6 +68,15 @@
77
68
  "require": "./create-fixed-array/index.cjs",
78
69
  "default": "./create-fixed-array/index.cjs"
79
70
  },
71
+ "./detect-eol": {
72
+ "types": "./detect-eol/index.d.ts",
73
+ "import": {
74
+ "types": "./detect-eol/index.d.ts",
75
+ "default": "./detect-eol/index.mjs"
76
+ },
77
+ "require": "./detect-eol/index.cjs",
78
+ "default": "./detect-eol/index.cjs"
79
+ },
80
80
  "./append-set-elements-to-array": {
81
81
  "types": "./append-set-elements-to-array/index.d.ts",
82
82
  "import": {
@@ -86,23 +86,23 @@
86
86
  "require": "./append-set-elements-to-array/index.cjs",
87
87
  "default": "./append-set-elements-to-array/index.cjs"
88
88
  },
89
- "./detect-eol": {
90
- "types": "./detect-eol/index.d.ts",
89
+ "./bitwise": {
90
+ "types": "./bitwise/index.d.ts",
91
91
  "import": {
92
- "types": "./detect-eol/index.d.ts",
93
- "default": "./detect-eol/index.mjs"
92
+ "types": "./bitwise/index.d.ts",
93
+ "default": "./bitwise/index.mjs"
94
94
  },
95
- "require": "./detect-eol/index.cjs",
96
- "default": "./detect-eol/index.cjs"
95
+ "require": "./bitwise/index.cjs",
96
+ "default": "./bitwise/index.cjs"
97
97
  },
98
- "./escape-string-regexp": {
99
- "types": "./escape-string-regexp/index.d.ts",
98
+ "./escape-html": {
99
+ "types": "./escape-html/index.d.ts",
100
100
  "import": {
101
- "types": "./escape-string-regexp/index.d.ts",
102
- "default": "./escape-string-regexp/index.mjs"
101
+ "types": "./escape-html/index.d.ts",
102
+ "default": "./escape-html/index.mjs"
103
103
  },
104
- "require": "./escape-string-regexp/index.cjs",
105
- "default": "./escape-string-regexp/index.cjs"
104
+ "require": "./escape-html/index.cjs",
105
+ "default": "./escape-html/index.cjs"
106
106
  },
107
107
  "./fast-string-array-join": {
108
108
  "types": "./fast-string-array-join/index.d.ts",
@@ -131,32 +131,23 @@
131
131
  "require": "./fnv1a/index.cjs",
132
132
  "default": "./fnv1a/index.cjs"
133
133
  },
134
- "./headers-to-object": {
135
- "types": "./headers-to-object/index.d.ts",
136
- "import": {
137
- "types": "./headers-to-object/index.d.ts",
138
- "default": "./headers-to-object/index.mjs"
139
- },
140
- "require": "./headers-to-object/index.cjs",
141
- "default": "./headers-to-object/index.cjs"
142
- },
143
- "./guard": {
144
- "types": "./guard/index.d.ts",
134
+ "./fnv1a52": {
135
+ "types": "./fnv1a52/index.d.ts",
145
136
  "import": {
146
- "types": "./guard/index.d.ts",
147
- "default": "./guard/index.mjs"
137
+ "types": "./fnv1a52/index.d.ts",
138
+ "default": "./fnv1a52/index.mjs"
148
139
  },
149
- "require": "./guard/index.cjs",
150
- "default": "./guard/index.cjs"
140
+ "require": "./fnv1a52/index.cjs",
141
+ "default": "./fnv1a52/index.cjs"
151
142
  },
152
- "./is-probably-ip": {
153
- "types": "./is-probably-ip/index.d.ts",
143
+ "./escape-string-regexp": {
144
+ "types": "./escape-string-regexp/index.d.ts",
154
145
  "import": {
155
- "types": "./is-probably-ip/index.d.ts",
156
- "default": "./is-probably-ip/index.mjs"
146
+ "types": "./escape-string-regexp/index.d.ts",
147
+ "default": "./escape-string-regexp/index.mjs"
157
148
  },
158
- "require": "./is-probably-ip/index.cjs",
159
- "default": "./is-probably-ip/index.cjs"
149
+ "require": "./escape-string-regexp/index.cjs",
150
+ "default": "./escape-string-regexp/index.cjs"
160
151
  },
161
152
  "./identity": {
162
153
  "types": "./identity/index.d.ts",
@@ -167,6 +158,24 @@
167
158
  "require": "./identity/index.cjs",
168
159
  "default": "./identity/index.cjs"
169
160
  },
161
+ "./guard": {
162
+ "types": "./guard/index.d.ts",
163
+ "import": {
164
+ "types": "./guard/index.d.ts",
165
+ "default": "./guard/index.mjs"
166
+ },
167
+ "require": "./guard/index.cjs",
168
+ "default": "./guard/index.cjs"
169
+ },
170
+ "./headers-to-object": {
171
+ "types": "./headers-to-object/index.d.ts",
172
+ "import": {
173
+ "types": "./headers-to-object/index.d.ts",
174
+ "default": "./headers-to-object/index.mjs"
175
+ },
176
+ "require": "./headers-to-object/index.cjs",
177
+ "default": "./headers-to-object/index.cjs"
178
+ },
170
179
  "./noop": {
171
180
  "types": "./noop/index.d.ts",
172
181
  "import": {
@@ -176,6 +185,15 @@
176
185
  "require": "./noop/index.cjs",
177
186
  "default": "./noop/index.cjs"
178
187
  },
188
+ "./is-probably-ip": {
189
+ "types": "./is-probably-ip/index.d.ts",
190
+ "import": {
191
+ "types": "./is-probably-ip/index.d.ts",
192
+ "default": "./is-probably-ip/index.mjs"
193
+ },
194
+ "require": "./is-probably-ip/index.cjs",
195
+ "default": "./is-probably-ip/index.cjs"
196
+ },
179
197
  "./merge-headers": {
180
198
  "types": "./merge-headers/index.d.ts",
181
199
  "import": {
@@ -185,15 +203,6 @@
185
203
  "require": "./merge-headers/index.cjs",
186
204
  "default": "./merge-headers/index.cjs"
187
205
  },
188
- "./once": {
189
- "types": "./once/index.d.ts",
190
- "import": {
191
- "types": "./once/index.d.ts",
192
- "default": "./once/index.mjs"
193
- },
194
- "require": "./once/index.cjs",
195
- "default": "./once/index.cjs"
196
- },
197
206
  "./pick-random": {
198
207
  "types": "./pick-random/index.d.ts",
199
208
  "import": {
@@ -203,14 +212,14 @@
203
212
  "require": "./pick-random/index.cjs",
204
213
  "default": "./pick-random/index.cjs"
205
214
  },
206
- "./fnv1a52": {
207
- "types": "./fnv1a52/index.d.ts",
215
+ "./once": {
216
+ "types": "./once/index.d.ts",
208
217
  "import": {
209
- "types": "./fnv1a52/index.d.ts",
210
- "default": "./fnv1a52/index.mjs"
218
+ "types": "./once/index.d.ts",
219
+ "default": "./once/index.mjs"
211
220
  },
212
- "require": "./fnv1a52/index.cjs",
213
- "default": "./fnv1a52/index.cjs"
221
+ "require": "./once/index.cjs",
222
+ "default": "./once/index.cjs"
214
223
  },
215
224
  "./random-int": {
216
225
  "types": "./random-int/index.d.ts",
@@ -248,15 +257,6 @@
248
257
  "require": "./serialized-memo/index.cjs",
249
258
  "default": "./serialized-memo/index.cjs"
250
259
  },
251
- "./simple-string-hash": {
252
- "types": "./simple-string-hash/index.d.ts",
253
- "import": {
254
- "types": "./simple-string-hash/index.d.ts",
255
- "default": "./simple-string-hash/index.mjs"
256
- },
257
- "require": "./simple-string-hash/index.cjs",
258
- "default": "./simple-string-hash/index.cjs"
259
- },
260
260
  "./tagged": {
261
261
  "types": "./tagged/index.d.ts",
262
262
  "import": {
@@ -266,6 +266,15 @@
266
266
  "require": "./tagged/index.cjs",
267
267
  "default": "./tagged/index.cjs"
268
268
  },
269
+ "./simple-string-hash": {
270
+ "types": "./simple-string-hash/index.d.ts",
271
+ "import": {
272
+ "types": "./simple-string-hash/index.d.ts",
273
+ "default": "./simple-string-hash/index.mjs"
274
+ },
275
+ "require": "./simple-string-hash/index.cjs",
276
+ "default": "./simple-string-hash/index.cjs"
277
+ },
269
278
  "./wait": {
270
279
  "types": "./wait/index.d.ts",
271
280
  "import": {