@arkecosystem/utils
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -8,2 +8,8 @@ # Changelog | ||
## [1.1.5] - 2019-10-25 | ||
## Changed | ||
- Better handling of falsy values for `has` | ||
## [1.1.4] - 2019-10-25 | ||
@@ -421,2 +427,3 @@ | ||
[1.1.5]: https://github.com/ArkEcosystem/utils/compare/1.1.4...1.1.5 | ||
[1.1.4]: https://github.com/ArkEcosystem/utils/compare/1.1.0...1.1.4 | ||
@@ -423,0 +430,0 @@ [1.1.0]: https://github.com/ArkEcosystem/utils/compare/1.0.34...1.1.0 |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const internal_1 = require("./internal"); | ||
const is_empty_1 = require("./is-empty"); | ||
const is_undefined_1 = require("./is-undefined"); | ||
const is_object_1 = require("./is-object"); | ||
const is_string_1 = require("./is-string"); | ||
exports.has = (object, path) => { | ||
if (is_empty_1.isEmpty(object)) { | ||
if (!is_object_1.isObject(object) || !is_string_1.isString(path)) { | ||
return false; | ||
} | ||
const fragments = internal_1.castPath(path); | ||
let index = 0; | ||
const length = fragments.length; | ||
while (object !== null && index < length) { | ||
object = object[fragments[index++]]; | ||
const pathArray = internal_1.castPath(path); | ||
for (let i = 0; i < pathArray.length; i++) { | ||
if (!is_object_1.isObject(object)) { | ||
return false; | ||
} | ||
if (!(pathArray[i] in object)) { | ||
return false; | ||
} | ||
object = object[pathArray[i]]; | ||
} | ||
return !is_undefined_1.isUndefined(object); | ||
return true; | ||
}; | ||
//# sourceMappingURL=has.js.map |
{ | ||
"name": "@arkecosystem/utils", | ||
"description": "Performance oriented implementations of commonly used functions in TypeScript.", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ "Brian Faust <brian@ark.io>", |
Sorry, the diff of this file is not supported yet
205035
2608