| 1 |
"use strict"; |
| 2 |
|
| 3 |
var ensureString = require("type/string/ensure") |
| 4 |
, esniff = require("./"); |
| 5 |
|
| 6 |
module.exports = function (objName) { |
| 7 |
var length; |
| 8 |
objName = ensureString(objName); |
| 9 |
length = objName.length; |
| 10 |
if (!length) throw new TypeError(objName + " is not valid object name"); |
| 11 |
return function (code) { |
| 12 |
var data = []; |
| 13 |
code = ensureString(code); |
| 14 |
esniff(code, function (emitter) { |
| 15 |
emitter.on("trigger:" + objName[0], function (accessor) { |
| 16 |
if (accessor.previousToken === ".") return; |
| 17 |
if (!accessor.skipCodePart(objName)) return; |
| 18 |
accessor.skipWhitespace(); |
| 19 |
if (!accessor.skipCodePart(".")) return; |
| 20 |
accessor.skipWhitespace(); |
| 21 |
var identifierMeta = accessor.skipIdentifier(); |
| 22 |
if (identifierMeta) data.push(identifierMeta); |
| 23 |
}); |
| 24 |
}); |
| 25 |
return data; |
| 26 |
}; |
| 27 |
}; |