foxts 1.0.12 → 1.1.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.mergeHeaders=function(e,r){const s=new Headers(e);return new Headers(r).forEach((e,r)=>{s.set(r,e)}),s};
1
+ "use strict";exports.mergeHeaders=function(e,r){const t=new Headers(e);return new Headers(r).forEach((e,r)=>{t.set(r,e)}),t},exports.mergeNodeHttpHeaders=function(e,r){return Object.assign({},e,r)};
@@ -1,4 +1,8 @@
1
1
  type HeadersInitLike = string[][] | Record<string, string | readonly string[]> | Headers;
2
+ type IncomingHttpHeadersLike = Record<string, string | string[] | undefined>;
3
+ type OutgoingHttpHeadersLike = Record<string, number | string | string[] | undefined>;
2
4
  declare function mergeHeaders(dest: HeadersInitLike, source: HeadersInitLike): Headers;
5
+ declare function mergeNodeHttpHeaders(dest: IncomingHttpHeadersLike, source: IncomingHttpHeadersLike): IncomingHttpHeadersLike;
6
+ declare function mergeNodeHttpHeaders(dest: OutgoingHttpHeadersLike, source: IncomingHttpHeadersLike | OutgoingHttpHeadersLike): OutgoingHttpHeadersLike;
3
7
 
4
- export { type HeadersInitLike, mergeHeaders };
8
+ export { type HeadersInitLike, type IncomingHttpHeadersLike, type OutgoingHttpHeadersLike, mergeHeaders, mergeNodeHttpHeaders };
@@ -1 +1 @@
1
- function e(e,r){const n=new Headers(e);return new Headers(r).forEach((e,r)=>{n.set(r,e)}),n}export{e as mergeHeaders};
1
+ function e(e,r){const n=new Headers(e);return new Headers(r).forEach((e,r)=>{n.set(r,e)}),n}function r(e,r){return Object.assign({},e,r)}export{e as mergeHeaders,r as mergeNodeHttpHeaders};
package/noop/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";exports.falseFn=()=>!1,exports.noop=()=>{},exports.throwFn=()=>{throw Error()},exports.trueFn=()=>!0;
1
+ "use strict";const o=()=>{},r=Promise.resolve(),e=new Promise(o);exports.asyncNeverFn=()=>e,exports.asyncNoop=()=>r,exports.falseFn=()=>!1,exports.noop=o,exports.throwFn=()=>{throw Error()},exports.trueFn=()=>!0;
package/noop/index.d.ts CHANGED
@@ -5,5 +5,7 @@ declare const noop: Noop;
5
5
  declare const trueFn: Noop<true>;
6
6
  declare const falseFn: Noop<false>;
7
7
  declare const throwFn: Noop<never>;
8
+ declare const asyncNoop: Noop<Promise<any>>;
9
+ declare const asyncNeverFn: Noop<Promise<never>>;
8
10
 
9
- export { type Noop, falseFn, noop, throwFn, trueFn };
11
+ export { type Noop, asyncNeverFn, asyncNoop, falseFn, noop, throwFn, trueFn };
package/noop/index.mjs CHANGED
@@ -1 +1 @@
1
- const o=()=>{},r=()=>!0,n=()=>!1,t=()=>{throw Error()};export{n as falseFn,o as noop,t as throwFn,r as trueFn};
1
+ const o=()=>{},r=()=>!0,e=()=>!1,n=()=>{throw Error()},s=Promise.resolve(),t=()=>s,F=new Promise(o),a=()=>F;export{a as asyncNeverFn,t as asyncNoop,e as falseFn,o as noop,n as throwFn,r as trueFn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "1.0.12",
3
+ "version": "1.1.0",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -146,15 +146,6 @@
146
146
  "require": "./identity/index.cjs",
147
147
  "default": "./identity/index.cjs"
148
148
  },
149
- "./is-probably-ip": {
150
- "types": "./is-probably-ip/index.d.ts",
151
- "import": {
152
- "types": "./is-probably-ip/index.d.ts",
153
- "default": "./is-probably-ip/index.mjs"
154
- },
155
- "require": "./is-probably-ip/index.cjs",
156
- "default": "./is-probably-ip/index.cjs"
157
- },
158
149
  "./merge-headers": {
159
150
  "types": "./merge-headers/index.d.ts",
160
151
  "import": {
@@ -164,6 +155,15 @@
164
155
  "require": "./merge-headers/index.cjs",
165
156
  "default": "./merge-headers/index.cjs"
166
157
  },
158
+ "./is-probably-ip": {
159
+ "types": "./is-probably-ip/index.d.ts",
160
+ "import": {
161
+ "types": "./is-probably-ip/index.d.ts",
162
+ "default": "./is-probably-ip/index.mjs"
163
+ },
164
+ "require": "./is-probably-ip/index.cjs",
165
+ "default": "./is-probably-ip/index.cjs"
166
+ },
167
167
  "./noop": {
168
168
  "types": "./noop/index.d.ts",
169
169
  "import": {
@@ -173,6 +173,24 @@
173
173
  "require": "./noop/index.cjs",
174
174
  "default": "./noop/index.cjs"
175
175
  },
176
+ "./repool": {
177
+ "types": "./repool/index.d.ts",
178
+ "import": {
179
+ "types": "./repool/index.d.ts",
180
+ "default": "./repool/index.mjs"
181
+ },
182
+ "require": "./repool/index.cjs",
183
+ "default": "./repool/index.cjs"
184
+ },
185
+ "./retrie": {
186
+ "types": "./retrie/index.d.ts",
187
+ "import": {
188
+ "types": "./retrie/index.d.ts",
189
+ "default": "./retrie/index.mjs"
190
+ },
191
+ "require": "./retrie/index.cjs",
192
+ "default": "./retrie/index.cjs"
193
+ },
176
194
  "./serialized-memo": {
177
195
  "types": "./serialized-memo/index.d.ts",
178
196
  "import": {
@@ -191,15 +209,6 @@
191
209
  "require": "./simple-string-hash/index.cjs",
192
210
  "default": "./simple-string-hash/index.cjs"
193
211
  },
194
- "./tagged": {
195
- "types": "./tagged/index.d.ts",
196
- "import": {
197
- "types": "./tagged/index.d.ts",
198
- "default": "./tagged/index.mjs"
199
- },
200
- "require": "./tagged/index.cjs",
201
- "default": "./tagged/index.cjs"
202
- },
203
212
  "./wait": {
204
213
  "types": "./wait/index.d.ts",
205
214
  "import": {
@@ -208,6 +217,15 @@
208
217
  },
209
218
  "require": "./wait/index.cjs",
210
219
  "default": "./wait/index.cjs"
220
+ },
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"
211
229
  }
212
230
  }
213
231
  }
@@ -0,0 +1 @@
1
+ "use strict";exports.Repool=class{createObject;head;tail;constructor(t){this.createObject=t;const e=t();this.tail=e,this.head=e}get(){const t=this.head;if(t.next)this.head=t.next;else{const t=this.createObject();this.tail=t,this.head=t}return t.next=null,t}release(t){this.tail.next=t,this.tail=t}};
@@ -0,0 +1,18 @@
1
+ interface Reusifiable {
2
+ next: this | null;
3
+ }
4
+ /**
5
+ * Repool is a class that allows you to reuse objects.
6
+ *
7
+ * Do not use this to store class instances, please use https://github.com/mcollina/reusify instead.
8
+ */
9
+ declare class Repool<T extends Reusifiable> {
10
+ private createObject;
11
+ private head;
12
+ private tail;
13
+ constructor(createObject: () => T);
14
+ get(): T;
15
+ release(obj: T): void;
16
+ }
17
+
18
+ export { Repool, type Reusifiable };
@@ -0,0 +1 @@
1
+ class t{createObject;head;tail;constructor(t){this.createObject=t;const e=t();this.tail=e,this.head=e}get(){const t=this.head;if(t.next)this.head=t.next;else{const t=this.createObject();this.tail=t,this.head=t}return t.next=null,t}release(t){this.tail.next=t,this.tail=t}}export{t as Repool};
@@ -0,0 +1 @@
1
+ "use strict";const t=new Set([".","?","*","+","^","$","|","(",")","{","[","\\"]);exports.retrie=function(n,e=!1){const o={},r=(t,n)=>{let e;let r=o;for(let o=0,l=t.length;o<l;++o)(e=t.charAt(o))in r||(r[e]=n?{"":""}:{}),r=r[e];n&&(r[""]="")};for(let t=0,o=n.length;t<o;++t)r(n[t],e);const l=()=>(function n(e){let o,r,l=!1,s=!1;const c=[],i=[];for(const o in e){if(!o){l=!0;continue}((r=n(e[o]))?c:i).push((t.has(o)?"\\"+o:o)+r)}return l&&null==r?"":(s=!c.length,i.length&&c.push(i[1]?"["+i.join("")+"]":i[0]),o=c[1]?"(?:"+c.join("|")+")":c[0],l&&(o=s?o+"?":"(?:"+o+")?"),o||"")})(o);return{add:r,toString:l,toRe:()=>new RegExp((e?"^":"")+l())}};
@@ -0,0 +1,7 @@
1
+ declare function retrie(keywords: ArrayLike<string>, asPrefixes?: boolean): {
2
+ add: (keywords: string, asPrefixes: boolean) => void;
3
+ toString: () => string;
4
+ toRe: () => RegExp;
5
+ };
6
+
7
+ export { retrie };
@@ -0,0 +1 @@
1
+ const n=new Set([".","?","*","+","^","$","|","(",")","{","[","\\"]);function t(e,o=!1){const l={},r=(n,t)=>{let e;let o=l;for(let l=0,r=n.length;l<r;++l)(e=n.charAt(l))in o||(o[e]=t?{"":""}:{}),o=o[e];t&&(o[""]="")};for(let n=0,t=e.length;n<t;++n)r(e[n],o);const c=()=>(function t(e){let o,l,r=!1,c=!1;const i=[],h=[];for(const o in e){if(!o){r=!0;continue}((l=t(e[o]))?i:h).push((n.has(o)?"\\"+o:o)+l)}return r&&null==l?"":(c=!i.length,h.length&&i.push(h[1]?"["+h.join("")+"]":h[0]),o=i[1]?"(?:"+i.join("|")+")":i[0],r&&(o=c?o+"?":"(?:"+o+")?"),o||"")})(l);return{add:r,toString:c,toRe:()=>new RegExp((o?"^":"")+c())}}export{t as retrie};