Last active
October 31, 2017 22:11
-
-
Save mateuszsokola/4b5650ec26a379dc73b36d76dde0db8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { curryRight, flow, join } from "lodash"; | |
import split from "./split"; | |
import reverse from "./reverse"; | |
/** | |
* Thousand Regular Expression | |
*/ | |
const thousandRegExp:RegExp = /[0-9]{1,3}/g; | |
/** | |
* @example splitCurry(RegExp)(string) | |
*/ | |
const splitCurry:Function = curryRight(split); | |
/** | |
* @example joinCurry(separator)(string) | |
*/ | |
const joinCurry:Function = curryRight(join); | |
export default function thousandSeparator(separator:string):Function { | |
return flow([ | |
reverse, | |
splitCurry(thousandRegExp), | |
joinCurry(separator), | |
reverse, | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment