<commit_before>/**
 * @file Image Puzzle - puzzle game factory
 * @author StefanoMagrassi <<EMAIL>>
 */

// Imports
// -------
import _partial from 'lodash/partial';
import puzzle from './lib/puzzle';

// Exports
// -------
export default imagePuzzle;

// Constants
// ---------
/**
 * @constant {number} DEFAULT_ROWS - Default number of rows
 * @public
 */
export const DEFAULT_ROWS = 3;
/**
 * @constant {number} DEFAULT_COLS - Default number of columns
 * @public
 */
export const DEFAULT_COLS = 3;

// Public methods
// --------------
function imagePuzzle(image = null, rows = DEFAULT_ROWS, cols = DEFAULT_COLS) {
  if (image === null) {
    return null;
  }

  return {
    image : image,
    rows  : rows,
    cols  : cols,
    run   : run(image, rows, cols),
    update: update(image, rows, cols)
  };
}

// Private methods
// ---------------
function run(image, rows, cols) {
  return _partial(puzzle.run, image, rows, cols);
}

function update(image, rows, cols) {
  return _partial(puzzle.update, image, rows, cols);
}
<commit_msg>start factory<commit_after>/**
 * @file Image Puzzle - puzzle game factory
 * @author StefanoMagrassi <<EMAIL>>
 */

// Imports
// -------
import _partial from 'lodash/partial';
import puzzle from './lib/puzzle';

// Exports
// -------
export default imagePuzzle;

// Constants
// ---------
/**
 * @constant {number} DEFAULT_ROWS - Default number of rows
 * @public
 */
export const DEFAULT_ROWS = 3;
/**
 * @constant {number} DEFAULT_COLS - Default number of columns
 * @public
 */
export const DEFAULT_COLS = 3;

// Public methods
// --------------
function imagePuzzle(image = null, rows = DEFAULT_ROWS, cols = DEFAULT_COLS) {
  if (image === null) {
    return null;
  }

  return start({
    image: image,
    rows : rows,
    cols : cols
  });
}

// Private methods
// ---------------
/**
 * Creates a new image puzzle object with specified options.
 * @param  {object} opts - Options object
 * @return {object} Image puzzle object
 */
function start(opts) {
  return {
    run   : run(opts),
    update: update(opts)
  };
}

/**
 * Runs the puzzle with specified options.
 * @param  {object} opts - Options object
 * @return {function} Partially applied run function
 */
function run(opts) {
  let {image, rows, cols} = opts;

  return _partial(puzzle.run, image, rows, cols);
}

/**
 * Updates the puzzle pieces.
 * @param  {object} opts - Options object
 * @return {function} Partially applied update function
 */
function update(opts) {
  let {image, rows, cols} = opts;

  return _partial(puzzle.update, image, rows, cols);
}

{'fraction_non_alphanumeric': 0.17145073700543056, 'fraction_numerical': 0.0015515903801396431, 'mean_word_length': 2.710791366906475, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5224888', 'n_tokens_mistral': 843, 'n_tokens_neox': 812, 'n_words': 252}