@nestjs/graphql
Version:
Nest - modern, fast, powerful node.js web framework (@graphql)
35 lines (34 loc) • 1.05 kB
JavaScript
import { MetadataByNameCollection } from './metadata-by-name.collection.js';
export class MetadataListByNameCollection extends MetadataByNameCollection {
constructor(globalArray = null) {
super();
this.globalArray = globalArray;
}
getByName(name) {
return super.getByName(name) || [];
}
add(value, name) {
let arrayResult = super.getByName(name);
if (!arrayResult) {
arrayResult = [];
this.internalCollection.set(name, arrayResult);
}
arrayResult.push(value);
this.all.push(value);
if (this.globalArray) {
this.globalArray.push(value);
}
}
unshift(value, name) {
let arrayResult = super.getByName(name);
if (!arrayResult) {
arrayResult = [];
this.internalCollection.set(name, arrayResult);
}
arrayResult.unshift(value);
this.all.unshift(value);
if (this.globalArray) {
this.globalArray.unshift(value);
}
}
}