foxts 1.1.6 → 1.2.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";exports.addArrayElementsToSet=function(r,t){return t.forEach(r.add,r),r};
1
+ "use strict";var e=require("../identity/index.cjs");exports.addArrayElementsToSet=function(t,r,i=e.identity){return r.forEach(e=>t.add(i(e))),t};
@@ -1,3 +1,3 @@
1
- declare function addArrayElementsToSet<T>(set: Set<T>, arr: T[]): Set<T>;
1
+ declare function addArrayElementsToSet<T>(set: Set<T>, arr: T[], transformer?: (item: T) => T): Set<T>;
2
2
 
3
3
  export { addArrayElementsToSet };
@@ -1 +1 @@
1
- function r(r,e){return e.forEach(r.add,r),r}export{r as addArrayElementsToSet};
1
+ import{identity as r}from"../identity/index.mjs";function t(e,d,n=r){return d.forEach(r=>e.add(n(r))),e}export{t as addArrayElementsToSet};
@@ -0,0 +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;
@@ -0,0 +1,5 @@
1
+ declare function createFixedArrayWithoutGC(length: number): readonly number[];
2
+ declare function createFixedArrayWithGC(length: number): readonly number[];
3
+ declare const createFixedArray: typeof createFixedArrayWithGC;
4
+
5
+ export { createFixedArray, createFixedArrayWithGC, createFixedArrayWithoutGC };
@@ -0,0 +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 +1 @@
1
- "use strict";exports.isProbablyIpv4=function(t){if(t.length<7||t.length>15)return!1;let e=0;for(let r=0;r<t.length;r+=1){const n=t.charCodeAt(r);if(46===n)e+=1;else if(n<48||n>57)return!1}return 3===e&&46!==t.charCodeAt(0)&&46!==t.charCodeAt(t.length-1)},exports.isProbablyIpv6=function(t){if(t.length<3)return!1;let e="["===t[0]?1:0,r=t.length;if("]"===t[r-1]&&(r-=1),r-e>39)return!1;let n=!1;for(;e<r;e+=1){const r=t.charCodeAt(e);if(58===r)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=90))return!1}return n};
1
+ "use strict";exports.isProbablyIpv4=function(t){if(t.length<7||t.length>15)return!1;let e=0;for(let r=0;r<t.length;r+=1){const n=t.charCodeAt(r);if(46===n)e+=1;else if(n<48||n>57)return!1}return 3===e&&46!==t.charCodeAt(0)&&46!==t.charCodeAt(t.length-1)},exports.isProbablyIpv6=function(t){if(t.length<3)return!1;let e=+("["===t[0]),r=t.length;if("]"===t[r-1]&&(r-=1),r-e>39)return!1;let n=!1;for(;e<r;e+=1){const r=t.charCodeAt(e);if(58===r)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=90))return!1}return n};
@@ -1 +1 @@
1
- function e(e){if(e.length<7||e.length>15)return!1;let t=0;for(let r=0;r<e.length;r+=1){const n=e.charCodeAt(r);if(46===n)t+=1;else if(n<48||n>57)return!1}return 3===t&&46!==e.charCodeAt(0)&&46!==e.charCodeAt(e.length-1)}function t(e){if(e.length<3)return!1;let t="["===e[0]?1:0,r=e.length;if("]"===e[r-1]&&(r-=1),r-t>39)return!1;let n=!1;for(;t<r;t+=1){const r=e.charCodeAt(t);if(58===r)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=90))return!1}return n}export{e as isProbablyIpv4,t as isProbablyIpv6};
1
+ function e(e){if(e.length<7||e.length>15)return!1;let t=0;for(let r=0;r<e.length;r+=1){const n=e.charCodeAt(r);if(46===n)t+=1;else if(n<48||n>57)return!1}return 3===t&&46!==e.charCodeAt(0)&&46!==e.charCodeAt(e.length-1)}function t(e){if(e.length<3)return!1;let t=+("["===e[0]),r=e.length;if("]"===e[r-1]&&(r-=1),r-t>39)return!1;let n=!1;for(;t<r;t+=1){const r=e.charCodeAt(t);if(58===r)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=90))return!1}return n}export{e as isProbablyIpv4,t as isProbablyIpv6};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -38,24 +38,6 @@
38
38
  "require": "./add-array-elements-to-set/index.cjs",
39
39
  "default": "./add-array-elements-to-set/index.cjs"
40
40
  },
41
- "./ahocorasick": {
42
- "types": "./ahocorasick/index.d.ts",
43
- "import": {
44
- "types": "./ahocorasick/index.d.ts",
45
- "default": "./ahocorasick/index.mjs"
46
- },
47
- "require": "./ahocorasick/index.cjs",
48
- "default": "./ahocorasick/index.cjs"
49
- },
50
- "./async-write-to-stream": {
51
- "types": "./async-write-to-stream/index.d.ts",
52
- "import": {
53
- "types": "./async-write-to-stream/index.d.ts",
54
- "default": "./async-write-to-stream/index.mjs"
55
- },
56
- "require": "./async-write-to-stream/index.cjs",
57
- "default": "./async-write-to-stream/index.cjs"
58
- },
59
41
  "./append-set-elements-to-array": {
60
42
  "types": "./append-set-elements-to-array/index.d.ts",
61
43
  "import": {
@@ -65,15 +47,6 @@
65
47
  "require": "./append-set-elements-to-array/index.cjs",
66
48
  "default": "./append-set-elements-to-array/index.cjs"
67
49
  },
68
- "./fast-string-array-join": {
69
- "types": "./fast-string-array-join/index.d.ts",
70
- "import": {
71
- "types": "./fast-string-array-join/index.d.ts",
72
- "default": "./fast-string-array-join/index.mjs"
73
- },
74
- "require": "./fast-string-array-join/index.cjs",
75
- "default": "./fast-string-array-join/index.cjs"
76
- },
77
50
  "./bitwise": {
78
51
  "types": "./bitwise/index.d.ts",
79
52
  "import": {
@@ -83,6 +56,24 @@
83
56
  "require": "./bitwise/index.cjs",
84
57
  "default": "./bitwise/index.cjs"
85
58
  },
59
+ "./ahocorasick": {
60
+ "types": "./ahocorasick/index.d.ts",
61
+ "import": {
62
+ "types": "./ahocorasick/index.d.ts",
63
+ "default": "./ahocorasick/index.mjs"
64
+ },
65
+ "require": "./ahocorasick/index.cjs",
66
+ "default": "./ahocorasick/index.cjs"
67
+ },
68
+ "./create-fixed-array": {
69
+ "types": "./create-fixed-array/index.d.ts",
70
+ "import": {
71
+ "types": "./create-fixed-array/index.d.ts",
72
+ "default": "./create-fixed-array/index.mjs"
73
+ },
74
+ "require": "./create-fixed-array/index.cjs",
75
+ "default": "./create-fixed-array/index.cjs"
76
+ },
86
77
  "./escape-string-regexp": {
87
78
  "types": "./escape-string-regexp/index.d.ts",
88
79
  "import": {
@@ -92,6 +83,24 @@
92
83
  "require": "./escape-string-regexp/index.cjs",
93
84
  "default": "./escape-string-regexp/index.cjs"
94
85
  },
86
+ "./async-write-to-stream": {
87
+ "types": "./async-write-to-stream/index.d.ts",
88
+ "import": {
89
+ "types": "./async-write-to-stream/index.d.ts",
90
+ "default": "./async-write-to-stream/index.mjs"
91
+ },
92
+ "require": "./async-write-to-stream/index.cjs",
93
+ "default": "./async-write-to-stream/index.cjs"
94
+ },
95
+ "./fast-string-array-join": {
96
+ "types": "./fast-string-array-join/index.d.ts",
97
+ "import": {
98
+ "types": "./fast-string-array-join/index.d.ts",
99
+ "default": "./fast-string-array-join/index.mjs"
100
+ },
101
+ "require": "./fast-string-array-join/index.cjs",
102
+ "default": "./fast-string-array-join/index.cjs"
103
+ },
95
104
  "./fifo": {
96
105
  "types": "./fifo/index.d.ts",
97
106
  "import": {
@@ -110,14 +119,14 @@
110
119
  "require": "./fnv1a/index.cjs",
111
120
  "default": "./fnv1a/index.cjs"
112
121
  },
113
- "./fnv1a52": {
114
- "types": "./fnv1a52/index.d.ts",
122
+ "./headers-to-object": {
123
+ "types": "./headers-to-object/index.d.ts",
115
124
  "import": {
116
- "types": "./fnv1a52/index.d.ts",
117
- "default": "./fnv1a52/index.mjs"
125
+ "types": "./headers-to-object/index.d.ts",
126
+ "default": "./headers-to-object/index.mjs"
118
127
  },
119
- "require": "./fnv1a52/index.cjs",
120
- "default": "./fnv1a52/index.cjs"
128
+ "require": "./headers-to-object/index.cjs",
129
+ "default": "./headers-to-object/index.cjs"
121
130
  },
122
131
  "./guard": {
123
132
  "types": "./guard/index.d.ts",
@@ -128,15 +137,6 @@
128
137
  "require": "./guard/index.cjs",
129
138
  "default": "./guard/index.cjs"
130
139
  },
131
- "./headers-to-object": {
132
- "types": "./headers-to-object/index.d.ts",
133
- "import": {
134
- "types": "./headers-to-object/index.d.ts",
135
- "default": "./headers-to-object/index.mjs"
136
- },
137
- "require": "./headers-to-object/index.cjs",
138
- "default": "./headers-to-object/index.cjs"
139
- },
140
140
  "./identity": {
141
141
  "types": "./identity/index.d.ts",
142
142
  "import": {
@@ -164,6 +164,15 @@
164
164
  "require": "./merge-headers/index.cjs",
165
165
  "default": "./merge-headers/index.cjs"
166
166
  },
167
+ "./noop": {
168
+ "types": "./noop/index.d.ts",
169
+ "import": {
170
+ "types": "./noop/index.d.ts",
171
+ "default": "./noop/index.mjs"
172
+ },
173
+ "require": "./noop/index.cjs",
174
+ "default": "./noop/index.cjs"
175
+ },
167
176
  "./once": {
168
177
  "types": "./once/index.d.ts",
169
178
  "import": {
@@ -173,6 +182,15 @@
173
182
  "require": "./once/index.cjs",
174
183
  "default": "./once/index.cjs"
175
184
  },
185
+ "./fnv1a52": {
186
+ "types": "./fnv1a52/index.d.ts",
187
+ "import": {
188
+ "types": "./fnv1a52/index.d.ts",
189
+ "default": "./fnv1a52/index.mjs"
190
+ },
191
+ "require": "./fnv1a52/index.cjs",
192
+ "default": "./fnv1a52/index.cjs"
193
+ },
176
194
  "./repool": {
177
195
  "types": "./repool/index.d.ts",
178
196
  "import": {
@@ -182,14 +200,14 @@
182
200
  "require": "./repool/index.cjs",
183
201
  "default": "./repool/index.cjs"
184
202
  },
185
- "./noop": {
186
- "types": "./noop/index.d.ts",
203
+ "./retrie": {
204
+ "types": "./retrie/index.d.ts",
187
205
  "import": {
188
- "types": "./noop/index.d.ts",
189
- "default": "./noop/index.mjs"
206
+ "types": "./retrie/index.d.ts",
207
+ "default": "./retrie/index.mjs"
190
208
  },
191
- "require": "./noop/index.cjs",
192
- "default": "./noop/index.cjs"
209
+ "require": "./retrie/index.cjs",
210
+ "default": "./retrie/index.cjs"
193
211
  },
194
212
  "./serialized-memo": {
195
213
  "types": "./serialized-memo/index.d.ts",
@@ -200,14 +218,14 @@
200
218
  "require": "./serialized-memo/index.cjs",
201
219
  "default": "./serialized-memo/index.cjs"
202
220
  },
203
- "./retrie": {
204
- "types": "./retrie/index.d.ts",
221
+ "./tagged": {
222
+ "types": "./tagged/index.d.ts",
205
223
  "import": {
206
- "types": "./retrie/index.d.ts",
207
- "default": "./retrie/index.mjs"
224
+ "types": "./tagged/index.d.ts",
225
+ "default": "./tagged/index.mjs"
208
226
  },
209
- "require": "./retrie/index.cjs",
210
- "default": "./retrie/index.cjs"
227
+ "require": "./tagged/index.cjs",
228
+ "default": "./tagged/index.cjs"
211
229
  },
212
230
  "./simple-string-hash": {
213
231
  "types": "./simple-string-hash/index.d.ts",
@@ -218,15 +236,6 @@
218
236
  "require": "./simple-string-hash/index.cjs",
219
237
  "default": "./simple-string-hash/index.cjs"
220
238
  },
221
- "./tagged": {
222
- "types": "./tagged/index.d.ts",
223
- "import": {
224
- "types": "./tagged/index.d.ts",
225
- "default": "./tagged/index.mjs"
226
- },
227
- "require": "./tagged/index.cjs",
228
- "default": "./tagged/index.cjs"
229
- },
230
239
  "./wait": {
231
240
  "types": "./wait/index.d.ts",
232
241
  "import": {