function createRestorable() {
    const _undo = [];
    const _once = createOnce();
    return {
        // Creates new instance of this type of Restorable
        createNew() {
            return createRestorable();
        },
        // Executes callback only once for the given key, returns saved value
        once: _once,
        // Returns child restorable for the given key (for sub-properties)
        sub(name, factory) {
            return this.once('sub:' + name, () => {
                const subr = factory ? factory() : this.createNew();
                this.pushUndo(() => subr.restore());
                return subr;
            });
        },
        // Push an undo operation to perform during restore
        pushUndo(cb) {
            return _undo.push(cb);
        },
        // Replay all undo operations
        restore() {
            _undo.forEach(cb => cb());
        }
    };
}
/**
 * Creates a basic Restorable tracker instance, which can be used to store a list of
 * undo operations to replay to restore object to the original state.
 * 
 * @returns {Restorable}
 */
Creates a basic Restorable tracker instance, which can be used to store a list of
undo operations to replay to restore object to the original state.

@returns {Restorable}
Creates a basic Restorable tracker instance which can be used to store a list of undo operations to replay to restore object to the original state . @returns { Restorable }
function createRestorable() {
    const _undo = [];
    const _once = createOnce();
    return {
        createNew() {
            return createRestorable();
        },
        once: _once,
        sub(name, factory) {
            return this.once('sub:' + name, () => {
                const subr = factory ? factory() : this.createNew();
                this.pushUndo(() => subr.restore());
                return subr;
            });
        },
        pushUndo(cb) {
            return _undo.push(cb);
        },
        restore() {
            _undo.forEach(cb => cb());
        }
    };
}
function createRestorable ( ) { const _undo = [ ] ; const _once = createOnce ( ) ; return { createNew ( ) { return createRestorable ( ) ; } , once : _once , sub ( name , factory ) { return this . once ( 'sub:' + name , ( ) => { const subr = factory ? factory ( ) : this . createNew ( ) ; this . pushUndo ( ( ) => subr . restore ( ) ) ; return subr ; } ) ; } , pushUndo ( cb ) { return _undo . push ( cb ) ; } , restore ( ) { _undo . forEach ( cb => cb ( ) ) ; } } ; }
Creates a basic Restorable tracker instance, which can be used to store a list of
 undo operations to replay to restore object to the original state.
Creates a basic Restorable tracker instance which can be used to store a list of undo operations to replay to restore object to the original state .
// Creates new instance of this type of Restorable // Executes callback only once for the given key, returns saved value // Returns child restorable for the given key (for sub-properties) // Push an undo operation to perform during restore // Replay all undo operations