add-ender
v1.0.0
Published
add a period to a string if it doesn't already end in one
Downloads
11
Readme
add-ender
Do you ever have this issue with your robots?
IKNORITE?
if only it had inserted a period there between the sentences that would have been a hot toot!
NOT ANYMORE
add-ender will check the last character or your string and see if it is .
or ?
or !
and if it is not it will append a .
to that string and return it unto you.
EXAMPLE
var addEnder = require('add-ender')
var str = 'wow it really works'
addEnder(str, '!')
// => 'wow it really works!'
// lets get more excited about this!
addEnder(str, '!').toUpperCase()
// => 'WOW IT REALLY WORKS!'
API
addEnder(str, ender || '.', reggie || /(\.|\?|\!)$/)
str: any string. probably the output of some sort of api call or text generator or twitter stream or idk. you know it is a "sentence" but it is possible it does not end with proper punctuation.
ender: any string. probably something like
.
or?
or!
.reggie: any reginald or regex. defaults to the
.
or?
or!
thing.