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

collect.js

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collect.js - npm Package Compare versions

Comparing version 3.0.40 to 3.0.43

10

dist/methods/get.js
'use strict';
module.exports = function get(key, defaultValue) {
module.exports = function get(key) {
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (this.items[key] !== undefined) {

@@ -12,3 +14,7 @@ return this.items[key];

return defaultValue || null;
if (defaultValue !== null) {
return defaultValue;
}
return null;
};

22

dist/methods/sum.js
'use strict';
module.exports = function sum(key) {
return this.items.reduce(function (accumulator, current) {
if (key === undefined) {
return accumulator + current;
} else if (typeof key === 'function') {
return accumulator + key(current);
var total = 0;
if (key === undefined) {
for (var i = 0; i < this.items.length; i += 1) {
total += this.items[i];
}
} else if (typeof key === 'function') {
for (var _i = 0; _i < this.items.length; _i += 1) {
total += key(this.items[_i]);
}
} else {
for (var _i2 = 0; _i2 < this.items.length; _i2 += 1) {
total += this.items[_i2][key];
}
}
return accumulator + current[key];
}, 0);
return total;
};
{
"name": "collect.js",
"version": "3.0.40",
"version": "3.0.43",
"description": "Convenient and dependency free wrapper for working with arrays and objects.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

'use strict';
module.exports = function get(key, defaultValue) {
module.exports = function get(key, defaultValue = null) {
if (this.items[key] !== undefined) {

@@ -12,3 +12,7 @@ return this.items[key];

return defaultValue || null;
if (defaultValue !== null) {
return defaultValue;
}
return null;
};
'use strict';
module.exports = function sum(key) {
return this.items.reduce((accumulator, current) => {
if (key === undefined) {
return accumulator + current;
} else if (typeof key === 'function') {
return accumulator + key(current);
let total = 0;
if (key === undefined) {
for (let i = 0; i < this.items.length; i += 1) {
total += this.items[i];
}
} else if (typeof key === 'function') {
for (let i = 0; i < this.items.length; i += 1) {
total += key(this.items[i]);
}
} else {
for (let i = 0; i < this.items.length; i += 1) {
total += this.items[i][key];
}
}
return accumulator + current[key];
}, 0);
return total;
};
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