UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

46 lines 1.18 kB
import NotFoundError from '../../lib/error/notfound-error.js'; export default class FakeTagStore { constructor() { this.tags = []; } async bulkImport(tags) { tags.forEach((t) => { this.tags.push(t); }); return tags; } async createTag(tag) { this.tags.push(tag); } async delete(key) { this.tags.splice(this.tags.indexOf(key)); } async deleteAll() { this.tags = []; } destroy() { } async exists(key) { return this.tags.some((t) => t === key); } async get(key) { const tag = this.tags.find((t) => t === key); if (tag) { return tag; } throw new NotFoundError('Tag does not exist'); } async getAll() { return this.tags; } async getTag(type, value) { const tag = this.tags.find((t) => t.type === type && t.value === value); if (tag) { return tag; } throw new NotFoundError('Tag does not exist'); } async getTagsByType(type) { return this.tags.filter((t) => t.type === type); } } //# sourceMappingURL=fake-tag-store.js.map