This is a porting of "typescript-string-operations" (https://github.com/sevensc/typescript-string-operations) adapted to work correctly with angular 4 and above
jQuery required. Unit tested (work in progress).
USAGE:
String.Empty
;
String.IsNullOrWhiteSpace():
;ifString.IsNullOrWhiteSpaceid return image;
String.Format():
String.Format"image_{0}.jpg", idoutput: "image_2db5da20-1c5d-4f1a-8fd4-b41e34c8c5b5.jpg";
Specifier available!
; //output "apple" value = String.Format"{0:U}", "apple"; // output "APPLE" value = String.Format"{0:d}", "2017-01-23 00:00"; //output "23.01.2017" value = String.Format"{0:s}", "21.03.2017 22:15:01" //output "2017-03-21T22:15:01" value = String.Format"{0:n}", 1000000;//output "1.000.000"
Specifier | Result |
---|---|
L |
LowerCase |
U |
UpperCase |
d |
ShortDatePattern |
s |
SortableDateTimePattern |
n |
Thousand seperator |
String.Join():
;//output: "Apple; Banana";
OR
var array = ['Apple', 'Banana']var value = String.Join("; ", array);//output: "Apple; Banana";
Methods
Method | Type | Description | Parameter |
---|---|---|---|
Empty |
Property |
simply returns "" . |
|
IsNullOrWhiteSpace |
Method |
returns true value if given parameter is either null, empty or undefined. | format , args |
Format |
Method |
Converts the value of objects to strings based on the formats specified and inserts them into another string. | format , args |
Join |
Method |
Combines arguments delimited by given seperator. | delimiter ,args |
Join |
Method |
Combines arguments delimited by given seperator from array. | delimiter ,array |