17 lines
301 B
JavaScript
17 lines
301 B
JavaScript
|
|
|
|
// @path: normalized path
|
|
var resourceSet = function( data, path, value ) {
|
|
var i,
|
|
node = data,
|
|
length = path.length;
|
|
|
|
for ( i = 0; i < length - 1; i++ ) {
|
|
if ( !node[ path[ i ] ] ) {
|
|
node[ path[ i ] ] = {};
|
|
}
|
|
node = node[ path[ i ] ];
|
|
}
|
|
node[ path[ i ] ] = value;
|
|
};
|
|
|