Skip to content

Commit 3ad83e3

Browse files
committed
[FIX] Fix issue where falsey property is returned as undefined
1 parent 6c25608 commit 3ad83e3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

lib/yam.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Yam.prototype.getAll = function getAll() {
4444
Yam.prototype.get = function get(key) {
4545
var value = this.options[key];
4646

47-
return value ? value : undefined;
47+
return value !== undefined ? value : undefined;
4848
};
4949

5050
module.exports = Yam;

test/fixtures/primary/.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"foo": "bar"
2+
"foo": "bar",
3+
"falsey": false
34
}

test/yam-test.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ describe('Yam', function() {
4343

4444
equal(yam.get('durp'), undefined);
4545
});
46+
47+
it('returns `false` if the value is false', function() {
48+
yam = new Yam('test', {
49+
primary: 'test/fixtures/primary/',
50+
secondary: 'test/fixtures/secondary/'
51+
});
52+
53+
equal(yam.get('falsey'), false);
54+
});
4655
});
4756

4857
describe('constructor', function() {
@@ -60,7 +69,8 @@ describe('Yam', function() {
6069

6170
deepEqual(yam.options, {
6271
foo: 'bar',
63-
baz: 5
72+
baz: 5,
73+
falsey: false
6474
});
6575
});
6676
});

0 commit comments

Comments
 (0)