Socket
Socket
Sign inDemoInstall

mout

Package Overview
Dependencies
0
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.3 to 1.2.4

4

index.js
/**@license
* mout v1.2.3 | http://moutjs.com | MIT license
* mout v1.2.4 | http://moutjs.com | MIT license
*/

@@ -9,3 +9,3 @@

module.exports = {
'VERSION' : '1.2.3',
'VERSION' : '1.2.4',
'array' : require('./array'),

@@ -12,0 +12,0 @@ 'collection' : require('./collection'),

var enforcePrecision = require('./enforcePrecision');
var _defaultDict = {
thousand : 'K',
million : 'M',
billion : 'B'
thousand: "K",
million: "M",
billion: "B",
};

@@ -12,4 +11,4 @@

*/
function abbreviateNumber(val, nDecimals, dict){
nDecimals = nDecimals != null? nDecimals : 1;
function abbreviateNumber(val, nDecimals, dict) {
nDecimals = nDecimals != null ? nDecimals : 1;
dict = dict || _defaultDict;

@@ -19,10 +18,16 @@ val = enforcePrecision(val, nDecimals);

var str, mod;
var negative = false;
if (val < 0) {
val = -val;
negative = true;
}
if (val < 1000000) {
mod = enforcePrecision(val / 1000, nDecimals);
// might overflow to next scale during rounding
str = mod < 1000? mod + dict.thousand : 1 + dict.million;
str = mod < 1000 ? mod + dict.thousand : 1 + dict.million;
} else if (val < 1000000000) {
mod = enforcePrecision(val / 1000000, nDecimals);
str = mod < 1000? mod + dict.million : 1 + dict.billion;
str = mod < 1000 ? mod + dict.million : 1 + dict.billion;
} else {

@@ -32,2 +37,6 @@ str = enforcePrecision(val / 1000000000, nDecimals) + dict.billion;

if (negative) {
str = "-" + str;
}
return str;

@@ -38,2 +47,1 @@ }

@@ -7,11 +7,12 @@ var namespace = require('./namespace');

function set(obj, prop, val){
var stringifiedProp = prop.toString();
// prototype pollution mitigation
if(prop.includes('__proto__') || prop.includes('prototype') || prop.includes('constructor')) {
if(stringifiedProp.includes('__proto__') || stringifiedProp.includes('prototype') || stringifiedProp.includes('constructor')) {
return false;
}
var parts = (/^(.+)\.(.+)$/).exec(prop);
var parts = (/^(.+)\.(.+)$/).exec(stringifiedProp);
if (parts){
namespace(obj, parts[1])[parts[2]] = val;
} else {
obj[prop] = val;
obj[stringifiedProp] = val;
}

@@ -18,0 +19,0 @@ }

{
"name": "mout",
"description": "Modular Utilities",
"version": "1.2.3",
"version": "1.2.4",
"homepage": "http://moutjs.com/",

@@ -41,3 +41,3 @@ "author": "Miller Medeiros <contact@millermedeiros.com> (http://blog.millermedeiros.com)",

"commander": "~2.16.0",
"handlebars": "~4.1.2",
"handlebars": "~4.7.7",
"istanbul": "~0.4.5",

@@ -44,0 +44,0 @@ "jasmine-node": "^1.15.0",

/**@license
* mout v1.2.3 | http://moutjs.com | MIT license
* mout v1.2.4 | http://moutjs.com | MIT license
*/

@@ -9,3 +9,3 @@ define(function(require){

return {
'VERSION' : '1.2.3',
'VERSION' : '1.2.4',
'array' : require('./array'),

@@ -12,0 +12,0 @@ 'collection' : require('./collection'),

@@ -1,7 +0,6 @@

define(['./enforcePrecision'], function (enforcePrecision) {
define(["./enforcePrecision"], function (enforcePrecision) {
var _defaultDict = {
thousand : 'K',
million : 'M',
billion : 'B'
thousand: "K",
million: "M",
billion: "B",
};

@@ -12,4 +11,4 @@

*/
function abbreviateNumber(val, nDecimals, dict){
nDecimals = nDecimals != null? nDecimals : 1;
function abbreviateNumber(val, nDecimals, dict) {
nDecimals = nDecimals != null ? nDecimals : 1;
dict = dict || _defaultDict;

@@ -19,10 +18,16 @@ val = enforcePrecision(val, nDecimals);

var str, mod;
var negative = false;
if (val < 0) {
val = -val;
negative = true;
}
if (val < 1000000) {
mod = enforcePrecision(val / 1000, nDecimals);
// might overflow to next scale during rounding
str = mod < 1000? mod + dict.thousand : 1 + dict.million;
str = mod < 1000 ? mod + dict.thousand : 1 + dict.million;
} else if (val < 1000000000) {
mod = enforcePrecision(val / 1000000, nDecimals);
str = mod < 1000? mod + dict.million : 1 + dict.billion;
str = mod < 1000 ? mod + dict.million : 1 + dict.billion;
} else {

@@ -32,2 +37,6 @@ str = enforcePrecision(val / 1000000000, nDecimals) + dict.billion;

if (negative) {
str = "-" + str;
}
return str;

@@ -37,3 +46,2 @@ }

return abbreviateNumber;
});

@@ -7,11 +7,12 @@ define(['./namespace'], function (namespace) {

function set(obj, prop, val){
var stringifiedProp = prop.toString();
// prototype pollution mitigation
if(prop.includes('__proto__') || prop.includes('prototype') || prop.includes('constructor')) {
if(stringifiedProp.includes('__proto__') || stringifiedProp.includes('prototype') || stringifiedProp.includes('constructor')) {
return false;
}
var parts = (/^(.+)\.(.+)$/).exec(prop);
var parts = (/^(.+)\.(.+)$/).exec(stringifiedProp);
if (parts){
namespace(obj, parts[1])[parts[2]] = val;
} else {
obj[prop] = val;
obj[stringifiedProp] = val;
}

@@ -18,0 +19,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc