foxts 1.0.6 → 1.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.
@@ -0,0 +1 @@
1
+ "use strict";exports.addArrayElementsToSet=function(r,t){return t.forEach(r.add,r),r};
@@ -0,0 +1,3 @@
1
+ declare function addArrayElementsToSet<T>(set: Set<T>, arr: T[]): Set<T>;
2
+
3
+ export { addArrayElementsToSet };
@@ -0,0 +1 @@
1
+ function r(r,e){return e.forEach(r.add,r),r}export{r as addArrayElementsToSet};
@@ -0,0 +1 @@
1
+ "use strict";class t extends Map{wordEnd;fail;constructor(t,e){super(),this.wordEnd=t,this.fail=e}}exports.createAhoCorasick=function(e){const o=new t(!1,void 0);e.forEach(e=>{let r=o;for(let o=0,s=e.length;o<s;o++){const s=e[o];if(r.has(s))r=r.get(s);else{const e=new t(!1,void 0);r.set(s,e),r=e}}r!==o&&(r.wordEnd=!0)});const r=[o];for(;r.length;){const t=r.pop();t.forEach((e,s)=>{let n=t.fail;for(;n&&!n.has(s);)n=n.fail;e.fail=n?n.get(s):o,r.push(e)})}return t=>{let e=o;for(let r=0,s=t.length;r<s;r++){const s=t[r];for(;e&&!e.has(s);)e=e.fail;if((e=e?e.get(s):o).wordEnd)return!0}return!1}};
@@ -0,0 +1,3 @@
1
+ declare function createAhoCorasick(keys: string[] | Set<string> | readonly string[]): (text: string) => boolean;
2
+
3
+ export { createAhoCorasick };
@@ -0,0 +1 @@
1
+ class t extends Map{wordEnd;fail;constructor(t,o){super(),this.wordEnd=t,this.fail=o}}function o(o){const e=new t(!1,void 0);o.forEach(o=>{let r=e;for(let e=0,n=o.length;e<n;e++){const n=o[e];if(r.has(n))r=r.get(n);else{const o=new t(!1,void 0);r.set(n,o),r=o}}r!==e&&(r.wordEnd=!0)});const r=[e];for(;r.length;){const t=r.pop();t.forEach((o,n)=>{let s=t.fail;for(;s&&!s.has(n);)s=s.fail;o.fail=s?s.get(n):e,r.push(o)})}return t=>{let o=e;for(let r=0,n=t.length;r<n;r++){const n=t[r];for(;o&&!o.has(n);)o=o.fail;if((o=o?o.get(n):e).wordEnd)return!0}return!1}}export{o as createAhoCorasick};
package/fifo/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e;e=Symbol.iterator;class t{head=null;tail=null;$size=0;constructor(){this.clear()}enqueue(e){const t=[e,null];this.head?this.tail[1]=t:this.head=t,this.tail=t,this.$size++}push=this.enqueue;dequeue(){const e=this.head;if(e)return this.head=this.head[1],this.$size--,e[0]}shift=this.dequeue;peek(){return this.head?.[0]}clear(){this.head=null,this.tail=null,this.$size=0}get size(){return this.$size}*[e](){let e=this.head;for(;e;)yield e[0],e=e[1]}}exports.FIFO=t;
@@ -0,0 +1,16 @@
1
+ declare class FIFO<T> {
2
+ private head;
3
+ private tail;
4
+ $size: number;
5
+ constructor();
6
+ enqueue(value: T): void;
7
+ push: (value: T) => void;
8
+ dequeue(): T | undefined;
9
+ shift: () => T | undefined;
10
+ peek(): T | undefined;
11
+ clear(): void;
12
+ get size(): number;
13
+ [Symbol.iterator](): Generator<T, void, unknown>;
14
+ }
15
+
16
+ export { FIFO };
package/fifo/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var e;e=Symbol.iterator;class t{head=null;tail=null;$size=0;constructor(){this.clear()}enqueue(e){const t=[e,null];this.head?this.tail[1]=t:this.head=t,this.tail=t,this.$size++}push=this.enqueue;dequeue(){const e=this.head;if(e)return this.head=this.head[1],this.$size--,e[0]}shift=this.dequeue;peek(){return this.head?.[0]}clear(){this.head=null,this.tail=null,this.$size=0}get size(){return this.$size}*[e](){let e=this.head;for(;e;)yield e[0],e=e[1]}}export{t as FIFO};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -29,14 +29,23 @@
29
29
  "exports": {
30
30
  "./package.json": "./package.json",
31
31
  "./sizes.json": "./sizes.json",
32
- "./append-set-elements-to-array": {
33
- "types": "./append-set-elements-to-array/index.d.ts",
32
+ "./add-array-elements-to-set": {
33
+ "types": "./add-array-elements-to-set/index.d.ts",
34
34
  "import": {
35
- "types": "./append-set-elements-to-array/index.d.ts",
36
- "default": "./append-set-elements-to-array/index.mjs"
35
+ "types": "./add-array-elements-to-set/index.d.ts",
36
+ "default": "./add-array-elements-to-set/index.mjs"
37
37
  },
38
- "require": "./append-set-elements-to-array/index.cjs",
39
- "default": "./append-set-elements-to-array/index.cjs"
38
+ "require": "./add-array-elements-to-set/index.cjs",
39
+ "default": "./add-array-elements-to-set/index.cjs"
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"
40
49
  },
41
50
  "./async-write-to-stream": {
42
51
  "types": "./async-write-to-stream/index.d.ts",
@@ -47,6 +56,24 @@
47
56
  "require": "./async-write-to-stream/index.cjs",
48
57
  "default": "./async-write-to-stream/index.cjs"
49
58
  },
59
+ "./bitwise": {
60
+ "types": "./bitwise/index.d.ts",
61
+ "import": {
62
+ "types": "./bitwise/index.d.ts",
63
+ "default": "./bitwise/index.mjs"
64
+ },
65
+ "require": "./bitwise/index.cjs",
66
+ "default": "./bitwise/index.cjs"
67
+ },
68
+ "./append-set-elements-to-array": {
69
+ "types": "./append-set-elements-to-array/index.d.ts",
70
+ "import": {
71
+ "types": "./append-set-elements-to-array/index.d.ts",
72
+ "default": "./append-set-elements-to-array/index.mjs"
73
+ },
74
+ "require": "./append-set-elements-to-array/index.cjs",
75
+ "default": "./append-set-elements-to-array/index.cjs"
76
+ },
50
77
  "./fast-string-array-join": {
51
78
  "types": "./fast-string-array-join/index.d.ts",
52
79
  "import": {
@@ -56,6 +83,15 @@
56
83
  "require": "./fast-string-array-join/index.cjs",
57
84
  "default": "./fast-string-array-join/index.cjs"
58
85
  },
86
+ "./fifo": {
87
+ "types": "./fifo/index.d.ts",
88
+ "import": {
89
+ "types": "./fifo/index.d.ts",
90
+ "default": "./fifo/index.mjs"
91
+ },
92
+ "require": "./fifo/index.cjs",
93
+ "default": "./fifo/index.cjs"
94
+ },
59
95
  "./fnv1a": {
60
96
  "types": "./fnv1a/index.d.ts",
61
97
  "import": {
@@ -65,14 +101,14 @@
65
101
  "require": "./fnv1a/index.cjs",
66
102
  "default": "./fnv1a/index.cjs"
67
103
  },
68
- "./bitwise": {
69
- "types": "./bitwise/index.d.ts",
104
+ "./guard": {
105
+ "types": "./guard/index.d.ts",
70
106
  "import": {
71
- "types": "./bitwise/index.d.ts",
72
- "default": "./bitwise/index.mjs"
107
+ "types": "./guard/index.d.ts",
108
+ "default": "./guard/index.mjs"
73
109
  },
74
- "require": "./bitwise/index.cjs",
75
- "default": "./bitwise/index.cjs"
110
+ "require": "./guard/index.cjs",
111
+ "default": "./guard/index.cjs"
76
112
  },
77
113
  "./fnv1a52": {
78
114
  "types": "./fnv1a52/index.d.ts",
@@ -83,15 +119,6 @@
83
119
  "require": "./fnv1a52/index.cjs",
84
120
  "default": "./fnv1a52/index.cjs"
85
121
  },
86
- "./guard": {
87
- "types": "./guard/index.d.ts",
88
- "import": {
89
- "types": "./guard/index.d.ts",
90
- "default": "./guard/index.mjs"
91
- },
92
- "require": "./guard/index.cjs",
93
- "default": "./guard/index.cjs"
94
- },
95
122
  "./headers-to-object": {
96
123
  "types": "./headers-to-object/index.d.ts",
97
124
  "import": {
@@ -119,15 +146,6 @@
119
146
  "require": "./is-probably-ip/index.cjs",
120
147
  "default": "./is-probably-ip/index.cjs"
121
148
  },
122
- "./merge-headers": {
123
- "types": "./merge-headers/index.d.ts",
124
- "import": {
125
- "types": "./merge-headers/index.d.ts",
126
- "default": "./merge-headers/index.mjs"
127
- },
128
- "require": "./merge-headers/index.cjs",
129
- "default": "./merge-headers/index.cjs"
130
- },
131
149
  "./noop": {
132
150
  "types": "./noop/index.d.ts",
133
151
  "import": {
@@ -137,6 +155,15 @@
137
155
  "require": "./noop/index.cjs",
138
156
  "default": "./noop/index.cjs"
139
157
  },
158
+ "./merge-headers": {
159
+ "types": "./merge-headers/index.d.ts",
160
+ "import": {
161
+ "types": "./merge-headers/index.d.ts",
162
+ "default": "./merge-headers/index.mjs"
163
+ },
164
+ "require": "./merge-headers/index.cjs",
165
+ "default": "./merge-headers/index.cjs"
166
+ },
140
167
  "./simple-string-hash": {
141
168
  "types": "./simple-string-hash/index.d.ts",
142
169
  "import": {