castPath.cjs 806 B

12345678910111213141516171819202122
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const isKey_js_1 = __importDefault(require("./isKey.cjs"));
  7. const stringToPath_js_1 = __importDefault(require("./stringToPath.cjs"));
  8. /**
  9. * Casts `value` to a path array if it's not one.
  10. *
  11. * @private
  12. * @param {*} value The value to inspect.
  13. * @param {Object} [object] The object to query keys on.
  14. * @returns {Array} Returns the cast property path array.
  15. */
  16. function castPath(value, object) {
  17. if (Array.isArray(value)) {
  18. return value;
  19. }
  20. return (0, isKey_js_1.default)(value, object) ? [value] : (0, stringToPath_js_1.default)(value);
  21. }
  22. exports.default = castPath;