uni-ticket-system/node_modules/licia/castPath.js

17 lines
535 B
JavaScript
Raw Normal View History

2023-12-05 02:11:10 +00:00
var has = require('./has');
var isArr = require('./isArr');
exports = function(str, obj) {
if (isArr(str)) return str;
if (obj && has(obj, str)) return [str];
var ret = [];
str.replace(regPropName, function(match, number, quote, str) {
ret.push(quote ? str.replace(regEscapeChar, '$1') : number || match);
});
return ret;
};
var regPropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
var regEscapeChar = /\\(\\)?/g;
module.exports = exports;