duplichar
v1.0.2
Published
Duplicate characters that are substrings of a string
Downloads
19
Maintainers
Readme
duplichar
Duplicate characters that are substrings of a string
Install
Node
npm install --save duplichar
Web
<script src="https://rawgit.com/dawsonbotsford/duplichar/master/bundle.js"></script>
Alternatively, you can install the npm module and reference the bundle within node_modules
<script src="<path to node_modules>/duplichar/bundle.js"></script>
Usage
// Remove this require line if you're using the web bundle (it's already bundled as "duplichar")
const duplichar = require('duplichar');
duplichar('hackathons', 0, 3);
//=> 'hhhackathons'
duplichar('hackathons', [0, 2], 3);
//=> '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