duplichar
Duplicate characters that are substrings of a string
Install
Node
npm install --save duplichar
Web
Alternatively, you can install the npm module and reference the bundle within node_modules
Usage
// Remove this require line if you're using the web bundle (it's already bundled as "duplichar")const duplichar = ; ;//=> 'hhhackathons' ;//=> 'hahahackathons'
API
duplichar(str, index(s), multiplier)
str
Type: string
Description: String to duplicate part of
index
Type: number
|| array
|| string
Description: Index(s) of what to duplicate. Operate with slice() style indexing.
Examples:
1
: duplicate character at index 1'1'
: duplicate character at index 1[0, 2]
: duplicate substring containing characters at index 0 and 1.[-2]
: duplicate substring containing characters at index -2 and -1. (read the slice documentation to understand more advanced slices like this)
multiplier
Type: number
|| string
Description: Amount of times you would like the selected character or substring duplicated.
returns
Type: string
License
MIT © Dawson Botsford