foxts 1.0.4 → 1.0.5

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";var e=require("../identity/index.cjs");function t(r,n,i=e.identity){let u;const s=n.values();for(;!(u=s.next()).done;)r.push(i(u.value));return r}exports.appendSetElementsToArray=function(r,n,i=e.identity){if(!Array.isArray(n))return t(r,n,i);for(let e=0,u=n.length;e<u;e++)t(r,n[e],i);return r};
1
+ "use strict";var e=require("../identity/index.cjs");function r(e,r,t){let n;const i=r.values();for(;!(n=i.next()).done;)e.push(t(n.value));return e}exports.appendSetElementsToArray=function(t,n,i=e.identity){if(!Array.isArray(n))return r(t,n,i);for(let e=0,u=n.length;e<u;e++)r(t,n[e],i);return t};
@@ -1 +1 @@
1
- import{identity as e}from"../identity/index.mjs";function r(t,n,o=e){let i;const u=n.values();for(;!(i=u.next()).done;)t.push(o(i.value));return t}function t(n,o,i=e){if(!Array.isArray(o))return r(n,o,i);for(let e=0,t=o.length;e<t;e++)r(n,o[e],i);return n}export{t as appendSetElementsToArray};
1
+ import{identity as e}from"../identity/index.mjs";function r(e,r,t){let n;const o=r.values();for(;!(n=o.next()).done;)e.push(t(n.value));return e}function t(n,o,i=e){if(!Array.isArray(o))return r(n,o,i);for(let e=0,t=o.length;e<t;e++)r(n,o[e],i);return n}export{t as appendSetElementsToArray};
package/bitwise/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const t=t=>t>>16&65535,r=t=>65535&t,e=t=>t>>20&1023,s=t=>t>>10&1023,n=t=>1023&t;exports.bitCount=function(t){return t-=t>>1&0x55555555,((t=(0x33333333&t)+(t>>2&0x33333333))+(t>>4)&0xf0f0f0f)*0x1010101>>24},exports.deleteBit=function(t,r){return t&~r},exports.getBit=function(t,r){return!!(t&r)},exports.packThreeBits=(t,r,e)=>t<<20|r<<10|e,exports.packTwoBits=(t,r)=>t<<16|r,exports.setBit=function(t,r){return t|r},exports.unpackThreeBits=function(t,r=Array.from([,,,].keys())){return r[0]=e(t),r[1]=s(t),r[2]=n(t),r},exports.unpackThreeBitsFirst=e,exports.unpackThreeBitsSecond=s,exports.unpackThreeBitsThird=n,exports.unpackTwoBits=function(e,s=Array.from([,,].keys())){return s[0]=t(e),s[1]=r(e),s},exports.unpackTwoBitsFirst=t,exports.unpackTwoBitsSecond=r;
1
+ "use strict";const t=t=>t>>16&65535,e=t=>65535&t,r=t=>t>>20&1023,s=t=>t>>10&1023,o=t=>1023&t;exports.bitCount=function(t){return t-=t>>1&0x55555555,((t=(0x33333333&t)+(t>>2&0x33333333))+(t>>4)&0xf0f0f0f)*0x1010101>>24},exports.deleteBit=(t,e)=>t&~e,exports.getBit=(t,e)=>!!(t&e),exports.missingBit=(t,e)=>!(t&e),exports.packThreeBits=(t,e,r)=>t<<20|e<<10|r,exports.packTwoBits=(t,e)=>t<<16|e,exports.setBit=(t,e)=>t|e,exports.unpackThreeBits=function(t,e=Array.from([,,,].keys())){return e[0]=r(t),e[1]=s(t),e[2]=o(t),e},exports.unpackThreeBitsFirst=r,exports.unpackThreeBitsSecond=s,exports.unpackThreeBitsThird=o,exports.unpackTwoBits=function(r,s=Array.from([,,].keys())){return s[0]=t(r),s[1]=e(r),s},exports.unpackTwoBitsFirst=t,exports.unpackTwoBitsSecond=e;
@@ -1,7 +1,8 @@
1
1
  declare function bitCount(n: number): number;
2
- declare function getBit(n: number, mask: number): boolean;
3
- declare function setBit(n: number, mask: number): number;
4
- declare function deleteBit(n: number, mask: number): number;
2
+ declare const getBit: (n: number, mask: number) => boolean;
3
+ declare const missingBit: (n: number, mask: number) => boolean;
4
+ declare const setBit: (n: number, mask: number) => number;
5
+ declare const deleteBit: (n: number, mask: number) => number;
5
6
  /** Packs two 16-bit integers (0~65535) into one 32-bit integer */
6
7
  declare const packTwoBits: (a: number, b: number) => number;
7
8
  declare const unpackTwoBitsFirst: (value: number) => number;
@@ -26,4 +27,4 @@ declare const unpackThreeBitsThird: (value: number) => number;
26
27
  */
27
28
  declare function unpackThreeBits(value: number, arr?: [a: number, b: number, c: number]): [a: number, b: number, c: number];
28
29
 
29
- export { bitCount, deleteBit, getBit, packThreeBits, packTwoBits, setBit, unpackThreeBits, unpackThreeBitsFirst, unpackThreeBitsSecond, unpackThreeBitsThird, unpackTwoBits, unpackTwoBitsFirst, unpackTwoBitsSecond };
30
+ export { bitCount, deleteBit, getBit, missingBit, packThreeBits, packTwoBits, setBit, unpackThreeBits, unpackThreeBitsFirst, unpackThreeBitsSecond, unpackThreeBitsThird, unpackTwoBits, unpackTwoBitsFirst, unpackTwoBitsSecond };
package/bitwise/index.mjs CHANGED
@@ -1 +1 @@
1
- function t(t){return t-=t>>1&0x55555555,((t=(0x33333333&t)+(t>>2&0x33333333))+(t>>4)&0xf0f0f0f)*0x1010101>>24}function n(t,n){return!!(t&n)}function r(t,n){return t|n}function e(t,n){return t&~n}const i=(t,n)=>t<<16|n,u=t=>t>>16&65535,c=t=>65535&t;function o(t,n=Array.from([,,].keys())){return n[0]=u(t),n[1]=c(t),n}const s=(t,n,r)=>t<<20|n<<10|r,f=t=>t>>20&1023,B=t=>t>>10&1023,a=t=>1023&t;function k(t,n=Array.from([,,,].keys())){return n[0]=f(t),n[1]=B(t),n[2]=a(t),n}export{t as bitCount,e as deleteBit,n as getBit,s as packThreeBits,i as packTwoBits,r as setBit,k as unpackThreeBits,f as unpackThreeBitsFirst,B as unpackThreeBitsSecond,a as unpackThreeBitsThird,o as unpackTwoBits,u as unpackTwoBitsFirst,c as unpackTwoBitsSecond};
1
+ function t(t){return t-=t>>1&0x55555555,((t=(0x33333333&t)+(t>>2&0x33333333))+(t>>4)&0xf0f0f0f)*0x1010101>>24}const e=(t,e)=>!!(t&e),i=(t,e)=>!(t&e),n=(t,e)=>t|e,r=(t,e)=>t&~e,s=(t,e)=>t<<16|e,c=t=>t>>16&65535,o=t=>65535&t;function u(t,e=Array.from([,,].keys())){return e[0]=c(t),e[1]=o(t),e}const B=(t,e,i)=>t<<20|e<<10|i,a=t=>t>>20&1023,k=t=>t>>10&1023,p=t=>1023&t;function T(t,e=Array.from([,,,].keys())){return e[0]=a(t),e[1]=k(t),e[2]=p(t),e}export{t as bitCount,r as deleteBit,e as getBit,i as missingBit,B as packThreeBits,s as packTwoBits,n as setBit,T as unpackThreeBits,a as unpackThreeBitsFirst,k as unpackThreeBitsSecond,p as unpackThreeBitsThird,u as unpackTwoBits,c as unpackTwoBitsFirst,o as unpackTwoBitsSecond};
package/guard/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";function s(s){switch(s){case null:return s=>null!==s;case void 0:return s=>void 0!==s;case!1:return s=>!1!==s;case"nullish":return s=>null!=s;case"falsy":return s=>!!s;default:throw TypeError("Invalid argument")}}const r=s("falsy"),l=s(null),t=s("nullish");exports.isFalsy=s=>!s,exports.isNonNull=l,exports.isNonNullish=t,exports.isTruthy=r,exports.not=s;
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 t(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=t("truthy"),s=t("falsy"),n=r(null),u=r("nullish");exports.is=t,exports.isFalsy=s,exports.isNonNull=n,exports.isNonNullish=u,exports.isTruthy=e,exports.not=r;
package/guard/index.d.ts CHANGED
@@ -3,9 +3,15 @@ declare function not(arg: undefined): <T>(i: T | undefined) => i is T;
3
3
  declare function not(arg: false): <T>(i: T | false) => i is T;
4
4
  declare function not(arg: 'nullish'): <T>(i: T | null | undefined) => i is T;
5
5
  declare function not(arg: 'falsy'): <T>(i: T | 0 | '' | false | null | undefined) => i is T;
6
+ declare function is(arg: null): (i: unknown) => i is null;
7
+ declare function is(arg: undefined): (i: unknown) => i is undefined;
8
+ declare function is(arg: false): (i: unknown) => i is false;
9
+ declare function is(arg: 'nullish'): (i: unknown) => i is null | undefined;
10
+ declare function is(arg: 'falsy'): (i: unknown) => i is 0 | '' | false | null | undefined;
11
+ declare function is(arg: 'truthy'): <T>(i: T | 0 | '' | false | null | undefined) => i is T;
6
12
  declare const isTruthy: <T>(i: T | 0 | "" | false | null | undefined) => i is T;
7
- declare const isFalsy: <T>(i: T | 0 | "" | false | null | undefined) => i is 0 | "" | false | null | undefined;
13
+ declare const isFalsy: (i: unknown) => i is 0 | "" | false | null | undefined;
8
14
  declare const isNonNull: <T>(i: T | null) => i is T;
9
15
  declare const isNonNullish: <T>(i: T | null | undefined) => i is T;
10
16
 
11
- export { isFalsy, isNonNull, isNonNullish, isTruthy, not };
17
+ export { is, isFalsy, isNonNull, isNonNullish, isTruthy, not };
package/guard/index.mjs CHANGED
@@ -1 +1 @@
1
- function l(l){switch(l){case null:return l=>null!==l;case void 0:return l=>void 0!==l;case!1:return l=>!1!==l;case"nullish":return l=>null!=l;case"falsy":return l=>!!l;default:throw TypeError("Invalid argument")}}const n=l("falsy"),r=l=>!l,s=l(null),u=l("nullish");export{r as isFalsy,s as isNonNull,u as isNonNullish,n as isTruthy,l as not};
1
+ 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 l=n("truthy"),u=n("falsy"),e=r(null),t=r("nullish");export{n as is,u as isFalsy,e as isNonNull,t as isNonNullish,l as isTruthy,r as not};
@@ -0,0 +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};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Check if a hostname is an IP. You should be aware that this only works
3
+ * because `hostname` is already garanteed to be a valid hostname!
4
+ */
5
+ declare function isProbablyIpv4(hostname: string): boolean;
6
+ declare function isProbablyIpv6(hostname: string): boolean;
7
+
8
+ export { isProbablyIpv4, isProbablyIpv6 };
@@ -0,0 +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};
package/noop/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";exports.noop=function(){};
@@ -0,0 +1,3 @@
1
+ declare function noop(): void;
2
+
3
+ export { noop };
package/noop/index.mjs ADDED
@@ -0,0 +1 @@
1
+ function o(){}export{o as noop};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -56,15 +56,6 @@
56
56
  "require": "./async-write-to-stream/index.cjs",
57
57
  "default": "./async-write-to-stream/index.cjs"
58
58
  },
59
- "./fast-string-array-join": {
60
- "types": "./fast-string-array-join/index.d.ts",
61
- "import": {
62
- "types": "./fast-string-array-join/index.d.ts",
63
- "default": "./fast-string-array-join/index.mjs"
64
- },
65
- "require": "./fast-string-array-join/index.cjs",
66
- "default": "./fast-string-array-join/index.cjs"
67
- },
68
59
  "./fnv1a": {
69
60
  "types": "./fnv1a/index.d.ts",
70
61
  "import": {
@@ -74,6 +65,15 @@
74
65
  "require": "./fnv1a/index.cjs",
75
66
  "default": "./fnv1a/index.cjs"
76
67
  },
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
77
  "./fnv1a52": {
78
78
  "types": "./fnv1a52/index.d.ts",
79
79
  "import": {
@@ -110,14 +110,23 @@
110
110
  "require": "./identity/index.cjs",
111
111
  "default": "./identity/index.cjs"
112
112
  },
113
- "./merge-headers": {
114
- "types": "./merge-headers/index.d.ts",
113
+ "./is-probably-ip": {
114
+ "types": "./is-probably-ip/index.d.ts",
115
115
  "import": {
116
- "types": "./merge-headers/index.d.ts",
117
- "default": "./merge-headers/index.mjs"
116
+ "types": "./is-probably-ip/index.d.ts",
117
+ "default": "./is-probably-ip/index.mjs"
118
118
  },
119
- "require": "./merge-headers/index.cjs",
120
- "default": "./merge-headers/index.cjs"
119
+ "require": "./is-probably-ip/index.cjs",
120
+ "default": "./is-probably-ip/index.cjs"
121
+ },
122
+ "./noop": {
123
+ "types": "./noop/index.d.ts",
124
+ "import": {
125
+ "types": "./noop/index.d.ts",
126
+ "default": "./noop/index.mjs"
127
+ },
128
+ "require": "./noop/index.cjs",
129
+ "default": "./noop/index.cjs"
121
130
  },
122
131
  "./simple-string-hash": {
123
132
  "types": "./simple-string-hash/index.d.ts",
@@ -136,6 +145,15 @@
136
145
  },
137
146
  "require": "./wait/index.cjs",
138
147
  "default": "./wait/index.cjs"
148
+ },
149
+ "./merge-headers": {
150
+ "types": "./merge-headers/index.d.ts",
151
+ "import": {
152
+ "types": "./merge-headers/index.d.ts",
153
+ "default": "./merge-headers/index.mjs"
154
+ },
155
+ "require": "./merge-headers/index.cjs",
156
+ "default": "./merge-headers/index.cjs"
139
157
  }
140
158
  }
141
159
  }