RHeactorJS/bdd-contexts

View on GitHub
src/util/storage.js

Summary

Maintainability
A
35 mins
Test Coverage
import _template from 'lodash/template'
 
Function `storage` has 5 arguments (exceeds 4 allowed). Consider refactoring.
function storage (store, defaults, context, name, value) {
if (!context[store]) {
context[store] = defaults
}
if (value === undefined) {
if (name === undefined) {
return context[store]
}
return context[store][name]
}
context[store][name] = value
}
 
export const utils = {
template: (str, data) => {
return _template(str, {interpolate: /\{([\s\S]+?)\}/g})(data)
},
header: storage.bind(null, 'header', {}),
data: storage.bind(null, 'data', {time: Date.now()})
}