UNPKG

@ishitatsuyuki/oruga-next

Version:

UI components for Vue.js and CSS framework agnostic

24 lines (21 loc) 590 B
'use strict'; 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); }); } } exports.InstanceRegistry = InstanceRegistry;