knot
nthIndex
Slice a string by counted delimiters
Usage
expect(
nthIndex('/', -5, 'a/b/c/d/e/f/g/h/i/j')
).toEqual("f/g/h/i/j")
expect(
nthIndex('/', 5, 'a/b/c/d/e/f/g/h/i/j')
).toEqual("a/b/c/d/e")
strepeat
A simple memoized utility for repeating a string and joining the array.
Usage
expect(strepeat('=', 5)).toEqual('=====')
expect(strepeat('/', -1)).toEqual('')
capitalize
Capitalize a string
Usage
expect(capitalize("nice")).toEqual("Nice")
expect(capitalize("")).toEqual("")
slugWord
Take PascalCase and kebabCase inputs and replace them with slug-case
Usage
expect(slugWord('CoolFuckingShit')).toEqual('cool-fucking-shit')
expect(slugWord('hoorayNiceLife')).toEqual('hooray-nice-life')
expect(slugWord('Do nothingCool ever')).toEqual('do nothing-cool ever')
expect(
slugWord('src/components/homepage/AugmentedDetailsDumbComponent')
).toEqual(
'src-components-homepage-augmented-details-dumb-component'
)