ember-source
Version:
A JavaScript framework for creating ambitious web applications
25 lines (23 loc) • 609 B
JavaScript
function isPresentArray(list) {
return list ? list.length > 0 : false;
}
function asPresentArray(list, message = `unexpected empty list`) {
return list;
}
function getLast(list) {
return list.length === 0 ? undefined : list[list.length - 1];
}
function getFirst(list) {
return list.length === 0 ? undefined : list[0];
}
function mapPresentArray(list, mapper) {
if (list === null) {
return null;
}
let out = [];
for (let item of list) {
out.push(mapper(item));
}
return out;
}
export { getFirst as a, asPresentArray as b, getLast as g, isPresentArray as i, mapPresentArray as m };