import Cookies from '../../3rd-libs/js-cookie';

const K_PREFIX = 'dmx_';

/**
 * 参考：https://www.npmjs.com/package/js-cookie
 */
export class MyCookie {
  constructor(key) {
    if (!key) {
      throw new Error('非法的key，无法创建cookie');
    }

    this.key = K_PREFIX + key;
  }

  get() {
    return Cookies.get(this.key);
  }

  set(value) {
    Cookies.set(this.key, value);
  }

  remove() {
    Cookies.remove(this.key);
  }
}
