From 024808fa0dfdac1b7c91cb9927e5d3892b2e2e1a Mon Sep 17 00:00:00 2001 From: Luca Martinetti Date: Wed, 12 Oct 2016 16:37:03 -0700 Subject: [PATCH] add stripLeft and stripRight --- string/index.d.ts | 4 ++++ string/string-tests.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/string/index.d.ts b/string/index.d.ts index dbf3120e09..9e4a28b709 100644 --- a/string/index.d.ts +++ b/string/index.d.ts @@ -72,6 +72,10 @@ interface StringJS { strip(...strings: string[]): StringJS; + stripLeft(...strings: string[]): StringJS; + + stripRight(...strings: string[]): StringJS; + right(n: number): StringJS; setValue(string: any): StringJS; diff --git a/string/string-tests.ts b/string/string-tests.ts index 9349551b18..64195738c4 100644 --- a/string/string-tests.ts +++ b/string/string-tests.ts @@ -164,6 +164,13 @@ S('Yes it does!').replaceAll(' ', '').s; //'Yesitdoes!' S(' 1 2 3--__--4 5 6-7__8__9--0').strip(' ', '_', '-').s; //'1234567890' S('can words also be stripped out?').strip('words', 'also', 'be').s; //'can stripped out?' +S(' hello ').stripLeft().s; //'hello ' +S('abcz').stripLeft('a-z').s; //'bcz' +S('www.example.com').stripLeft('w.').s; //'example.com' + +S(' hello ').stripRight().s; //' hello' +S('abcz').stripRight('a-z').s; //'abc' + S('I AM CRAZY').right(2).s; //'ZY' S('Does it work? ').right(4).s; //'k? ' S('Hi').right(0).s; //''