UNPKG

@ishitatsuyuki/oruga-next

Version:

UI components for Vue.js and CSS framework agnostic

22 lines (20 loc) 564 B
class InstanceRegistry { constructor() { this.entries = []; } add(entry) { this.entries.push(entry); } remove(entry) { let index = this.entries.indexOf(entry); this.entries.splice(index, 1); } walk(callback) { // Walk a copy of the array so that the callback is allowed to remove the instance this.entries = [...this.entries].filter((e) => { const ret = callback(e); return !(ret === true); }); } } export { InstanceRegistry as I };