<commit_before># API Cheatsheet

## Microcosm

Life Cycle
+--------------+
start - Resets initial state, installs all plugins, and then executes a callback

Data Operations
+--------------+
clone  - Return a new object whose prototype is the last state
commit - Assign a new state, trigger an event
funnel - Commit the result of deserializing a set of data
get    - Provided a key, return that entry in the state object

Serialization
+--------------+
deserialize - Parse external data into an acceptable format
serialize   - Convert internal data into an acceptable external format
toJSON      - Serialize to JSON (calls `serialize` by default)
toObject    - Return a flat copy of the latest revision of state

Message passing
+--------------+
dispatch - Send an action and payload to all stores
prepare  - Partially apply the `send` method
send     - Given a set of parameters, execute an action and forward that result to `dispatch`

Events
+--------------+

listen - Add a callback listener
ignore - Remove a callback listener
emit   - Trigger an event

Install
+--------------+
addPlugin - Append an entry into the list of known plugins
addStore  - Add an entry to the map of known stores

## Store

Identity
+--------------+
toString - Must return a unique string identifying which key this store manages in global state

Life Cycle
+--------------+
getInitialState - Determines the initial state required to operate. Called on `Microcosm::start`

Serialization
+--------------+
deserialize - Returns a cleaned object given external data for the managed key
serialize   - Returns a serialized object for the managed key

## Plugin

Life Cycle
+--------------+
register - setup behavior to execute for a plugin when `Microcosm::start` is executed<commit_msg>[fix] Spacing in readme<commit_after># API Cheatsheet

## Microcosm

```
Life Cycle
+--------------+
start - Resets initial state, installs all plugins, and then executes a callback

Data Operations
+--------------+
clone  - Return a new object whose prototype is the last state
commit - Assign a new state, trigger an event
funnel - Commit the result of deserializing a set of data
get    - Provided a key, return that entry in the state object

Serialization
+--------------+
deserialize - Parse external data into an acceptable format
serialize   - Convert internal data into an acceptable external format
toJSON      - Serialize to JSON (calls `serialize` by default)
toObject    - Return a flat copy of the latest revision of state

Message passing
+--------------+
dispatch - Send an action and payload to all stores
prepare  - Partially apply the `send` method
send     - Given a set of parameters, execute an action and forward that result to `dispatch`

Events
+--------------+
listen - Add a callback listener
ignore - Remove a callback listener
emit   - Trigger an event

Install
+--------------+
addPlugin - Append an entry into the list of known plugins
addStore  - Add an entry to the map of known stores
```

## Store

```
Identity
+--------------+
toString - Must return a unique string identifying which key this store manages in global state

Life Cycle
+--------------+
getInitialState - Determines the initial state required to operate. Called on `Microcosm::start`

Serialization
+--------------+
deserialize - Returns a cleaned object given external data for the managed key
serialize   - Returns a serialized object for the managed key
```

## Plugin

```
Life Cycle
+--------------+
register - setup behavior to execute for a plugin when `Microcosm::start` is executed
```
{'fraction_non_alphanumeric': 0.12587805563360493, 'fraction_numerical': 0.0, 'mean_word_length': 2.775185577942736, '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': '1156463', 'n_tokens_mistral': 847, 'n_tokens_neox': 831, 'n_words': 466}