Appends all provided JSON values together. undefined values will be ignored. The first value
determines whether the output will be an object or an array. Any value appended to an array will
work just fine, but primitives append to an object will likely behave unexpectedly. Arrays
appended to arrays will be flattened (but only by one level).
Example
import {appendJson} from'@augment-vir/common';
// `result1` will be `{a: 'q', b: 'b'}` constresult1 = appendJson({a:'a'}, {b:'b'}, {a:'q'}); // `result2` will be `[{a: 'a'}, {b: 'b'}, {a: 'q'}, 'r']` constresult2 = appendJson([{a:'a'}], {b:'b'}, {a:'q'}, 'r'); // `result3` will be `['a', ['b', 'c'], 'd', 'e']` constresult3 = appendJson(['a'], [['b', 'c']], ['d'], 'e');
Appends all provided JSON values together.
undefined
values will be ignored. The first value determines whether the output will be an object or an array. Any value appended to an array will work just fine, but primitives append to an object will likely behave unexpectedly. Arrays appended to arrays will be flattened (but only by one level).Example
Package
@augment-vir/common