UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

59 lines 1.23 kB
/** * @module Utilities */ export const RESULT = { FAILURE: "failure", SUCCESS: "success", }; /** * * IMPORT_PATH: `"@daiso-tech/core/utilities"` */ export function isResultFailure(value) { return (typeof value === "object" && value !== null && "type" in value && typeof value.type === "string" && value.type === RESULT.FAILURE && "error" in value); } /** * * IMPORT_PATH: `"@daiso-tech/core/utilities"` */ export function isResultSuccess(value) { return (typeof value === "object" && value !== null && "type" in value && typeof value.type === "string" && value.type === RESULT.SUCCESS && "value" in value); } /** * * IMPORT_PATH: `"@daiso-tech/core/utilities"` */ export function isResult(value) { return isResultFailure(value) || isResultSuccess(value); } /** * * IMPORT_PATH: `"@daiso-tech/core/utilities"` */ export function resultFailure(error) { return { type: RESULT.FAILURE, error, }; } /** * * IMPORT_PATH: `"@daiso-tech/core/utilities"` */ export function resultSuccess(value) { return { type: RESULT.SUCCESS, value, }; } //# sourceMappingURL=result.js.map