assign(id, data)
Assigns a new object to an object data in a node.
Parameters
- id (string) - string id of a node. The node must contain data type of
object
. - data (object) - new object to be assigned. If the key already exists in the node, it will update the value. If the key doesn't exist, it will add the new key with the value.
Returns
- N/A
Examples
import Treeful from 'treeful';
Treeful.add('n1', { key1: 'value1' });
Treeful.assign('n1', { key1: 'value2' });
// Treeful.get('n1') == { key1: 'value2' }
Treeful.assign('n1', { key1: 'value3', key2: 1 });
// Treeful.get('n1') == { key1: 'value3', key2: 1 }