@depthbomb/common 1.0.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Caprine Logic (https://github.com/depthbomb)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @depthbomb/common
2
+
3
+ A set of common utilities for TypeScript/JavaScript that I use in my projects.
4
+
5
+ **Looking for utilities for Node.js specifically? See [@depthbomb/node-common](https://www.npmjs.com/package/@depthbomb/node-common)!**
6
+
7
+ ---
8
+
9
+ Documentation and additional TSDocs coming soon.
package/dist/async.cjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){return new Promise(t=>setTimeout(t,e))}function t(e){return new Promise((t,n)=>setTimeout(n,e))}async function n(t,n=100,r=5e3){let i=Date.now();for(;!await t();){if(Date.now()-i>r)throw Error(`Timeout exceeded`);await e(n)}}async function r(e,t){return Promise.race([e,new Promise((e,n)=>setTimeout(()=>n(Error(`Operation timed out`)),t))])}async function i(e){return(await Promise.allSettled(e)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}async function a(e){let t=[];for(let n of e)t.push(await n());return t}exports.allSettledSuccessful=i,exports.pollUntil=n,exports.rejectionTimeout=t,exports.sequential=a,exports.timeout=e,exports.withTimeout=r;
@@ -0,0 +1,44 @@
1
+ //#region src/async.d.ts
2
+ /**
3
+ * Returns a promise after the provided {@link ms} has passed
4
+ * @param ms The number of milliseconds to wait
5
+ */
6
+ declare function timeout(ms: number): Promise<unknown>;
7
+ /**
8
+ * Rejects a promise after the provided {@link ms} has passed
9
+ * @param ms The number of milliseconds to wait
10
+ */
11
+ declare function rejectionTimeout(ms: number): Promise<unknown>;
12
+ /**
13
+ * Polls until the provided condition is met, or the timeout is exceeded.
14
+ *
15
+ * @param condition A function that returns a boolean or a promise that resolves to a boolean
16
+ * @param interval The interval in milliseconds to wait between checks
17
+ * @param timeoutMs The maximum time in milliseconds to wait before throwing an error
18
+ */
19
+ declare function pollUntil(condition: () => boolean | Promise<boolean>, interval?: number, timeoutMs?: number): Promise<void>;
20
+ /**
21
+ * Wraps a promise with a timeout. If the promise does not resolve within the specified time, an error is thrown.
22
+ *
23
+ * @param promise The promise to wrap with a timeout
24
+ * @param ms The number of milliseconds to wait before timing out
25
+ *
26
+ * @returns The result of the promise if it resolves before the timeout, otherwise throws an error
27
+ */
28
+ declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
29
+ /**
30
+ * Waits for all promises to settle and returns an array of successful results.
31
+ *
32
+ * @param promises An array of promises to wait for
33
+ * @returns A promise that resolves to an array of successful results
34
+ */
35
+ declare function allSettledSuccessful<T>(promises: Promise<T>[]): Promise<T[]>;
36
+ /**
37
+ * Executes an array of asynchronous tasks sequentially.
38
+ *
39
+ * @param tasks An array of functions that return promises
40
+ * @returns A promise that resolves to an array of results from the input tasks
41
+ */
42
+ declare function sequential<T>(tasks: (() => Promise<T>)[]): Promise<T[]>;
43
+ //#endregion
44
+ export { allSettledSuccessful, pollUntil, rejectionTimeout, sequential, timeout, withTimeout };
@@ -0,0 +1,44 @@
1
+ //#region src/async.d.ts
2
+ /**
3
+ * Returns a promise after the provided {@link ms} has passed
4
+ * @param ms The number of milliseconds to wait
5
+ */
6
+ declare function timeout(ms: number): Promise<unknown>;
7
+ /**
8
+ * Rejects a promise after the provided {@link ms} has passed
9
+ * @param ms The number of milliseconds to wait
10
+ */
11
+ declare function rejectionTimeout(ms: number): Promise<unknown>;
12
+ /**
13
+ * Polls until the provided condition is met, or the timeout is exceeded.
14
+ *
15
+ * @param condition A function that returns a boolean or a promise that resolves to a boolean
16
+ * @param interval The interval in milliseconds to wait between checks
17
+ * @param timeoutMs The maximum time in milliseconds to wait before throwing an error
18
+ */
19
+ declare function pollUntil(condition: () => boolean | Promise<boolean>, interval?: number, timeoutMs?: number): Promise<void>;
20
+ /**
21
+ * Wraps a promise with a timeout. If the promise does not resolve within the specified time, an error is thrown.
22
+ *
23
+ * @param promise The promise to wrap with a timeout
24
+ * @param ms The number of milliseconds to wait before timing out
25
+ *
26
+ * @returns The result of the promise if it resolves before the timeout, otherwise throws an error
27
+ */
28
+ declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
29
+ /**
30
+ * Waits for all promises to settle and returns an array of successful results.
31
+ *
32
+ * @param promises An array of promises to wait for
33
+ * @returns A promise that resolves to an array of successful results
34
+ */
35
+ declare function allSettledSuccessful<T>(promises: Promise<T>[]): Promise<T[]>;
36
+ /**
37
+ * Executes an array of asynchronous tasks sequentially.
38
+ *
39
+ * @param tasks An array of functions that return promises
40
+ * @returns A promise that resolves to an array of results from the input tasks
41
+ */
42
+ declare function sequential<T>(tasks: (() => Promise<T>)[]): Promise<T[]>;
43
+ //#endregion
44
+ export { allSettledSuccessful, pollUntil, rejectionTimeout, sequential, timeout, withTimeout };
package/dist/async.mjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){return new Promise(t=>setTimeout(t,e))}function t(e){return new Promise((t,n)=>setTimeout(n,e))}async function n(t,n=100,r=5e3){let i=Date.now();for(;!await t();){if(Date.now()-i>r)throw Error(`Timeout exceeded`);await e(n)}}async function r(e,t){return Promise.race([e,new Promise((e,n)=>setTimeout(()=>n(Error(`Operation timed out`)),t))])}async function i(e){return(await Promise.allSettled(e)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}async function a(e){let t=[];for(let n of e)t.push(await n());return t}export{i as allSettledSuccessful,n as pollUntil,t as rejectionTimeout,a as sequential,e as timeout,r as withTimeout};
@@ -0,0 +1 @@
1
+ function e(e){let t=new WeakMap,n=0;function r(e){let i=typeof e;return e===null||i===`number`||i===`string`||i===`boolean`?e:i===`undefined`?`undefined`:i===`function`?`function:${e.name||`anon`}`:e instanceof Date?`date:${e.toISOString()}`:e instanceof RegExp?`regexp:${e.toString()}`:Array.isArray(e)?e.map(r):e instanceof Map?{map:[...e.entries()].map(([e,t])=>[r(e),r(t)])}:e instanceof Set?{set:[...e.values()].map(r).sort()}:typeof e==`object`?t.has(e)?{ref:t.get(e)}:(t.set(e,n++),{obj:Object.entries(e).sort(([e],[t])=>e<t?-1:1).map(([e,t])=>[e,r(t)])}):e}return JSON.stringify(e.map(r))}function t(t){return function(n,r){let i=new WeakMap;return async function(...r){let a=Date.now(),o=i.get(this);o||(o=new Map,i.set(this,o));let s=e(r),c=o.get(s);if(c&&c.expiry>a)return c.value;let l=n.apply(this,r),u=l instanceof Promise?await l:l;return o.set(s,{value:u,expiry:a+t}),u}}}exports.cache=t;
@@ -0,0 +1,10 @@
1
+ //#region src/decorators.d.ts
2
+ /**
3
+ * Creates a method decorator that caches the return value of the method for the specified
4
+ * {@link ttlMs|time to live} in milliseconds.
5
+ *
6
+ * @param ttlMs How long the cached value should be returned after its last call in milliseconds.
7
+ */
8
+ declare function cache(ttlMs: number): <T extends object>(method: (this: T, ...args: any[]) => any, _ctx: ClassMethodDecoratorContext<T>) => (this: T, ...args: any[]) => Promise<any>;
9
+ //#endregion
10
+ export { cache };
@@ -0,0 +1,10 @@
1
+ //#region src/decorators.d.ts
2
+ /**
3
+ * Creates a method decorator that caches the return value of the method for the specified
4
+ * {@link ttlMs|time to live} in milliseconds.
5
+ *
6
+ * @param ttlMs How long the cached value should be returned after its last call in milliseconds.
7
+ */
8
+ declare function cache(ttlMs: number): <T extends object>(method: (this: T, ...args: any[]) => any, _ctx: ClassMethodDecoratorContext<T>) => (this: T, ...args: any[]) => Promise<any>;
9
+ //#endregion
10
+ export { cache };
@@ -0,0 +1 @@
1
+ function e(e){let t=new WeakMap,n=0;function r(e){let i=typeof e;return e===null||i===`number`||i===`string`||i===`boolean`?e:i===`undefined`?`undefined`:i===`function`?`function:${e.name||`anon`}`:e instanceof Date?`date:${e.toISOString()}`:e instanceof RegExp?`regexp:${e.toString()}`:Array.isArray(e)?e.map(r):e instanceof Map?{map:[...e.entries()].map(([e,t])=>[r(e),r(t)])}:e instanceof Set?{set:[...e.values()].map(r).sort()}:typeof e==`object`?t.has(e)?{ref:t.get(e)}:(t.set(e,n++),{obj:Object.entries(e).sort(([e],[t])=>e<t?-1:1).map(([e,t])=>[e,r(t)])}):e}return JSON.stringify(e.map(r))}function t(t){return function(n,r){let i=new WeakMap;return async function(...r){let a=Date.now(),o=i.get(this);o||(o=new Map,i.set(this,o));let s=e(r),c=o.get(s);if(c&&c.expiry>a)return c.value;let l=n.apply(this,r),u=l instanceof Promise?await l:l;return o.set(s,{value:u,expiry:a+t}),u}}}export{t as cache};
package/dist/fn.cjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){let t=!1,n;return((...r)=>(t||=(n=e(...r),!0),n))}exports.once=e;
package/dist/fn.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ //#region src/fn.d.ts
2
+ /**
3
+ * Creates a function that calls the given function only once.
4
+ *
5
+ * @param fn Function to be called only once
6
+ * @returns A new function that calls the original function only once
7
+ */
8
+ declare function once<T extends (...args: any[]) => any>(fn: T): T;
9
+ //#endregion
10
+ export { once };
package/dist/fn.d.mts ADDED
@@ -0,0 +1,10 @@
1
+ //#region src/fn.d.ts
2
+ /**
3
+ * Creates a function that calls the given function only once.
4
+ *
5
+ * @param fn Function to be called only once
6
+ * @returns A new function that calls the original function only once
7
+ */
8
+ declare function once<T extends (...args: any[]) => any>(fn: T): T;
9
+ //#endregion
10
+ export { once };
package/dist/fn.mjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){let t=!1,n;return((...r)=>(t||=(n=e(...r),!0),n))}export{e as once};
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=require(`./async.cjs`),t=require(`./decorators.cjs`),n=require(`./fn.cjs`),r=require(`./lazy.cjs`),i=require(`./queue-QKkKGMY-.cjs`),a=require(`./types.cjs`);exports.Queue=i.t,exports.allSettledSuccessful=e.allSettledSuccessful,exports.assume=a.assume,exports.cache=t.cache,exports.cast=a.cast,exports.lazy=r.lazy,exports.lazyAsync=r.lazyAsync,exports.once=n.once,exports.pollUntil=e.pollUntil,exports.rejectionTimeout=e.rejectionTimeout,exports.resettableLazy=r.resettableLazy,exports.sequential=e.sequential,exports.timeout=e.timeout,exports.typedEntries=a.typedEntries,exports.withTimeout=e.withTimeout;
@@ -0,0 +1,7 @@
1
+ import { allSettledSuccessful, pollUntil, rejectionTimeout, sequential, timeout, withTimeout } from "./async.cjs";
2
+ import { cache } from "./decorators.cjs";
3
+ import { once } from "./fn.cjs";
4
+ import { lazy, lazyAsync, resettableLazy } from "./lazy.cjs";
5
+ import { Queue } from "./queue.cjs";
6
+ import { Awaitable, Maybe, Nullable, assume, cast, typedEntries } from "./types.cjs";
7
+ export { Awaitable, Maybe, Nullable, Queue, allSettledSuccessful, assume, cache, cast, lazy, lazyAsync, once, pollUntil, rejectionTimeout, resettableLazy, sequential, timeout, typedEntries, withTimeout };
@@ -0,0 +1,7 @@
1
+ import { allSettledSuccessful, pollUntil, rejectionTimeout, sequential, timeout, withTimeout } from "./async.mjs";
2
+ import { cache } from "./decorators.mjs";
3
+ import { once } from "./fn.mjs";
4
+ import { lazy, lazyAsync, resettableLazy } from "./lazy.mjs";
5
+ import { Queue } from "./queue.mjs";
6
+ import { Awaitable, Maybe, Nullable, assume, cast, typedEntries } from "./types.mjs";
7
+ export { Awaitable, Maybe, Nullable, Queue, allSettledSuccessful, assume, cache, cast, lazy, lazyAsync, once, pollUntil, rejectionTimeout, resettableLazy, sequential, timeout, typedEntries, withTimeout };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{allSettledSuccessful as e,pollUntil as t,rejectionTimeout as n,sequential as r,timeout as i,withTimeout as a}from"./async.mjs";import{cache as o}from"./decorators.mjs";import{once as s}from"./fn.mjs";import{lazy as c,lazyAsync as l,resettableLazy as u}from"./lazy.mjs";import{t as d}from"./queue-CX1hK7A0.mjs";import{assume as f,cast as p,typedEntries as m}from"./types.mjs";export{d as Queue,e as allSettledSuccessful,f as assume,o as cache,p as cast,c as lazy,l as lazyAsync,s as once,t as pollUntil,n as rejectionTimeout,u as resettableLazy,r as sequential,i as timeout,m as typedEntries,a as withTimeout};
package/dist/lazy.cjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){let t,n=!1;return()=>(n||=(t=e(),!0),t)}function t(e){let t;return()=>(t||=e(),t)}function n(e){let t,n=!1;function r(){return n||=(t=e(),!0),t}function i(){n=!1,t=void 0}return{get:r,reset:i}}exports.lazy=e,exports.lazyAsync=t,exports.resettableLazy=n;
@@ -0,0 +1,9 @@
1
+ //#region src/lazy.d.ts
2
+ declare function lazy<T>(factory: () => T): () => T;
3
+ declare function lazyAsync<T>(factory: () => Promise<T>): () => Promise<T>;
4
+ declare function resettableLazy<T>(factory: () => T): {
5
+ get: () => T;
6
+ reset: () => void;
7
+ };
8
+ //#endregion
9
+ export { lazy, lazyAsync, resettableLazy };
@@ -0,0 +1,9 @@
1
+ //#region src/lazy.d.ts
2
+ declare function lazy<T>(factory: () => T): () => T;
3
+ declare function lazyAsync<T>(factory: () => Promise<T>): () => Promise<T>;
4
+ declare function resettableLazy<T>(factory: () => T): {
5
+ get: () => T;
6
+ reset: () => void;
7
+ };
8
+ //#endregion
9
+ export { lazy, lazyAsync, resettableLazy };
package/dist/lazy.mjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){let t,n=!1;return()=>(n||=(t=e(),!0),t)}function t(e){let t;return()=>(t||=e(),t)}function n(e){let t,n=!1;function r(){return n||=(t=e(),!0),t}function i(){n=!1,t=void 0}return{get:r,reset:i}}export{e as lazy,t as lazyAsync,n as resettableLazy};
@@ -0,0 +1 @@
1
+ function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let i;i=Symbol.iterator;var a=class{constructor(e){r(this,`items`,[]),e&&(this.items=[...e])}get size(){return this.items.length}get isEmpty(){return this.items.length===0}enqueue(e){this.items.push(e)}dequeue(){return this.items.shift()}peek(){return this.items[0]}clear(){this.items=[]}[i](){return this.items[Symbol.iterator]()}toArray(){return[...this.items]}};export{a as t};
@@ -0,0 +1 @@
1
+ function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let i;i=Symbol.iterator;var a=class{constructor(e){r(this,`items`,[]),e&&(this.items=[...e])}get size(){return this.items.length}get isEmpty(){return this.items.length===0}enqueue(e){this.items.push(e)}dequeue(){return this.items.shift()}peek(){return this.items[0]}clear(){this.items=[]}[i](){return this.items[Symbol.iterator]()}toArray(){return[...this.items]}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
package/dist/queue.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=require(`./queue-QKkKGMY-.cjs`);exports.Queue=e.t;
@@ -0,0 +1,49 @@
1
+ //#region src/queue.d.ts
2
+ declare class Queue<T> {
3
+ private items;
4
+ constructor(initial?: Iterable<T>);
5
+ /**
6
+ * Get the number of items in the queue.
7
+ */
8
+ get size(): number;
9
+ /**
10
+ * Check if the queue is empty.
11
+ */
12
+ get isEmpty(): boolean;
13
+ /**
14
+ * Add an item to the end of the queue.
15
+ *
16
+ * @param item Item to add to the end of the queue
17
+ */
18
+ enqueue(item: T): void;
19
+ /**
20
+ * Remove and return the item at the front of the queue.
21
+ *
22
+ * @returns The item at the front of the queue, or undefined if the queue is empty
23
+ */
24
+ dequeue(): T | undefined;
25
+ /**
26
+ * Return the item at the front of the queue without removing it.
27
+ *
28
+ * @returns The item at the front of the queue without removing it, or undefined if the queue is empty
29
+ */
30
+ peek(): T | undefined;
31
+ /**
32
+ * Clear all items from the queue.
33
+ */
34
+ clear(): void;
35
+ /**
36
+ * Get an iterator for the items in the queue.
37
+ *
38
+ * @returns An iterator for the items in the queue
39
+ */
40
+ [Symbol.iterator](): Iterator<T>;
41
+ /**
42
+ * Convert the queue to an array.
43
+ *
44
+ * @returns An array containing all items in the queue in order
45
+ */
46
+ toArray(): T[];
47
+ }
48
+ //#endregion
49
+ export { Queue };
@@ -0,0 +1,49 @@
1
+ //#region src/queue.d.ts
2
+ declare class Queue<T> {
3
+ private items;
4
+ constructor(initial?: Iterable<T>);
5
+ /**
6
+ * Get the number of items in the queue.
7
+ */
8
+ get size(): number;
9
+ /**
10
+ * Check if the queue is empty.
11
+ */
12
+ get isEmpty(): boolean;
13
+ /**
14
+ * Add an item to the end of the queue.
15
+ *
16
+ * @param item Item to add to the end of the queue
17
+ */
18
+ enqueue(item: T): void;
19
+ /**
20
+ * Remove and return the item at the front of the queue.
21
+ *
22
+ * @returns The item at the front of the queue, or undefined if the queue is empty
23
+ */
24
+ dequeue(): T | undefined;
25
+ /**
26
+ * Return the item at the front of the queue without removing it.
27
+ *
28
+ * @returns The item at the front of the queue without removing it, or undefined if the queue is empty
29
+ */
30
+ peek(): T | undefined;
31
+ /**
32
+ * Clear all items from the queue.
33
+ */
34
+ clear(): void;
35
+ /**
36
+ * Get an iterator for the items in the queue.
37
+ *
38
+ * @returns An iterator for the items in the queue
39
+ */
40
+ [Symbol.iterator](): Iterator<T>;
41
+ /**
42
+ * Convert the queue to an array.
43
+ *
44
+ * @returns An array containing all items in the queue in order
45
+ */
46
+ toArray(): T[];
47
+ }
48
+ //#endregion
49
+ export { Queue };
package/dist/queue.mjs ADDED
@@ -0,0 +1 @@
1
+ import{t as e}from"./queue-CX1hK7A0.mjs";export{e as Queue};
package/dist/types.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=e=>e;function t(e){}function n(e){return Object.entries(e)}exports.assume=t,exports.cast=e,exports.typedEntries=n;
@@ -0,0 +1,9 @@
1
+ //#region src/types.d.ts
2
+ type Awaitable<T> = PromiseLike<T> | T;
3
+ type Maybe<T> = T | undefined;
4
+ type Nullable<T> = T | null;
5
+ declare const cast: <T, U extends T>(value: U) => U;
6
+ declare function assume<T>(value: unknown): asserts value is T;
7
+ declare function typedEntries<T extends object>(obj: T): { [K in keyof T]: [K, T[K]] }[keyof T][];
8
+ //#endregion
9
+ export { Awaitable, Maybe, Nullable, assume, cast, typedEntries };
@@ -0,0 +1,9 @@
1
+ //#region src/types.d.ts
2
+ type Awaitable<T> = PromiseLike<T> | T;
3
+ type Maybe<T> = T | undefined;
4
+ type Nullable<T> = T | null;
5
+ declare const cast: <T, U extends T>(value: U) => U;
6
+ declare function assume<T>(value: unknown): asserts value is T;
7
+ declare function typedEntries<T extends object>(obj: T): { [K in keyof T]: [K, T[K]] }[keyof T][];
8
+ //#endregion
9
+ export { Awaitable, Maybe, Nullable, assume, cast, typedEntries };
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ const e=e=>e;function t(e){}function n(e){return Object.entries(e)}export{t as assume,e as cast,n as typedEntries};
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@depthbomb/common",
3
+ "version": "1.0.0",
4
+ "description": "A set of common utilities for TypeScript/JavaScript",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=22"
8
+ },
9
+ "keywords": [
10
+ "typescript",
11
+ "utilities"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "require": "./dist/index.cjs",
16
+ "import": "./dist/index.mjs"
17
+ },
18
+ "./async": {
19
+ "require": "./dist/async.cjs",
20
+ "import": "./dist/async.mjs"
21
+ },
22
+ "./decorators": {
23
+ "require": "./dist/decorators.cjs",
24
+ "import": "./dist/decorators.mjs"
25
+ },
26
+ "./fn": {
27
+ "require": "./dist/fn.cjs",
28
+ "import": "./dist/fn.mjs"
29
+ },
30
+ "./lazy": {
31
+ "require": "./dist/lazy.cjs",
32
+ "import": "./dist/lazy.mjs"
33
+ },
34
+ "./queue": {
35
+ "require": "./dist/queue.cjs",
36
+ "import": "./dist/queue.mjs"
37
+ },
38
+ "./types": {
39
+ "require": "./dist/types.cjs",
40
+ "import": "./dist/types.mjs"
41
+ }
42
+ },
43
+ "main": "./dist/index.cjs",
44
+ "module": "./dist/index.mjs",
45
+ "types": "./dist/index.d.cts",
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "sideEffects": false,
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/depthbomb/js-common.git"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/depthbomb/js-common/issues"
59
+ },
60
+ "scripts": {
61
+ "build": "tsc",
62
+ "dist": "tsdown",
63
+ "release": "yarn dist && release-it",
64
+ "lint": "eslint ./src --ext .ts"
65
+ },
66
+ "devDependencies": {
67
+ "@types/eslint": "^9.6.1",
68
+ "@types/node": "^22.19.7",
69
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
70
+ "@typescript-eslint/parser": "^8.53.0",
71
+ "eslint": "^9.39.2",
72
+ "release-it": "^19.2.3",
73
+ "tsdown": "^0.20.0-beta.3",
74
+ "typescript": "^5.9.3"
75
+ },
76
+ "packageManager": "yarn@4.12.0"
77
+ }