Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
many (ids) {
this.debugMessage(`many(${this.url}) called (${ids.length} ids)`)
if (!this.isBulk) {
return Promise.reject(new Error('"many" is only available for bulk expanding endpoints'))
}
// Exit out early if we don't request any ids
if (ids.length === 0) {
return Promise.resolve([])
}
// Always only work on unique ids, since that's how the API works
ids = unique.immutable(ids)
// There is no cache time set, so always use the live data
if (!this.cacheTime) {
return this._many(ids)
}
// Get as much as possible out of the cache
const hashes = ids.map(id => this._cacheHash(id))
const handleCacheContent = (cached) => {
cached = cached.filter(x => x)
if (cached.length === ids.length) {
this.debugMessage(`many(${this.url}) resolving fully from cache`)
return cached
}
function component(alias, baseComponent, requirements, payload) {
return {
alias: alias,
base: baseComponent,
requirements: requirements
? unique([ baseComponent ].concat(requirements))
: [ baseComponent ],
payload: payload
}
}