Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bytes

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytes - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

11

History.md

@@ -0,6 +1,15 @@

2.0.1 / 2015-05-07
==================
* fix browserify require
* remove node.extend dependency
2.0.0 / 2015-04-12
==================
* rewrite to fix a few issues, see: https://github.com/visionmedia/bytes.js/pull/20#issuecomment-92121650
* add option "case"
* add option "thousandsSeparator"
* return "null" on invalid parse input
* support proper round-trip: bytes(bytes(num)) === num
* units no longer case sensitive when parsing

@@ -7,0 +16,0 @@ 1.0.0 / 2014-05-05

4

index.js
'use strict';
var convertFunction = require(__dirname + '/lib/byte-convert.js');
var parseFunction = require(__dirname + '/lib/byte-parse.js');
var convertFunction = require('./lib/byte-convert.js');
var parseFunction = require('./lib/byte-parse.js');

@@ -6,0 +6,0 @@ /**

'use strict';
var extend = require('node.extend');
/**
* Default options.
*
* @type {{case: string|null, thousandsSeparator: string|null}}
*/
var defaultOptions = {
thousandsSeparator: ''
};
/**
* Convert the value given in bytes into bytes, KB, MB, GB or TB.

@@ -67,10 +55,9 @@ *

options = extend({}, defaultOptions, options);
var converterResult = convertValue(value);
var convertedValue = converterResult.value;
var thousandsSeparator = (options && options.thousandsSeparator) || '';
var unit = converterResult.unit;
if (options.thousandsSeparator) {
convertedValue = convertedValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, options.thousandsSeparator);
if (thousandsSeparator) {
convertedValue = convertedValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
}

@@ -77,0 +64,0 @@

{
"name": "bytes",
"version": "2.0.0",
"version": "2.0.1",
"description": "Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.",

@@ -28,7 +28,4 @@ "keywords": [

"scripts": {
"test": "node_modules/mocha/bin/mocha --check-leaks"
"test": "mocha --check-leaks --reporter spec"
},
"dependencies": {
"node.extend": "*"
},
"devDependencies": {

@@ -67,3 +64,10 @@ "chai": "*",

],
"files": [
"lib/",
"History.md",
"LICENSE",
"Readme.md",
"index.js"
],
"license": "MIT"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc