import { Command } from './command';
export class AddValueCmd extends Command {
    execute(options) {
        const { path } = options;
        const value = options.value;
        const array = this.store.get(path);
        if (!Array.isArray(array)) {
            console.error('Can\'t add value to store. The item found by path should be an array');
            return undefined;
        }
        this.store.set(path, [...array, value]);
        return () => {
            const modifiedArray = this.store.get(path);
            this.store.set(path, modifiedArray.slice(0, -1));
        };
    }
}
