BytesConverter source
Converts a numeric value to byte format (for example, 2048 is converted to 2MB).
Specializes Converter
Properties
-
allowPartialConversion :boolean source
-
Specifies whether the converter allows partial conversion.
Inherited From: Default Value: - true
-
decimals :Property source
-
The number of decimals to include in the formatted value. Default is 2.
Default Value: - {number} 2
Methods
-
convert(v) → {string} source
-
Converts the specified value to byte format.
Parameters:
Name Type Description v
Property The value to format.
Returns: string
The value converted to byte format.
Example
var Converter = require("./converter").Converter; var BytesConverter = require("./converter").BytesConverter; var bytes = "12341234"; var byteconverter = new BytesConverter(); console.log("Converted: " + byteconverter.convert(bytes)); console.log("Reverted: " + byteconverter.revert(bytes)); // Converted: 11.77MB // Reverted: 12341234
-
revert(v) → {string} source
-
Reverts a formatted byte string to a standard number.
Parameters:
Name Type Description v
string The value to revert.
See: Returns: string
v
Example
var Converter= require("./converter").Converter; var BytesConverter = require("./converter").BytesConverter; var bytes = "11.77MB"; var byteconverter = new BytesConverter(); console.log("Reverted: " + byteconverter.revert(bytes)); // Reverted: 12341234
Generated from v0.14.14