Published
Edited
May 22, 2019
Insert cell
md`# Object Utilities`
Insert cell
/**
https://gist.github.com/jasonrhodes/2321581
*/

function getProperty(object, propertyName ) {
var parts = propertyName.split( "." ),
length = parts.length,
i,
property = object || this;

for ( i = 0; i < length; i++ ) {
property = property[parts[i]];
}

return property;
}
Insert cell
function setProperty( object, propertyName, value ) {
var parts = propertyName.split( "." ),
length = parts.length,
i,
property = object || this;

for ( i = 0; i < length-1; i++ ) {
property = property[parts[i]];
}

property[parts[length-1]] = value;
}
Insert cell
function set_attrs(obj, attrs) {
Object.keys(attrs).forEach((d) => {
obj.attr(d, attrs[d]);
});
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more