Skip to content

A simple class for resolving nested properties as a string from an object.

Notifications You must be signed in to change notification settings

grofit/property-resolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PropertyResolver

Build Status

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

Usage

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.