Created
June 2, 2018 03:41
-
-
Save Tatsh/0b35bfc1b928b095d3a82dba13396e76 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 { | |
append, compose, curryN, join, length, partialRight, prepend, repeat, subtract, | |
} from 'ramda' | |
const pad = (str, n, char = ' ', _f = append) => compose(join(''), _f(str), repeat(char), subtract(n), length)(str) | |
const padStart = curryN(3, pad) | |
const padEnd = curryN(3, partialRight(pad, [prepend])) |
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 { | |
append, compose, curryN, join, length, partialRight, prepend, repeat, subtract, | |
} from 'ramda'; | |
const pad = (str: string, n: number, char = ' ', _f = append) => compose( | |
join(''), | |
_f(str), | |
repeat(char), | |
subtract(n), | |
length)(str); | |
const padStart = curryN(3, pad); | |
const padEnd = curryN(3, partialRight(pad, [prepend])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment