diff --git a/src/utils/string.js b/src/utils/string.js index 4f0d6ee5..a5e7dace 100644 --- a/src/utils/string.js +++ b/src/utils/string.js @@ -1,3 +1,5 @@ +import {map} from './common'; + /** * Return a function that accept one String parameter and returns result of replacing. * @@ -6,3 +8,15 @@ */ export const stringReplace = (searchValue, replaceValue) => str => str.replace(searchValue, replaceValue); + +let toTrue = map(true, i => i === 'true'); +let toFalse = map(false, i => i === 'false'); +const boolProcessors = [toTrue, toFalse]; + +export function stringToBoolean(string){ + return boolProcessors + .reduce( + (value, fn) => fn(value), + string + ); +} \ No newline at end of file