@nestjs/graphql
Version:
Nest - modern, fast, powerful node.js web framework (@graphql)
27 lines (26 loc) • 648 B
JavaScript
export class MetadataByNameCollection {
constructor() {
this.internalCollection = new Map();
this.all = [];
}
getAll() {
return [...this.all];
}
getByName(name) {
return this.internalCollection.get(name);
}
add(value, name) {
if (this.internalCollection.has(name)) {
return;
}
this.internalCollection.set(name, value);
this.all.push(value);
}
unshift(value, name) {
if (this.internalCollection.has(name)) {
return;
}
this.internalCollection.set(name, value);
this.all.unshift(value);
}
}