Skip to content

Commit bef2930

Browse files
author
gregs
committed
string utilities for shell
1 parent 16a811b commit bef2930

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shell/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ String.prototype.rtrim = function() {
316316
return this.replace(/\s+$/,"");
317317
}
318318

319+
String.prototype.startsWith = function (str){
320+
return this.indexOf(str) == 0
321+
}
322+
323+
String.prototype.endsWith = function (str){
324+
return new RegExp( str + "$" ).test( this )
325+
}
326+
319327
Number.prototype.zeroPad = function(width) {
320328
var str = this + '';
321329
while (str.length < width)

0 commit comments

Comments
 (0)