Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.ensureLeft

ensureLeft($prefix) -> string

Description

Add $prefix to the beginning of the string if it does not already exist.

'throwbackthursday'.ensureLeft('#')
//= '#throwbackthursday'

'#throwbackthursday'.ensureLeft('#')
//= '#throwbackthursday'

See Also