UNPKG
suffix
Version:
latest (1.0.0)
1.0.0
0.1.1
0.1.0
Add suffix to a filename.
egoist/suffix
suffix
/
index.js
12 lines
(9 loc)
•
254 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
module
.
exports
=
function
(
filename, suffix
) {
if
(
typeof
filename !==
'string'
) {
throw
new
TypeError
(
'Expected a string as filename'
) }
if
(!suffix) {
return
filename }
return
filename.
replace
(
/(\.[a-zA-Z0-9]+)?$/
, suffix +
'$1'
) }