A simple class for allowing string based property resolving on models, like so:
var PropertyResolver = require("property-resolver").PropertyResolver;
var someObject = {
someArray: [
{ someObject: [
{ value: 1 }
]}
]
};
var propertyResolver = new PropertyResolver();
var value = propertyResolver.resolveProperty(someObject, "someArray[0].someObject[0].value");
// value is 1
It is exported using UMD for browsers (dist/browser
) and CommonJS for node/modules so if you want it that way just do a normal require:
var PropertyResolver = require("property-resolver").PropertyResolver;
or if you want to use it in the browser it will self register the PropertyResolver
global.
Either way you will need to new up an instance of it to use it.