function createObjectRestorable() {
    const restorable = createRestorable();
    return {
        ...restorable,
        createNew () {
            return createObjectRestorable();
        },
        // Tracks property assignment
        set (obj, propName, val) {
            const key = `prop:${propName}`;
            // Only want to execute this once, the first time property is set
            restorable.once(key, () => {
                // If property existed, then we will reset it to original value,
                // otherwise we will delete it
                const oldVal = obj[propName];
                return (propName in obj)
                    ? restorable.pushUndo(() => obj[propName] = oldVal)
                    : restorable.pushUndo(() => delete obj[propName]);
            });
            // Perform the actual property assignment
            obj[propName] = val;
        }
    };
}
/**
 * Creates a Restorable which can track object property assignments (e.g. obj\[name\] = val).
 * During restore, all properties are returned to original sttate, i.e. either reset to original
 * value, or deleted, if they didn't exist.
 * 
 * @returns {ObjectRestorable}
 */
Creates a Restorable which can track object property assignments .
During restore, all properties are returned to original sttate, i.e. either reset to original
value, or deleted, if they didn't exist.


Creates a Restorable which can track object property assignments . During restore all properties are returned to original sttate i . e . either reset to original value or deleted if they didn ' t exist .
function createObjectRestorable() {
    const restorable = createRestorable();
    return {
        ...restorable,
        createNew () {
            return createObjectRestorable();
        },
        set (obj, propName, val) {
            const key = `prop:${propName}`;
            restorable.once(key, () => {
                const oldVal = obj[propName];
                return (propName in obj)
                    ? restorable.pushUndo(() => obj[propName] = oldVal)
                    : restorable.pushUndo(() => delete obj[propName]);
            });
            obj[propName] = val;
        }
    };
}
function createObjectRestorable ( ) { const restorable = createRestorable ( ) ; return { ... restorable , createNew ( ) { return createObjectRestorable ( ) ; } , set ( obj , propName , val ) { const key = ` ${ propName } ` ; restorable . once ( key , ( ) => { const oldVal = obj [ propName ] ; return ( propName in obj ) ? restorable . pushUndo ( ( ) => obj [ propName ] = oldVal ) : restorable . pushUndo ( ( ) => delete obj [ propName ] ) ; } ) ; obj [ propName ] = val ; } } ; }
Creates a Restorable which can track object property assignments (e.g.
Creates a Restorable which can track object property assignments ( e . g .
// Tracks property assignment // Only want to execute this once, the first time property is set // If property existed, then we will reset it to original value, // otherwise we will delete it // Perform the actual property assignment