<commit_before>import Color from './color';
import {CMYK} from './space';

const KEY = Object.freeze({
  'C': Symbol.for('c'),
  'M': Symbol.for('m'),
  'Y': Symbol.for('y'),
  'K': Symbol.for('k')
});

export default class Cmyk extends Color {
  constructor(c, m, y, k) {
    super(CMYK, [[KEY.C, c], [KEY.M, m], [KEY.Y, y], [KEY.K, k]]);
  }

  toBytes() {
    let k = this.k();
    if (k === 1) {
      return [0, 0, 0, 0];
    }
    return [
      Math.floor(0xFF * (1 - this.c()) * (1 - k)),
      Math.floor(0xFF * (1 - this.m()) * (1 - k)),
      Math.floor(0xFF * (1 - this.y()) * (1 - k)),
      0
    ];
  }

  isValid() {
    for (let value of this.values()) {
      if (!Number.isFinite(value)) {
        return false;
      }
      if (value < 0 || value > 1) {
        return false;
      }
    }
    return true;
  }

  c(value = null) {
    return this.access(KEY.C, value);
  }

  m(value = null) {
    return this.access(KEY.M, value);
  }

  y(value = null) {
    return this.access(KEY.Y, value);
  }

  k(value = null) {<commit_msg>Added color space conversion method in CMYK<commit_after>import Color from './color';
import {CMYK} from './space';
import toRgb from '../converter/rgb';
import toHsl from '../converter/hsl';
import toHsv from '../converter/hsv';
import toCmy from '../converter/cmy';

const KEY = Object.freeze({
  'C': Symbol.for('c'),
  'M': Symbol.for('m'),
  'Y': Symbol.for('y'),
  'K': Symbol.for('k')
});

export default class Cmyk extends Color {
  constructor(c, m, y, k) {
    super(CMYK, [[KEY.C, c], [KEY.M, m], [KEY.Y, y], [KEY.K, k]]);
  }

  toBytes() {
    let k = this.k();
    if (k === 1) {
      return [0, 0, 0, 0];
    }
    return [
      Math.floor(0xFF * (1 - this.c()) * (1 - k)),
      Math.floor(0xFF * (1 - this.m()) * (1 - k)),
      Math.floor(0xFF * (1 - this.y()) * (1 - k)),
      0
    ];
  }

  isValid() {
    for (let value of this.values()) {
      if (!Number.isFinite(value)) {
        return false;
      }
      if (value < 0 || value > 1) {
        return false;
      }
    }
    return true;
  }

  rgb() {
    return toRgb(this);
  }

  hsl() {
    return toHsl(this);
  }

  hsv() {
    return toHsv(this);
  }

  cmy() {
    return toCmy(this);
  }

  cmyk() {
    return this;
  }

  c(value = null) {
    return this.access(KEY.C, value);
  }

  m(value = null) {
    return this.access(KEY.M, value);
  }

  y(value = null) {
    return this.access(KEY.Y, value);
  }

  k(value = null) {
{'fraction_non_alphanumeric': 0.20791279773920066, 'fraction_numerical': 0.013726281792490917, 'mean_word_length': 2.116981132075472, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1500916', 'n_tokens_mistral': 1012, 'n_tokens_neox': 981, 'n_words': 243}