Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

43
node_modules/es-toolkit/dist/util/attempt.d.mts generated vendored Normal file
View File

@@ -0,0 +1,43 @@
//#region src/util/attempt.d.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param {() => T} func - The function to execute.
* @returns {[null, T] | [E, null]} A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
declare function attempt<T, E>(func: () => T): [null, T] | [E, null];
//#endregion
export { attempt };

43
node_modules/es-toolkit/dist/util/attempt.d.ts generated vendored Normal file
View File

@@ -0,0 +1,43 @@
//#region src/util/attempt.d.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param {() => T} func - The function to execute.
* @returns {[null, T] | [E, null]} A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
declare function attempt<T, E>(func: () => T): [null, T] | [E, null];
//#endregion
export { attempt };

49
node_modules/es-toolkit/dist/util/attempt.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
//#region src/util/attempt.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param {() => T} func - The function to execute.
* @returns {[null, T] | [E, null]} A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
function attempt(func) {
try {
return [null, func()];
} catch (error) {
return [error, null];
}
}
//#endregion
exports.attempt = attempt;

49
node_modules/es-toolkit/dist/util/attempt.mjs generated vendored Normal file
View File

@@ -0,0 +1,49 @@
//#region src/util/attempt.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param {() => T} func - The function to execute.
* @returns {[null, T] | [E, null]} A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
function attempt(func) {
try {
return [null, func()];
} catch (error) {
return [error, null];
}
}
//#endregion
export { attempt };

36
node_modules/es-toolkit/dist/util/attemptAsync.d.mts generated vendored Normal file
View File

@@ -0,0 +1,36 @@
//#region src/util/attemptAsync.d.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param {() => Promise<T>} func - The async function to execute.
* @returns {Promise<[null, T] | [E, null]>} A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
declare function attemptAsync<T, E>(func: () => Promise<T>): Promise<[null, T] | [E, null]>;
//#endregion
export { attemptAsync };

36
node_modules/es-toolkit/dist/util/attemptAsync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,36 @@
//#region src/util/attemptAsync.d.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param {() => Promise<T>} func - The async function to execute.
* @returns {Promise<[null, T] | [E, null]>} A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
declare function attemptAsync<T, E>(func: () => Promise<T>): Promise<[null, T] | [E, null]>;
//#endregion
export { attemptAsync };

42
node_modules/es-toolkit/dist/util/attemptAsync.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
//#region src/util/attemptAsync.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param {() => Promise<T>} func - The async function to execute.
* @returns {Promise<[null, T] | [E, null]>} A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
async function attemptAsync(func) {
try {
return [null, await func()];
} catch (error) {
return [error, null];
}
}
//#endregion
exports.attemptAsync = attemptAsync;

42
node_modules/es-toolkit/dist/util/attemptAsync.mjs generated vendored Normal file
View File

@@ -0,0 +1,42 @@
//#region src/util/attemptAsync.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param {() => Promise<T>} func - The async function to execute.
* @returns {Promise<[null, T] | [E, null]>} A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
async function attemptAsync(func) {
try {
return [null, await func()];
} catch (error) {
return [error, null];
}
}
//#endregion
export { attemptAsync };

4
node_modules/es-toolkit/dist/util/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { attempt } from "./attempt.mjs";
import { attemptAsync } from "./attemptAsync.mjs";
import { invariant } from "./invariant.mjs";
export { invariant as assert, attempt, attemptAsync, invariant };

4
node_modules/es-toolkit/dist/util/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { attempt } from "./attempt.js";
import { attemptAsync } from "./attemptAsync.js";
import { invariant } from "./invariant.js";
export { invariant as assert, attempt, attemptAsync, invariant };

8
node_modules/es-toolkit/dist/util/index.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_attempt = require("./attempt.js");
const require_attemptAsync = require("./attemptAsync.js");
const require_invariant = require("./invariant.js");
exports.assert = require_invariant.invariant;
exports.attempt = require_attempt.attempt;
exports.attemptAsync = require_attemptAsync.attemptAsync;
exports.invariant = require_invariant.invariant;

4
node_modules/es-toolkit/dist/util/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { attempt } from "./attempt.mjs";
import { attemptAsync } from "./attemptAsync.mjs";
import { invariant } from "./invariant.mjs";
export { invariant as assert, attempt, attemptAsync, invariant };

41
node_modules/es-toolkit/dist/util/invariant.d.mts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
//#region src/util/invariant.d.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param {unknown} condition - The condition to evaluate.
* @param {string} message - The error message to throw if the condition is false.
* @returns {void} Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*/
declare function invariant(condition: unknown, message: string): asserts condition;
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided error.
*
* @param {unknown} condition - The condition to evaluate.
* @param {Error} error - The error to throw if the condition is false.
* @returns {void} Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, new Error('This should not throw'));
*
* class CustomError extends Error {
* constructor(message: string) {
* super(message);
* }
* }
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, new CustomError('This should throw'));
*/
declare function invariant(condition: unknown, error: Error): asserts condition;
//#endregion
export { invariant };

41
node_modules/es-toolkit/dist/util/invariant.d.ts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
//#region src/util/invariant.d.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param {unknown} condition - The condition to evaluate.
* @param {string} message - The error message to throw if the condition is false.
* @returns {void} Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*/
declare function invariant(condition: unknown, message: string): asserts condition;
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided error.
*
* @param {unknown} condition - The condition to evaluate.
* @param {Error} error - The error to throw if the condition is false.
* @returns {void} Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, new Error('This should not throw'));
*
* class CustomError extends Error {
* constructor(message: string) {
* super(message);
* }
* }
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, new CustomError('This should throw'));
*/
declare function invariant(condition: unknown, error: Error): asserts condition;
//#endregion
export { invariant };

32
node_modules/es-toolkit/dist/util/invariant.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
//#region src/util/invariant.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param {unknown} condition - The condition to evaluate.
* @param {string | Error} [message] - The error message to throw if the condition is false.
* @returns {void} Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*
* // Example of using invariant with a condition
* invariant(condition, 'Expected condition is false');
*
* // Ensure that the value is neither null nor undefined
* invariant(value !== null && value !== undefined, 'Value should not be null or undefined');
*
* // Example of using invariant to check if a number is positive
* invariant(number > 0, 'Number must be positive');
*/
function invariant(condition, message) {
if (condition) return;
if (typeof message === "string") throw new Error(message);
throw message;
}
//#endregion
exports.invariant = invariant;

32
node_modules/es-toolkit/dist/util/invariant.mjs generated vendored Normal file
View File

@@ -0,0 +1,32 @@
//#region src/util/invariant.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param {unknown} condition - The condition to evaluate.
* @param {string | Error} [message] - The error message to throw if the condition is false.
* @returns {void} Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*
* // Example of using invariant with a condition
* invariant(condition, 'Expected condition is false');
*
* // Ensure that the value is neither null nor undefined
* invariant(value !== null && value !== undefined, 'Value should not be null or undefined');
*
* // Example of using invariant to check if a number is positive
* invariant(number > 0, 'Number must be positive');
*/
function invariant(condition, message) {
if (condition) return;
if (typeof message === "string") throw new Error(message);
throw message;
}
//#endregion
export { invariant };