diff --git a/voca/index.d.ts b/voca/index.d.ts index 7a7fa6e6c5..95703b49ad 100644 --- a/voca/index.d.ts +++ b/voca/index.d.ts @@ -80,6 +80,8 @@ declare namespace v { reverseGrapheme(subject?: string): string; slugify(subject?: string): string; splice(subject?: string, start?: number, deleteCount?: number, toAdd?: string): string; + tr(subject?: string, from?: string, to?: string): string; + tr(subject?: string, from?: { [key: string]: string }): string; trim(subject?: string, whitespace?: string): string; trimLeft(subject?: string, whitespace?: string): string; trimRight(subject?: string, whitespace?: string): string; @@ -177,6 +179,8 @@ declare namespace v { reverseGrapheme(): Chain; slugify(): Chain; splice(start?: number, deleteCount?: number, toAdd?: string): Chain; + tr(from?: string, to?: string): Chain; + tr(from?: { [key: string]: string }): Chain; trim(whitespace?: string): Chain; trimLeft(whitespace?: string): Chain; trimRight(whitespace?: string): Chain; @@ -270,6 +274,8 @@ declare namespace v { reverseGrapheme(): ExplicitChain; slugify(): ExplicitChain; splice(start?: number, deleteCount?: number, toAdd?: string): ExplicitChain; + tr(from?: string, to?: string): ExplicitChain; + tr(from?: { [key: string]: string }): ExplicitChain; trim(whitespace?: string): ExplicitChain; trimLeft(whitespace?: string): ExplicitChain; trimRight(whitespace?: string): ExplicitChain; diff --git a/voca/voca-tests.ts b/voca/voca-tests.ts index 3fb9d100c3..532f7861a3 100644 --- a/voca/voca-tests.ts +++ b/voca/voca-tests.ts @@ -214,6 +214,23 @@ str = v.splice('new year', 0); str = v.splice('new year', 0, 4); str = v.splice('new year', 0, 3, 'happy'); +str = v.tr(); +str = v.tr('hello', 'el', 'ip'); +str = v.tr('Yes. The fire rises.', { + 'Yes': 'Awesome', + 'fire': 'flame' +}) +str = v('hello').tr('el', 'ip').value(); +str = v('Yes. The fire rises.').tr({ + 'Yes': 'Awesome', + 'fire': 'flame' +}).value(); +str = v.chain('hello').tr('el', 'ip').value(); +str = v.chain('Yes. The fire rises.').tr({ + 'Yes': 'Awesome', + 'fire': 'flame' +}).value(); + str = v.trim(); str = v.trim(' Mother nature '); str = v.trim('--Earth--', '-');