1.0.1 • Published 7 years ago

crnt-util v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

String.Format(text, ...variables)

text: Any text to be joined with variables variables: variables separated by coma as many as you want.

This method join string with variables based replacing {n} by the variables set. N must start from zero and up to the maximum variables provided, eg:

var message = String.Format('Number: {0}, Text: {1}', 123, 'abc');

The result for message would be: Number: 123, Text: abc

You can also reuse the same N along the message, eg:

var message = String.Format('Number: {0}, Text: {1}, Number: {0}', 123, 'abc');

The result for message in this case would be: Number: 123, Text: abc, Number: 123

Object.Merge(obj1, obj2)

Merge obj2 into obj1, eg:

var obj1 = { a: 1, b: 2 };

var obj2 = { b: 3, c: 4 };

Object.Merge(obj1, obj2);

The result for obj1 would be:

{ a: 1, b: 3, c: 4 }

String.prototype.pad(pad, total, toRight)

Add padding to the String.

pad: texto to be added total: total of the size expected toRight: Add the pad on the right side of the String

var number = 1; var text = number.toString().pad('0',5)

Result for text: 00001