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