You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
535 B
16 lines
535 B
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;
|
|
|