UNPKG

ionic-orm-2

Version:

Data-mapper ORM for Ionic WebSQL and SQLite

27 lines 858 B
export class OrmUtils { static groupBy(array, propertyCallback) { return array.reduce((groupedArray, value) => { const key = propertyCallback(value); let grouped = groupedArray.find(i => i.id === key); if (!grouped) { grouped = { id: key, items: [] }; groupedArray.push(grouped); } grouped.items.push(value); return groupedArray; }, []); } /** * Transforms given value into boolean value. */ static toBoolean(value) { if (typeof value === "boolean") return value; if (typeof value === "string") return value === "true" || value === "1"; if (typeof value === "number") return value > 0; return false; } } //# sourceMappingURL=OrmUtils.js.map