2016-10-10 03:43:44 +02:00
|
|
|
var isArray = require('./isArray'),
|
2016-11-16 01:59:39 +01:00
|
|
|
isKey = require('./_isKey'),
|
|
|
|
stringToPath = require('./_stringToPath'),
|
|
|
|
toString = require('./toString');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Casts `value` to a path array if it's not one.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {*} value The value to inspect.
|
2016-11-16 01:59:39 +01:00
|
|
|
* @param {Object} [object] The object to query keys on.
|
2016-10-10 03:43:44 +02:00
|
|
|
* @returns {Array} Returns the cast property path array.
|
|
|
|
*/
|
2016-11-16 01:59:39 +01:00
|
|
|
function castPath(value, object) {
|
|
|
|
if (isArray(value)) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = castPath;
|