hoek
Advanced tools
Comparing version 2.5.1 to 2.6.0
@@ -66,3 +66,9 @@ // Load modules | ||
if (obj.hasOwnProperty(i)) { | ||
newObj[i] = exports.clone(obj[i], seen); | ||
var descriptor = Object.getOwnPropertyDescriptor(obj, i); | ||
if (descriptor.get) { | ||
Object.defineProperty(newObj, i, descriptor); | ||
} | ||
else { | ||
newObj[i] = exports.clone(obj[i], seen); | ||
} | ||
} | ||
@@ -609,2 +615,5 @@ } | ||
exports.format = Util.format; | ||
exports.transform = function (source, transform, options) { | ||
@@ -611,0 +620,0 @@ |
{ | ||
"name": "hoek", | ||
"description": "General purpose node utilities", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"repository": "git://github.com/hapijs/hoek", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -273,2 +273,25 @@ // Load modules | ||
}); | ||
it('clones an object with property getter without executing it', function (done) { | ||
var obj = {}; | ||
var value = 1; | ||
var execCount = 0; | ||
Object.defineProperty(obj, 'test', { | ||
enumerable: true, | ||
configurable: true, | ||
get: function () { | ||
++execCount; | ||
return value; | ||
} | ||
}); | ||
var copy = Hoek.clone(obj); | ||
expect(execCount).to.equal(0); | ||
expect(copy.test).to.equal(1); | ||
expect(execCount).to.equal(1); | ||
done(); | ||
}); | ||
}); | ||
@@ -1404,2 +1427,18 @@ | ||
describe('format()', function () { | ||
it('exists', function (done) { | ||
expect(Hoek.format).to.exist; | ||
expect(typeof Hoek.format).to.equal('function'); | ||
done(); | ||
}); | ||
it('is a reference to Util.format', function (done) { | ||
expect(Hoek.format('hello %s', 'world')).to.equal('hello world'); | ||
done(); | ||
}); | ||
}); | ||
describe('transform()', function () { | ||
@@ -1406,0 +1445,0 @@ |
114434
1767