Usage const union = require('{%= name %}'); const obj = {}; union(obj, 'a.b.c', ['one', 'two']); union(obj, 'a.b.c', ['three']); console.log(obj); //=> { a: { b: { c: [ 'one', 'two', 'three' ] } } }