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

Number.prototype


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

Methods


Number.prototype.discount(percentage, [decimals])Number.prototype.floor(decimals)Number.prototype.format(format)Number.prototype.hex(length)Number.prototype.padLeft(max, [char])Number.prototype.padRight(max, [char])Number.prototype.parseDate([plus])Number.prototype.pluralize(zero, one, few, other)Number.prototype.VAT(percentage, [decimals], [includedVAT])
Number.prototype.discount(percentage, [decimals]);
return Number;

Discount calculator. Example: (100).VAT(20) == 80

Number.prototype.floor(decimals);
return Number;

Floor number. Example: (232.349).floor(2), result: 232.34

Number.prototype.format(format);
return String;

Formatting number. Example: (230230.34).format('### ###.##'), result: 230 230.34

Number.prototype.hex(length);
return String;

Number to hex format.

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

Character padding - left.

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

Character padding - right.

Number.prototype.parseDate([plus]);
return Number;

Parse date from number.

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

Pluralize number.

Number.prototype.VAT(percentage, [decimals], [includedVAT]);
return Number;

VAT calculator. Example: (100).VAT(20) == 83.33