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.6 to 0.0.7

9

lib/hoek.js

@@ -26,3 +26,10 @@ // Load modules

if (obj.hasOwnProperty(i)) {
if (obj[i] && typeof obj[i] === 'object') {
if (obj[i] instanceof Date) {
newObj[i] = new Date(obj[i].getTime());
}
else if (obj[i] instanceof RegExp) {
var flags = '' + (obj[i].global ? 'g' : '') + (obj[i].ignoreCase ? 'i' : '') + (obj[i].multiline ? 'm' : '') + (obj[i].sticky ? 'y' : '');
newObj[i] = new RegExp(obj[i].source, flags);
}
else if (typeof obj[i] === 'object') {
newObj[i] = exports.clone(obj[i]);

@@ -29,0 +36,0 @@ }

2

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

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

@@ -0,0 +0,0 @@ hoek

@@ -6,88 +6,90 @@ var assert = require('assert');

describe("hoek", function(){
var emptyObj = {};
var nestedObj = {
x: 'x',
y: 'y'
}
var dupsArray = [nestedObj, {z:'z'}, nestedObj];
var reducedDupsArray = [nestedObj, {z:'z'}];
describe("#clone", function(){
it("should clone a nested object", function(done){
var a = nestedObj;
var b = hoek.clone(a);
assert.deepEqual(a, b);
done();
describe("hoek", function () {
var emptyObj = {};
var nestedObj = {
x: 'x',
y: 'y',
z: new Date()
}
var dupsArray = [nestedObj, { z: 'z' }, nestedObj];
var reducedDupsArray = [nestedObj, { z: 'z' }];
describe("#clone", function () {
it("should clone a nested object", function (done) {
var a = nestedObj;
var b = hoek.clone(a);
assert.deepEqual(a, b);
b.z.should.equal(a.z);
done();
})
})
})
describe("#merge", function(){
it("should", function(done){
var a = emptyObj;
var b = nestedObj;
var c = hoek.merge(a, b);
assert.deepEqual(a, b);
assert.deepEqual(c, b);
done();
describe("#merge", function () {
it("should", function (done) {
var a = emptyObj;
var b = nestedObj;
var c = hoek.merge(a, b);
assert.deepEqual(a, b);
assert.deepEqual(c, b);
done();
})
})
})
describe("#unique", function(){
it("should ensure uniqueness within array of objects based on subkey", function(done){
var a = hoek.unique(dupsArray, 'x');
assert.deepEqual(a, reducedDupsArray);
done();
describe("#unique", function () {
it("should ensure uniqueness within array of objects based on subkey", function (done) {
var a = hoek.unique(dupsArray, 'x');
assert.deepEqual(a, reducedDupsArray);
done();
})
})
})
describe("#mapToObject", function () {
it("should convert basic array to existential object", function(done){
var keys = [1,2,3,4];
var a = hoek.mapToObject(keys);
for(var i in keys){
a[keys[i]].should.equal(true);
}
done();
describe("#mapToObject", function () {
it("should convert basic array to existential object", function (done) {
var keys = [1, 2, 3, 4];
var a = hoek.mapToObject(keys);
for (var i in keys) {
a[keys[i]].should.equal(true);
}
done();
})
it("should convert array of objects to existential object", function (done) {
var keys = [{ x: 1 }, { x: 2 }, { x: 3 }];
var subkey = 'x';
var a = hoek.mapToObject(keys, subkey);
for (var i in keys) {
a[keys[i][subkey]].should.equal(true);
}
done();
})
})
it("should convert array of objects to existential object", function(done){
var keys = [{x:1}, {x:2}, {x:3}];
var subkey = 'x';
var a = hoek.mapToObject(keys, subkey);
for(var i in keys){
a[keys[i][subkey]].should.equal(true);
}
done();
})
})
describe("#removeKeys", function(){
var objWithHiddenKeys = {
location: {
name: 'San Bruno'
},
company: {
name: "@WalmartLabs"
}
}
it("should delete params with definition's hide set to true", function(done){
var a = hoek.removeKeys(objWithHiddenKeys, ['location']);
should.not.exist(objWithHiddenKeys.location);
should.exist(objWithHiddenKeys.company);
done();
describe("#removeKeys", function () {
var objWithHiddenKeys = {
location: {
name: 'San Bruno'
},
company: {
name: "@WalmartLabs"
}
}
it("should delete params with definition's hide set to true", function (done) {
var a = hoek.removeKeys(objWithHiddenKeys, ['location']);
should.not.exist(objWithHiddenKeys.location);
should.exist(objWithHiddenKeys.company);
done();
})
})
})
describe("#assert", function() {
it('should throw an Error when using assert in a test', function(done) {
(function() {
hoek.assert(false, 'my error message')
}).should.throw('my error message');
done();
describe("#assert", function () {
it('should throw an Error when using assert in a test', function (done) {
(function () {
hoek.assert(false, 'my error message')
}).should.throw('my error message');
done();
})
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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