partial.js logo
Latest version
v1.3.1 (RC2)

String.prototype


String prototype is available in each node.js / partial.js script. Prototypes are defined in FrameworkUtils (utils.js). FrameworkUtils is a global variable.

Methods


String.prototype.base64ContentType()String.prototype.base64ToFile(filename, [callback])String.prototype.configuration()String.prototype.contains(value, [mustAll])String.prototype.count(word)String.prototype.decode()String.prototype.decrypt(key)String.prototype.encode()String.prototype.encrypt(key, [unique])String.prototype.format([param..1], [param..2], [param..n])String.prototype.fromUnicode()String.prototype.isBoolean()String.prototype.isEmail()String.prototype.isJSON()String.prototype.isURL()String.prototype.link([max])String.prototype.max(maxLength, [chars])String.prototype.md5([salt])String.prototype.padLeft(max, [char])String.prototype.padRight(max, [char])String.prototype.params(obj)String.prototype.parseDate()String.prototype.parseFLoat([def])String.prototype.parseInt([def])String.prototype.pluralize(zero, one, few, other)String.prototype.removeDiacritics()String.prototype.sha1([salt])String.prototype.sha256([salt])String.prototype.sha512([salt])String.prototype.toUnicode()String.prototype.trim()String.prototype.urlDecode()String.prototype.urlEncode()
String.prototype.base64ContentType();
return String;

Get content type from base64 string. Example of string: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...

String.prototype.base64ToFile(filename, [callback]);
return String;

Parse base64 to buffer and save to file.

String.prototype.configuration();
return Object;

Parse configuration from a string (same configuration as framework configuration)

String.prototype.contains(value, [mustAll]);
return Boolean;

Check if this string contain a value.

String.prototype.count(word);
return String;

Word counter.

String.prototype.decode();
return String;

Decode string from HTML safe characters.

String.prototype.decrypt(key);
return String;

Decrypt encoded string by the key.

String.prototype.encode();
return String;

Encode string to HTML safe characters.

String.prototype.encrypt(key, [unique]);
return String;

Encrypt string by the key.

String.prototype.format([param..1], [param..2], [param..n]);
return Object;

Formatting string like C#. Example: 'My name is {0} {1}'.format('Peter', 'Širka');

String.prototype.fromUnicode();
return String;

Load string from unicode HTML characters.

String.prototype.isBoolean();
return String;

Check is boolean type.

String.prototype.isEmail();
return Boolean;

Check if this string is valid e-mail address.

String.prototype.isJSON();
return Boolean;

Check if this string is valid JSON.

String.prototype.isURL();
return Boolean;

Check if this string is valid URL address.

return String;

Create link (URL address) from this string. Example: 'partial.js - web application framework for node.js'.link(),
result: 'partial-js-web-application-framework-for-node-js'

String.prototype.max(maxLength, [chars]);
return String;

Set maximum length of string.

String.prototype.md5([salt]);
return String;

Convert string to MD5.

String.prototype.padLeft(max, [char]);
return String;

Character padding - left.

String.prototype.padRight(max, [char]);
return String;

Character padding - right.

String.prototype.params(obj);
return String;

Simple string formatting like template formatting (keys are represent properties). Example:
'My name is {name} and I was born: {birthday | dd.MM.yyyy}'.params({ name: 'Peter', birthdate: new Date() })

String.prototype.parseDate();
return Date;

Parse date from this string.

String.prototype.parseFLoat([def]);
return Number;

Parse float number from string.

String.prototype.parseInt([def]);
return Number;

Parse int number from string.

String.prototype.pluralize(zero, one, few, other);
return String;

Pluralize string. This string is converted into the Number and then is pluralized.

String.prototype.removeDiacritics();
return String;

Remove diacritics from string.

String.prototype.sha1([salt]);
return String;

Convert string to SHA1.

String.prototype.sha256([salt]);
return String;

Convert string to SHA256.

String.prototype.sha512([salt]);
return String;

Convert string to SHA512.

String.prototype.toUnicode();
return String;

Convert string to unicode HTML characters.

String.prototype.trim();
return String;

Trim white characters.

String.prototype.urlDecode();
return String;

Decode string from URL safe characters.

String.prototype.urlEncode();
return String;

Encode string to URL safe characters.