Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8d3b1ae
wip: Some JSDoc drafts & tests...
Byloth Dec 18, 2024
152a157
merge: Merge branch 'master' into feature/jsdoc
Byloth Dec 22, 2024
97f88c5
add: JSDoc for `JSONStorage` class.
Byloth Dec 22, 2024
a197ab8
add: Added JSDoc for `core`, `models/json`, `helpers` & almost all `u…
Byloth Dec 22, 2024
f7a6a33
upd: Completed JSDoc for `utils` directory.
Byloth Dec 25, 2024
9d1727c
add: Added JSDoc for part of `models/callbacks` files.
Byloth Dec 28, 2024
def0de9
add: Completed JSDoc for `models/callbacks` files.
Byloth Dec 28, 2024
4e60b8b
add: Completed JSDoc for `models/exceptions` files.
Byloth Dec 28, 2024
eff694b
add: Completed JSDoc for `models/timers` files. + Some clean-up. 🧽✨
Byloth Dec 28, 2024
10a9dc2
add: Completed some JSDoc for `models/promises` files.
Byloth Dec 28, 2024
58a9755
fix: Minor fixes.
Byloth Dec 29, 2024
62cf513
merge: Merge branch 'master' into feature/jsdoc
Byloth Dec 29, 2024
c6b77ea
add: A better `SmartPromise` documentation.
Byloth Dec 29, 2024
4a5db3a
add: Completed JSDoc for `models/promises` files.
Byloth Dec 30, 2024
5d170cf
add: Missing JSDoc for `models/promises/types` file.
Byloth Dec 30, 2024
f4da623
add: Added all the documentation for the used generic types.
Byloth Dec 31, 2024
d614fe1
add: Almost completed JSDoc for `models/iterators` files.
Byloth Dec 31, 2024
80ee774
wip: Added some minor docs. + Commented out async type-guards. They'r…
Byloth Jan 4, 2025
9f67f7f
add: Missing JSDoc for `models/iterators/types` file. + Reintroduced …
Byloth Jan 5, 2025
9fb59b7
upd: Updated dependencies.
Byloth Jan 5, 2025
b5472f7
fix: Fixed a no longer required `eslint-disable` rule.
Byloth Jan 5, 2025
26936eb
wip: A lot of things...
Byloth Jan 8, 2025
30e904a
wip: Minor edits.
Byloth Jan 11, 2025
8bf63d9
upd: Updated dependencies. 🔝
Byloth Jan 11, 2025
5e16ed0
wip: Added some minor docs...
Byloth Jan 11, 2025
e0fbd69
wip: Added some other docs...
Byloth Jan 17, 2025
3d0eaf5
add: Minor comments.
Byloth Jan 20, 2025
6a5860f
add: Missing JSDoc for `models/aggregators/aggregated[-async]-iterato…
Byloth Jan 21, 2025
e1b0ed5
upd: Updated dependencies. 🔝
Byloth Jan 21, 2025
97944a8
fix: Renamed `items` into `entries`.
Byloth Jan 21, 2025
ce05a2a
wip: Added some documentation...
Byloth Jan 23, 2025
04c30d7
fix: Minor JSDoc fixes.
Byloth Jan 23, 2025
22ac117
wip: Some other JSDoc...
Byloth Jan 24, 2025
0061acf
imp: Completed the JSDoc! FINALLY! 🥹
Byloth Jan 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ indent_size = 2
[*.{json,yml}]
indent_size = 2

[*.md]
[*.{js,md,ts,vue}]
max_line_length = off
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const gitignorePath = path.resolve(__dirname, ".gitignore");

export default [includeIgnoreFile(gitignorePath), ...eslintTs, {
rules: {
"no-trailing-spaces": ["error", { "ignoreComments": true }],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/unified-signatures": "off"
}
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"exports": {
".": {
"import": {
"default": "./dist/core.js",
"types": "./src/index.ts"
"types": "./src/index.ts",
"default": "./dist/core.js"
},
"require": {
"default": "./dist/core.umd.cjs",
"types": "./src/index.ts"
"types": "./src/index.ts",
"default": "./dist/core.umd.cjs"
}
}
},
Expand All @@ -58,10 +58,10 @@
},
"devDependencies": {
"@byloth/eslint-config-typescript": "^3.0.3",
"@types/node": "^22.10.2",
"@types/node": "^22.10.7",
"husky": "^9.1.7",
"typescript": "^5.7.2",
"vite": "^5.4.11"
"typescript": "^5.7.3",
"vite": "^6.0.10"
},
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
}
674 changes: 352 additions & 322 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
/**
* A utility type that allows to define a class constructor of a specific type.
* Is the counterpart of the native `InstanceType` utility type.
*
* ```ts
* function factory<T extends object>(Factory: Constructor<T>): T { [...] }
*
* const instance: MyObject = factory(MyObject);
* ```
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Constructor<T extends object, P extends unknown[] = any[]> = new (...args: P) => T;

/**
* A type that represents the return value of `setInterval` function,
* indipendently from the platform it's currently running on.
*
* For instance, in a browser environment, it's a `number` value representing the interval ID.
* In a Node.js environment, on the other hand, it's an object of type `NodeJS.Timeout`.
*
* This allows to seamlessly use the same code in both environments, without having to deal with the differences:
*
* ```ts
* const intervalId: Interval = setInterval(() => { [...] }, 1_000);
*
* clearInterval(intervalId);
* ```
*/
export type Interval = ReturnType<typeof setInterval>;

/**
* A type that represents the return value of `setTimeout` function,
* indipendently from the platform it's currently running on.
*
* For instance, in a browser environment, it's a `number` value representing the timeout ID.
* In a Node.js environment, on the other hand, it's an object of type `NodeJS.Timeout`.
*
* This allows to seamlessly use the same code in both environments, without having to deal with the differences:
*
* ```ts
* const timeoutId: Timeout = setTimeout(() => { [...] }, 1_000);
*
* clearTimeout(timeoutId);
* ```
*/
export type Timeout = ReturnType<typeof setTimeout>;
11 changes: 10 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */

/**
* An utility constant that indicates whether the current environment is a browser.
*/
// @ts-ignore
export const isBrowser = ((typeof window !== "undefined") && (typeof window.document !== "undefined"));

/**
* An utility constant that indicates whether the current environment is a Node.js runtime.
*/
// @ts-ignore
export const isNode = ((typeof process !== "undefined") && (process.versions?.node));
export const isNode = ((typeof process !== "undefined") && !!(process.versions?.node));

/**
* An utility constant that indicates whether the current environment is a Web Worker.
*/
// @ts-ignore
export const isWebWorker = ((typeof self === "object") && (self.constructor?.name === "DedicatedWorkerGlobalScope"));
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export {

export type {
AsyncGeneratorFunction,
AsyncIteratee,
AsyncIteratorLike,
AsyncKeyedIteratee,
AsyncKeyedReducer,
AsyncReducer,
Callback,
FulfilledHandler,
GeneratorFunction,
Expand All @@ -51,22 +55,20 @@ export type {
JSONValue,
KeyedIteratee,
KeyedReducer,
KeyedTypeGuardIteratee,
KeyedTypeGuardPredicate,
MaybeAsyncKeyedIteratee,
MaybeAsyncKeyedReducer,
MaybeAsyncKeyedTypeGuardIteratee,
MaybeAsyncGeneratorFunction,
MaybeAsyncIteratee,
MaybeAsyncIteratorLike,
MaybeAsyncReducer,
MaybeAsyncTypeGuardIteratee,
MaybePromise,
PromiseExecutor,
PromiseRejecter,
PromiseResolver,
Reducer,
RejectedHandler,
TypeGuardIteratee
TypeGuardPredicate

} from "./models/types.js";

Expand All @@ -82,6 +84,7 @@ export {
dateRound,
TimeUnit,
enumerate,
getWeek,
hash,
loadScript,
nextAnimationFrame,
Expand All @@ -90,6 +93,7 @@ export {
shuffle,
sum,
unique,
WeekDay,
yieldToEventLoop,
zip

Expand Down
Loading