<commit_before>'use strict';

const { parallelResolve } = require('./parallel');
const { serialResolve } = require('./serial');

// Add `action.currentData`, i.e. current models for the write actions about
// to be fired.
// Also adds `action.dataPaths` for `patch` and `delete` commands.
const addCurrentData = function ({ top: { command }, ...rest }, nextLayer) {
  const resolver = resolvers[command.type];
  if (resolver === undefined) { return; }

  return resolver(rest, nextLayer);
};

// `find` and `create` commands do not use `currentData`
// `patch` and `delete` use `args.filter|id` so need to be run serially, waiting
// for their parent.
// But `replace` can be run in parallel.
const resolvers = {
  create: parallelResolve,
  replace: parallelResolve,
  patch: serialResolve,
  delete: serialResolve,
};

module.exports = {
  addCurrentData,
};<commit_msg>Update comment<commit_after>'use strict';

const { parallelResolve } = require('./parallel');
const { serialResolve } = require('./serial');

// Add `action.currentData`, i.e. current models for the write actions about
// to be fired.
// Also adds `action.dataPaths` for `patch` and `delete` commands.
const addCurrentData = function ({ top: { command }, ...rest }, nextLayer) {
  const resolver = resolvers[command.type];
  if (resolver === undefined) { return; }

  return resolver(rest, nextLayer);
};

// `find` command does not need `currentData`
// `patch` and `delete` use `args.filter|id` so need to be run serially,
// waiting for their parent.
// But `create` and `replace` can be run in parallel.
const resolvers = {
  create: parallelResolve,
  replace: parallelResolve,
  patch: serialResolve,
  delete: serialResolve,
};

module.exports = {
  addCurrentData,
};
{'fraction_non_alphanumeric': 0.14310246136233543, 'fraction_numerical': 0.0, 'mean_word_length': 4.111111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3942957', 'n_tokens_mistral': 514, 'n_tokens_neox': 519, 'n_words': 177}