# Changelog

## 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stash-it.gitbook.io/stash-it/changelog.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
