17 lines
846 B
JavaScript
17 lines
846 B
JavaScript
'use strict';
|
|
|
|
(function exposeLibraryModel(root, factory) {
|
|
const api = factory();
|
|
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
else root.chimeraLibraryModel = api;
|
|
})(typeof globalThis !== 'undefined' ? globalThis : window, function createLibraryModel() {
|
|
function items(response) {
|
|
if (Array.isArray(response)) return response;
|
|
return Array.isArray(response?.items) ? response.items : [];
|
|
}
|
|
function isInstalled(title) { return Number(title?.availability?.confirmedInstallCount || 0) > 0; }
|
|
function hasLocalCopy(title) { return Number(title?.protection?.localCopyCount || title?.availability?.localCopyCount || 0) > 0; }
|
|
function needsProtection(title) { return isInstalled(title) && !hasLocalCopy(title); }
|
|
return Object.freeze({ items, isInstalled, hasLocalCopy, needsProtection });
|
|
});
|