Socket
Socket
Sign inDemoInstall

hoek

Package Overview
Dependencies
Maintainers
2
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hoek - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

47

lib/hoek.js

@@ -132,20 +132,41 @@ // Load modules

if (array) {
var obj = {};
for (var i = 0, il = array.length; i < il; ++i) {
if (key) {
if (array[i][key]) {
obj[array[i][key]] = true;
}
if (!array) {
return null;
}
var obj = {};
for (var i = 0, il = array.length; i < il; ++i) {
if (key) {
if (array[i][key]) {
obj[array[i][key]] = true;
}
else {
obj[array[i]] = true;
}
}
else {
obj[array[i]] = true;
}
}
return obj;
return obj;
};
// Find the common unique items in two arrays
exports.intersect = function (array1, array2) {
if (!array1 || !array2) {
return [];
}
else {
return null;
var common = [];
var hash = exports.mapToObject(array1);
var found = {};
for (var i = 0, il = array2.length; i < il; ++i) {
if (hash[array2[i]] && !found[array2[i]]) {
common.push(array2[i]);
found[array2[i]] = true;
}
}
return common;
};

@@ -152,0 +173,0 @@

{
"name": "hoek",
"description": "General purpose node utilities",
"version": "0.0.11",
"version": "0.0.12",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",

@@ -6,0 +6,0 @@ "contributors":[

@@ -80,2 +80,14 @@ var assert = require('assert');

describe('#intersect', function () {
it('should return the common objects of two arrays', function (done) {
var array1 = [1, 2, 3, 4, 4, 5, 5];
var array2 = [5, 4, 5, 6, 7];
var common = Hoek.intersect(array1, array2);
common.length.should.equal(2);
done();
});
});
describe('#removeKeys', function () {

@@ -82,0 +94,0 @@

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