UNPKG

rako

Version:

[![LICENSE](https://img.shields.io/badge/license-MIT%20(The%20996%20Prohibited%20License)-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)

24 lines (18 loc) 710 B
import Store from './Store' import {applyMiddleware} from './applyMiddleware' function _createStores(producers, middlewares) { if (producers.some(producer => typeof producer !== 'function')) { throw new TypeError("Expected every `producer` to be a function.") } return producers.map(producer => { const maturedMiddlewares = middlewares.map(middleware => middleware(producer)).filter(maturedMiddleware => maturedMiddleware !== null) return new Store(producer, maturedMiddlewares.length ? applyMiddleware(maturedMiddlewares) : undefined) }) } function createStores(...producers) { return _createStores(producers, []) } export { _createStores, createStores }