Closed fabienjuif closed 6 years ago
lodash:
So I guess this is OK to loop over path as you suggested @bpetetot
Something like you wrote:
const reducerPath = path.split('.')
const reducerName = reducerPath.pop()
const reducerLocation = reducerPath.reduce((acc, next) => acc[next], definitionWithDrivers)
reducerLocation[reducerName] = reducer
You can shorten this with
const [reducerName, reducerPath] = path.split('.')
No I dont think you can do that, because reducerName
will be the first element and reducerPath
the second element of the splitted array.
reducerName
must be the last element and reducerPath
the rest of the splitted array.
Ha, ok I didn't understand that ^^
Feel free to open a PR if you want to :) Just say it here (or assign issue yourself)
See : https://github.com/alakarteio/k-ramel/pull/127#discussion_r175028357