UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

31 lines 969 B
import { isString } from 'es-toolkit/compat'; export const isPlainObject = value => { if (Object.prototype.toString.call(value) !== '[object Object]') { return false; } const prototype = Object.getPrototypeOf(value); return prototype === Object.prototype || prototype === null; }; export const clone = value => structuredClone(value); export const isStringArray = value => Array.isArray(value) && value.every(entry => isString(entry)); export const normalizeOptionalString = value => { if (!isString(value)) { return null; } const normalizedValue = value.trim(); return normalizedValue.length > 0 ? normalizedValue : null; }; export const dedupeMessages = messages => { if (!Array.isArray(messages)) { return []; } return [...new Set(messages.filter(Boolean))]; }; export const spreadIf = (condition, value) => { if (Array.isArray(value)) { return condition ? [...value] : []; } return condition ? { ...value } : {}; };