<commit_before>import Emitter from './emitter'
import History from './history'
import tag from './tag'
import { ACTION_STATES } from './constants'
import { inherit } from './utils'

/**
 * Actions encapsulate the process of resolving an action
 * creator. Create an action using `Microcosm::push`:
 */
export default function Action (command, history, status) {
  Emitter.call(this)

  this.history = history || new History()

  this.id = this.history.getId()
  this.command = tag(command)
  this.status = status || 'inactive'
}

inherit(Action, Emitter, {
  status     : 'inactive',
  payload    : undefined,
  disabled   : false,
  disposable : false,
  parent     : null,
  first      : null,
  next       : null,
  sibling    : null,

  is (type) {
    return this.command[this.status] === this.command[type]
  },

  toggle () {
    this.disabled = !this.disabled

    this.history.reconcile(this)

    return this
  },

  then (pass, fail) {
    return new Promise((resolve, reject) => {
      this.onDone(resolve)<commit_msg>Only assign status if it is provided to constructor<commit_after>import Emitter from './emitter'
import History from './history'
import tag from './tag'
import { ACTION_STATES } from './constants'
import { inherit } from './utils'

/**
 * Actions encapsulate the process of resolving an action
 * creator. Create an action using `Microcosm::push`:
 */
export default function Action (command, history, status) {
  Emitter.call(this)

  this.history = history || new History()

  this.id = this.history.getId()
  this.command = tag(command)

  if (status) {
    this.status = status
  }
}

inherit(Action, Emitter, {
  status     : 'inactive',
  payload    : undefined,
  disabled   : false,
  disposable : false,
  parent     : null,
  first      : null,
  next       : null,
  sibling    : null,

  is (type) {
    return this.command[this.status] === this.command[type]
  },

  toggle () {
    this.disabled = !this.disabled

    this.history.reconcile(this)

    return this
  },

  then (pass, fail) {
    return new Promise((resolve, reject) => {
      this.onDone(resolve)
{'fraction_non_alphanumeric': 0.12802275960170698, 'fraction_numerical': 0.0, 'mean_word_length': 3.0267175572519083, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1247684', 'n_tokens_mistral': 669, 'n_tokens_neox': 640, 'n_words': 188}