> For the complete documentation index, see [llms.txt](https://stash-it.gitbook.io/stash-it/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stash-it.gitbook.io/stash-it/changelog.md).

# Changelog

Changes since v2.0

## registerPlugins

There are three changes:

1. **registerPlugins** was imported from stash-it; now it is internally built into cacheInstance.
2. This method now takes one parameter: array of plugins.
3. Returned cacheInstance is freezed (using [Object.freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)), so that returned object is immutable.

Before:

```javascript
import { registerPlugins } from 'stash-it';

const cacheWithPlugins = registerPlugins(cache, [ plugin ]);
```

Now:

```javascript
const cacheWithPlugins = cache.registerPlugins([ plugin ]);
```

It felt more naturally that given cache instance should be able to register plugins on itself.

This method still returns newly created cache instance. Therefore:

```javascript
cacheWithPlugins === cache; // false
```

## getExtensions -> createExtensions

**getExtensions** was renamed to **createExtensions**. It also takes an object as an argument. That object is passed (by plugins):

* cacheInstance
* getPreData
* getPostData

Before:

```javascript
import { getPreData, getPostData } from 'stash-it';

// plugin's body
{
    getExtensions: (cacheInstnace) => {
        ...
    }
}
```

Now:

```javascript
// plugin's body
{
    createExtensions: ({ cacheInstance, getPreData, getPostData }) => {
        ...
    }
}
```

That happened because testing plugins against `getPreData` and `getPostData` was hard. Now, that they're passed as dependencies, it is trivial to stub them.

## key validation

Key validation happened in adapters (basic one). Now it is moved to stash-it, and is even simpler - checks if `key` is a string, throws otherwise. **If** any storage needs to validate this string further, given adapter should do it.

## bugfix with hooks

In stash-it v2, hooks are passed by reference, therefore registering more plugins (with hooks, one by one, not few at a time), registers them on all cache instances. Since v3 this is fixed and each plugin registering (that returns a new cache instance) sets hooks **only** on the newly returned instance.

## ES6

stash-it is still written in ES6, but also stays that way. It is about using the code that current environments use (be it node or browsers). Should you need ES5 code - you need to transpile it yourself.
