From 0812aa52d457dcc2b226a9046954a63b5c8beaa0 Mon Sep 17 00:00:00 2001 From: Vladimir Smyshlyaev Date: Thu, 29 Sep 2016 12:35:19 +0300 Subject: [PATCH] refactor: reduce options mutations with reduce --- src/Bundle.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Bundle.js b/src/Bundle.js index 2f4b0f9..b4dda83 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -31,11 +31,10 @@ export default class Bundle { this.plugins = ensureArray( options.plugins ); - this.plugins.forEach( plugin => { - if ( plugin.options ) { - options = plugin.options( options ) || options; - } - }); + options = this.plugins.reduce( ( acc, plugin ) => { + if ( plugin.options ) return plugin.options( acc ) || acc; + return acc; + }, options); this.entry = options.entry; this.entryId = null;