rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
60 lines (59 loc) • 928 B
JavaScript
class Size {
/**
* Initialize a new Size Class
* @since 8.0.0
*/
constructor(amount) {
this.amount = amount;
}
/**
* Use the provided amount as bytes
* @example
* ```
* size(10).b() // 10
* ```
* @since 8.0.0
*/
b() {
return this.amount;
}
/**
* Use the provided amount as kilobytes
* @example
* ```
* size(10).kb() // 10240
* ```
* @since 8.0.0
*/
kb() {
return this.amount * 1024;
}
/**
* Use the provided amount as megabytes
* @example
* ```
* size(10).mb() // 10485760
* ```
* @since 8.0.0
*/
mb() {
return this.amount * 1024 * 1024;
}
/**
* Use the provided amount as gigabytes
* @example
* ```
* size(10).gb() // 10737418240
* ```
* @since 8.0.0
*/
gb() {
return this.amount * 1024 * 1024 * 1024;
}
}
function size(amount) {
return new Size(amount);
}
export {
size as default
};