foxts 1.0.5 → 1.0.6

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.
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 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;
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 t=n("truthy"),e=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=e,exports.isNonNull=u,exports.isNonNullish=l,exports.isTruthy=t,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
@@ -13,5 +13,7 @@ declare const isTruthy: <T>(i: T | 0 | "" | false | null | undefined) => i is T;
13
13
  declare const isFalsy: (i: unknown) => i is 0 | "" | false | null | undefined;
14
14
  declare const isNonNull: <T>(i: T | null) => i is T;
15
15
  declare const isNonNullish: <T>(i: T | null | undefined) => i is T;
16
+ declare function nullthrow<T>(value: T | null | undefined, message?: string): T;
17
+ declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
16
18
 
17
- export { is, isFalsy, isNonNull, isNonNullish, isTruthy, not };
19
+ export { invariant, is, isFalsy, isNonNull, isNonNullish, isTruthy, not, nullthrow };
package/guard/index.mjs CHANGED
@@ -1 +1 @@
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};
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 l=r("truthy"),u=r("falsy"),t=n(null),e=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)}export{s as invariant,r as is,u as isFalsy,t as isNonNull,e as isNonNullish,l as isTruthy,n as not,i as nullthrow};
package/noop/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";exports.noop=function(){};
1
+ "use strict";exports.falseFn=()=>!1,exports.noop=()=>{},exports.throwFn=()=>{throw Error()},exports.trueFn=()=>!0;
package/noop/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
- declare function noop(): void;
1
+ interface Noop<T = any> {
2
+ (...args: any[]): T;
3
+ }
4
+ declare const noop: Noop;
5
+ declare const trueFn: Noop<true>;
6
+ declare const falseFn: Noop<false>;
7
+ declare const throwFn: Noop<never>;
2
8
 
3
- export { noop };
9
+ export { falseFn, noop, throwFn, trueFn };
package/noop/index.mjs CHANGED
@@ -1 +1 @@
1
- function o(){}export{o as noop};
1
+ const o=()=>{},r=()=>!0,n=()=>!1,t=()=>{throw Error()};export{n as falseFn,o as noop,t as throwFn,r as trueFn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -38,15 +38,6 @@
38
38
  "require": "./append-set-elements-to-array/index.cjs",
39
39
  "default": "./append-set-elements-to-array/index.cjs"
40
40
  },
41
- "./bitwise": {
42
- "types": "./bitwise/index.d.ts",
43
- "import": {
44
- "types": "./bitwise/index.d.ts",
45
- "default": "./bitwise/index.mjs"
46
- },
47
- "require": "./bitwise/index.cjs",
48
- "default": "./bitwise/index.cjs"
49
- },
50
41
  "./async-write-to-stream": {
51
42
  "types": "./async-write-to-stream/index.d.ts",
52
43
  "import": {
@@ -56,6 +47,15 @@
56
47
  "require": "./async-write-to-stream/index.cjs",
57
48
  "default": "./async-write-to-stream/index.cjs"
58
49
  },
50
+ "./fast-string-array-join": {
51
+ "types": "./fast-string-array-join/index.d.ts",
52
+ "import": {
53
+ "types": "./fast-string-array-join/index.d.ts",
54
+ "default": "./fast-string-array-join/index.mjs"
55
+ },
56
+ "require": "./fast-string-array-join/index.cjs",
57
+ "default": "./fast-string-array-join/index.cjs"
58
+ },
59
59
  "./fnv1a": {
60
60
  "types": "./fnv1a/index.d.ts",
61
61
  "import": {
@@ -65,14 +65,14 @@
65
65
  "require": "./fnv1a/index.cjs",
66
66
  "default": "./fnv1a/index.cjs"
67
67
  },
68
- "./fast-string-array-join": {
69
- "types": "./fast-string-array-join/index.d.ts",
68
+ "./bitwise": {
69
+ "types": "./bitwise/index.d.ts",
70
70
  "import": {
71
- "types": "./fast-string-array-join/index.d.ts",
72
- "default": "./fast-string-array-join/index.mjs"
71
+ "types": "./bitwise/index.d.ts",
72
+ "default": "./bitwise/index.mjs"
73
73
  },
74
- "require": "./fast-string-array-join/index.cjs",
75
- "default": "./fast-string-array-join/index.cjs"
74
+ "require": "./bitwise/index.cjs",
75
+ "default": "./bitwise/index.cjs"
76
76
  },
77
77
  "./fnv1a52": {
78
78
  "types": "./fnv1a52/index.d.ts",
@@ -119,6 +119,15 @@
119
119
  "require": "./is-probably-ip/index.cjs",
120
120
  "default": "./is-probably-ip/index.cjs"
121
121
  },
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
+ },
122
131
  "./noop": {
123
132
  "types": "./noop/index.d.ts",
124
133
  "import": {
@@ -145,15 +154,6 @@
145
154
  },
146
155
  "require": "./wait/index.cjs",
147
156
  "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"
157
157
  }
158
158
  }
159
159
  }