Socket
Socket
Sign inDemoInstall

hoek

Package Overview
Dependencies
1
Maintainers
2
Versions
116
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

17

lib/index.js

@@ -223,2 +223,19 @@ // Load modules

// Convert an object key chain string ('a.b.c') to reference (object[a][b][c])
exports.reach = function (obj, chain) {
var path = chain.split('.');
var ref = obj;
path.forEach(function (level) {
if (ref) {
ref = ref[level];
}
});
return ref;
};
// Inherits a selected set of methods from an object, wrapping functions in asynchronous syntax and catching errors

@@ -225,0 +242,0 @@

2

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

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

@@ -229,2 +229,51 @@ // Load modules

describe('#reach', function () {
var obj = {
a: {
b: {
c: {
d: 1,
e: 2
},
f: 'hello',
},
g: {
h: 3
}
},
i: function () { }
};
it('returns a valid member', function (done) {
expect(Hoek.reach(obj, 'a.b.c.d')).to.equal(1);
done();
});
it('returns null on null object', function (done) {
expect(Hoek.reach(null, 'a.b.c.d')).to.not.exist;
done();
});
it('returns null on missing member', function (done) {
expect(Hoek.reach(obj, 'a.b.c.d.x')).to.not.exist;
done();
});
it('returns null on invalid member', function (done) {
expect(Hoek.reach(obj, 'a.b.c.d-.x')).to.not.exist;
done();
});
it('returns function member', function (done) {
expect(typeof Hoek.reach(obj, 'i')).to.equal('function');
done();
});
});
describe('#inheritAsync', function () {

@@ -231,0 +280,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