jsedn
Version:
js implementation of edn
30 lines (26 loc) • 660 B
JavaScript
// Generated by CoffeeScript 1.6.1
(function() {
var kw;
kw = require("./atoms").kw;
module.exports = function(obj, path) {
var part, value, _i, _len;
path = path.trim().replace(/[ ]{2,}/g, ' ').split(' ');
value = obj;
for (_i = 0, _len = path.length; _i < _len; _i++) {
part = path[_i];
if (part[0] === ":") {
part = kw(part);
}
if (value.exists) {
if (value.exists(part) != null) {
value = value.at(part);
} else {
throw "Could not find " + part;
}
} else {
throw "Not a composite object";
}
}
return value;
};
}).call(this);