Skip to content

Commit fce33f0

Browse files
committed
fix: prop 0/false values
1 parent 7a3ec7b commit fce33f0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

dist/js/entity/in_memory.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ class InMemoryEntity {
7070
* @summary Return a prop or the default
7171
*/
7272
prop(name, defaultValue) {
73+
var _a;
7374
// `lodash.get` gets `null` when the value is `null`, but we still want a default value in this case, hence `||`
74-
return (0, get_1.default)(this._json, name, defaultValue) || defaultValue;
75+
return (_a = (0, get_1.default)(this._json, name, defaultValue)) !== null && _a !== void 0 ? _a : defaultValue;
7576
}
7677
/**
7778
* @summary Return a required prop, throwing an error if it doesn't exist or is undefined/null

src/js/entity/in_memory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class InMemoryEntity implements BaseInMemoryEntitySchema {
6161
*/
6262
prop<T = undefined>(name: string, defaultValue?: T): T | undefined {
6363
// `lodash.get` gets `null` when the value is `null`, but we still want a default value in this case, hence `||`
64-
return (getValue(this._json, name, defaultValue) as T) || defaultValue;
64+
return (getValue(this._json, name, defaultValue) as T) ?? defaultValue;
6565
}
6666

6767
/**

0 commit comments

Comments
 (0)