UNPKG

pinia-orm-edge

Version:

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.

35 lines (32 loc) 749 B
import { C as CastAttribute } from './pinia-orm.C7bM_uXu.mjs'; class BooleanCast extends CastAttribute { /** * Create a new String attribute instance. */ constructor(attributes) { super(attributes); } get(value) { if (typeof value === "boolean" || value === void 0 || value === null) { return value; } if (typeof value === "string") { if (value.length === 0) { return false; } const int = Number.parseInt(value, 0); return Number.isNaN(int) ? true : !!int; } if (typeof value === "number") { return !!value; } return false; } /** * Make the value for the attribute. */ set(value) { return this.get(value); } } export { BooleanCast as B };