foxts 4.4.0 → 4.5.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.
- package/dist/array-push-non-nullish/index.d.ts +11 -0
- package/dist/array-push-non-nullish/index.js +1 -0
- package/dist/array-push-non-nullish/index.mjs +1 -0
- package/dist/guard/index.js +1 -1
- package/dist/guard/index.mjs +1 -1
- package/dist/join-readablestreams/index.d.ts +3 -0
- package/dist/join-readablestreams/index.js +1 -0
- package/dist/join-readablestreams/index.mjs +1 -0
- package/package.json +13 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The only use case I have thought of so far would be @typescript-eslint/await-thenable banning
|
|
3
|
+
*
|
|
4
|
+
* `await Promise.all(Array<Promise | null | undefined>)`
|
|
5
|
+
*
|
|
6
|
+
* So instead of `.filter(not('nullish'))` which need to iterate through array, we use this when pushing
|
|
7
|
+
* things to array in the first place
|
|
8
|
+
*/
|
|
9
|
+
declare function arrayPushNonNullish<T>(arr: T[], itemOrItems: T | null | undefined | Array<T | null | undefined>): void;
|
|
10
|
+
|
|
11
|
+
export { arrayPushNonNullish };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.arrayPushNonNullish=function(s,l){if(Array.isArray(l))for(let r=0,u=l.length;r<u;r++){const u=l[r];null!=u&&s.push(u)}else null!=l&&s.push(l)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(l,r){if(Array.isArray(r))for(let n=0,s=r.length;n<s;n++){const s=r[n];null!=s&&l.push(s)}else null!=r&&l.push(r)}export{l as arrayPushNonNullish};
|
package/dist/guard/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const r=r=>null!==r,e=r=>void 0!==r,n=r=>!1!==r,t=r=>null!=r,u=r=>!!r,s=r=>null===r,l=r=>void 0===r,o=r=>!1===r,i=r=>null==r,a=r=>!r,c=r=>!!r;function f(r,e="value"){throw TypeError(`Unexpected ${e}: ${r} as ${JSON.stringify(typeof r)}, should be "never"`)}exports.invariant=function(r,e='[foxts/invariant] "value" is null or undefined'){if(null==r)throw TypeError(e)},exports.is=function(r){switch(r){case null:return s;case void 0:return l;case!1:return o;case"nullish":return i;case"falsy":return a;case"truthy":return c;default:f(r,"argument")}},exports.isFalsy=a,exports.isNonNull=r,exports.isNonNullish=t,exports.isTruthy=c,exports.never=f,exports.not=function(s){switch(s){case null:return r;case void 0:return e;case!1:return n;case"nullish":return t;case"falsy":return u;default:f(s,"argument")}},exports.nullthrow=function(r,e='[foxts/invariant] "value" is null or undefined'){if(null==r)throw TypeError(e);return r};
|
package/dist/guard/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const n=n=>null!==n,r=n=>void 0!==n,e=n=>!1!==n,u=n=>null!=n,t=n=>!!n;function l(l){switch(l){case null:return n;case void 0:return r;case!1:return e;case"nullish":return u;case"falsy":return t;default:x(l,"argument")}}const s=n=>null===n,i=n=>void 0===n,o=n=>!1===n,a=n=>null==n,c=n=>!n,f=n=>!!n;function d(n){switch(n){case null:return s;case void 0:return i;case!1:return o;case"nullish":return a;case"falsy":return c;case"truthy":return f;default:x(n,"argument")}}const h=f,v=c,y=n,p=u;function w(n,r='[foxts/invariant] "value" is null or undefined'){if(null==n)throw TypeError(r);return n}function N(n,r='[foxts/invariant] "value" is null or undefined'){if(null==n)throw TypeError(r)}function x(n,r="value"){throw TypeError(`Unexpected ${r}: ${n} as ${JSON.stringify(typeof n)}, should be "never"`)}export{N as invariant,d as is,v as isFalsy,y as isNonNull,p as isNonNullish,h as isTruthy,x as never,l as not,w as nullthrow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.joinReadableStreams=function(e){return new ReadableStream({async start(r){try{for(const a of e){const e=a.getReader();try{for(;;){const a=await e.read();if(a.done)break;r.enqueue(a.value)}}finally{e.releaseLock()}}r.close()}catch(e){r.error(e)}}})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return new ReadableStream({async start(r){try{for(const a of e){const e=a.getReader();try{for(;;){const a=await e.read();if(a.done)break;r.enqueue(a.value)}}finally{e.releaseLock()}}r.close()}catch(e){r.error(e)}}})}export{e as joinReadableStreams};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Opinionated collection of common TypeScript utils by @SukkaW",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/SukkaW/foxts"
|
|
@@ -40,6 +40,12 @@
|
|
|
40
40
|
"require": "./dist/append-set-elements-to-array/index.js",
|
|
41
41
|
"default": "./dist/append-set-elements-to-array/index.js"
|
|
42
42
|
},
|
|
43
|
+
"./array-push-non-nullish": {
|
|
44
|
+
"types": "./dist/array-push-non-nullish/index.d.ts",
|
|
45
|
+
"import": "./dist/array-push-non-nullish/index.mjs",
|
|
46
|
+
"require": "./dist/array-push-non-nullish/index.js",
|
|
47
|
+
"default": "./dist/array-push-non-nullish/index.js"
|
|
48
|
+
},
|
|
43
49
|
"./async-retry": {
|
|
44
50
|
"types": "./dist/async-retry/index.d.ts",
|
|
45
51
|
"import": "./dist/async-retry/index.mjs",
|
|
@@ -196,6 +202,12 @@
|
|
|
196
202
|
"require": "./dist/is-probably-ip/index.js",
|
|
197
203
|
"default": "./dist/is-probably-ip/index.js"
|
|
198
204
|
},
|
|
205
|
+
"./join-readablestreams": {
|
|
206
|
+
"types": "./dist/join-readablestreams/index.d.ts",
|
|
207
|
+
"import": "./dist/join-readablestreams/index.mjs",
|
|
208
|
+
"require": "./dist/join-readablestreams/index.js",
|
|
209
|
+
"default": "./dist/join-readablestreams/index.js"
|
|
210
|
+
},
|
|
199
211
|
"./lazy-promise": {
|
|
200
212
|
"types": "./dist/lazy-promise/index.d.ts",
|
|
201
213
|
"import": "./dist/lazy-promise/index.mjs",
|