devlien
Version:
Devlien is a lightweight, zero-dependency Node.js framework with clean MVC structure, built-in ORM, and intuitive routing for rapid backend development.
26 lines (21 loc) • 466 B
JavaScript
class collections {
#records;
constructor(records) {
this.#records = records;
}
first() {
return this.#records.length ? this.#records[0] : false;
}
last() {
return this.#records.length
? this.#records[this.#records.length - 1]
: false;
}
toArray() {
return Object.values(this.#records);
}
}
export default function collect(records) {
let _this = new collections(records);
return Object.assign(_this, records);
}