kitsu-core
Version:
Simple, lightweight & framework agnostic JSON:API (de)serialsation components
27 lines (23 loc) • 444 B
JavaScript
var error = require('./error.js');
function filterIncludes(included, {
id,
type
}) {
try {
if (id && type) {
const filtered = included.filter(el => {
return el.id === id && el.type === type;
})[0] || {
id,
type
};
return Object.assign({}, filtered);
} else {
return {};
}
} catch (E) {
error.error(E);
}
}
exports.filterIncludes = filterIncludes;
;