<commit_before># redux-storage-decorator-migrate

[![build](https://travis-ci.org/mathieudutour/redux-storage-decorator-migrate.svg)](https://travis-ci.org/mathieudutour/redux-storage-decorator-migrate)
[![dependencies](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate.svg)](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate)
[![devDependencies](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate/dev-status.svg)](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate#info=devDependencies)

[![license](https://img.shields.io/npm/l/redux-storage-decorator-migrate.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-migrate)
[![npm version](https://img.shields.io/npm/v/redux-storage-decorator-migrate.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-migrate)
[![npm downloads](https://img.shields.io/npm/dm/redux-storage-decorator-migrate.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-migrate)

Migrate decorator for [redux-storage][] to version the storage with migration

## Installation

```bash
  npm install --save redux-storage-decorator-migrate
```

## Usage

Versioned storage with migrations.

```js
import migrate from 'redux-storage-decorator-migrate'

engine = migrate(engine, 3);
engine.addMigration(1, (state) => { /* migration step for 1 */ return state; });
engine.addMigration(2, (state) => { /* migration step for 2 */ return state; });
engine.addMigration(3, (state) => { /* migration step for 3 */ return state; });
```

## Testing migrations without a store (applying against ad-hoc state)

```js<commit_msg>add usage with filter decorator info to README.md<commit_after># redux-storage-decorator-migrate

[![build](https://travis-ci.org/mathieudutour/redux-storage-decorator-migrate.svg)](https://travis-ci.org/mathieudutour/redux-storage-decorator-migrate)
[![dependencies](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate.svg)](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate)
[![devDependencies](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate/dev-status.svg)](https://david-dm.org/mathieudutour/redux-storage-decorator-migrate#info=devDependencies)

[![license](https://img.shields.io/npm/l/redux-storage-decorator-migrate.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-migrate)
[![npm version](https://img.shields.io/npm/v/redux-storage-decorator-migrate.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-migrate)
[![npm downloads](https://img.shields.io/npm/dm/redux-storage-decorator-migrate.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-migrate)

Migrate decorator for [redux-storage][] to version the storage with migration

## Installation

```bash
  npm install --save redux-storage-decorator-migrate
```

## Usage

Versioned storage with migrations.

```js
import migrate from 'redux-storage-decorator-migrate'

engine = migrate(engine, 3);
engine.addMigration(1, (state) => { /* migration step for 1 */ return state; });
engine.addMigration(2, (state) => { /* migration step for 2 */ return state; });
engine.addMigration(3, (state) => { /* migration step for 3 */ return state; });
```

### Usage with `redux-storage-decorator-filter` and other decorators

```js
import * as storage from 'redux-storage'
import createEngine from 'redux-storage-engine-localstorage'
import filter from 'redux-storage-decorator-filter'
import debounce from 'redux-storage-decorator-debounce'
import migrate from 'redux-storage-decorator-migrate'

const reducer = storage.reducer(reducers)
const stateVersionProp = '_stateVersion'
const whitelist = [stateVersionProp]
const blacklist = []
const engine = migrate(
  debounce(
    filter(
      createEngine('your.storage.identifier'),
      whitelist,
      blacklist
    ), 1000
  ), 0
)

// Your first migration:
engine.addMigration(1, (state) => { /* migration step for 1 */ return state; });
```

## Testing migrations without a store (applying against ad-hoc state)

```js
{'fraction_non_alphanumeric': 0.16421154310553007, 'fraction_numerical': 0.005071238831200193, 'mean_word_length': 5.401854714064915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 24, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6900815', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1407, 'n_words': 212}