UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

25 lines (24 loc) 938 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const isKey_1 = __importDefault(require("./isKey")); const stringToPath_1 = __importDefault(require("./stringToPath")); const isArray_1 = __importDefault(require("../isArray")); const toString_1 = __importDefault(require("../toString")); /** * Casts `value` to a path array if it's not one. * * @private * @param {*} value The value to inspect. * @param {Object} [object] The object to query keys on. * @returns {Array} Returns the cast property path array. */ function castPath(value, object) { if ((0, isArray_1.default)(value)) { return value; } return (0, isKey_1.default)(value, object) ? [value] : (0, stringToPath_1.default)((0, toString_1.default)(value)); } exports.default = castPath;