@nestjs/graphql
Version:
Nest - modern, fast, powerful node.js web framework (@graphql)
24 lines (23 loc) • 639 B
JavaScript
export class ArrayWithGlobalCacheCollection {
constructor(globalArray) {
this.globalArray = globalArray;
this.internalArray = [];
}
getAll() {
return this.internalArray;
}
push(...items) {
this.globalArray.push(...items);
return this.internalArray.push(...items);
}
unshift(...items) {
this.globalArray.unshift(...items);
return this.internalArray.unshift(...items);
}
reverse() {
return this.internalArray.reverse();
}
reduce(callbackfn, initialValue) {
return this.internalArray.reduce(callbackfn, initialValue);
}
}