Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2017-01-27 14:54:11 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2017-01-30 00:29:25 -0500
commit3289e42003f311cb819a2b3ba20910a6e043902b (patch)
tree2959fe1572f6d4ffe9634ad458f1ea900b5fb46e
parent282c0acf54d9b21841cbf2c8299ced705765141c (diff)
downloadliza-3289e42003f311cb819a2b3ba20910a6e043902b.tar.gz
liza-3289e42003f311cb819a2b3ba20910a6e043902b.tar.bz2
liza-3289e42003f311cb819a2b3ba20910a6e043902b.zip
Update MemoryStore syntax to ES6
`#reduce` is much better. * src/store/MemoryStore.js: Update syntax. DEV-2296
-rw-r--r--src/store/MemoryStore.js23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/store/MemoryStore.js b/src/store/MemoryStore.js
index fccb895..02ca32c 100644
--- a/src/store/MemoryStore.js
+++ b/src/store/MemoryStore.js
@@ -81,7 +81,7 @@ module.exports = Class( 'MemoryStore' )
* @return {Promise.<Store>} promise to add item to store, resolving to
* self (for chaining)
*/
- 'virtual public add': function( key, value )
+ 'virtual public add'( key, value )
{
this._store[ key ] = value;
@@ -98,7 +98,7 @@ module.exports = Class( 'MemoryStore' )
*
* @return {Promise} promise for the key value
*/
- 'virtual public get': function( key )
+ 'virtual public get'( key )
{
return ( this._store[ key ] !== undefined )
? Promise.resolve( this._store[ key ] )
@@ -114,7 +114,7 @@ module.exports = Class( 'MemoryStore' )
* @return {Promise<Store>} promise to clear store, resolving to self
* (for chaining)
*/
- 'virtual public clear': function()
+ 'virtual public clear'()
{
this._store = {};
@@ -143,20 +143,15 @@ module.exports = Class( 'MemoryStore' )
*
* @return {Promise} promise of a folded value (final accumulator value)
*/
- 'public reduce': function( callback, initial )
+ 'public reduce'( callback, initial )
{
- var store = this._store;
+ const store = this._store;
return Promise.resolve(
- Object.keys( store )
- .map( function( key )
- {
- return [ key, store[ key ] ];
- } )
- .reduce( function( accum, values )
- {
- return callback( accum, values[ 1 ], values[ 0 ] );
- }, initial )
+ Object.keys( store ).reduce(
+ ( accum, key ) => callback( accum, store[ key ], key ),
+ initial
+ )
);
}
} );