Skip to content

Instantly share code, notes, and snippets.

@mateuszsokola
Last active October 31, 2017 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateuszsokola/4b5650ec26a379dc73b36d76dde0db8d to your computer and use it in GitHub Desktop.
Save mateuszsokola/4b5650ec26a379dc73b36d76dde0db8d to your computer and use it in GitHub Desktop.
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