@dozerg/merge-options
v1.0.11
Published
Merge plain objects with customised rules.
Downloads
5,278
Maintainers
Readme
Merge Options
Merge plain objects with customised rules.
Install
npm i @dozerg/merge-options
Usage
import { mergeOptions, Merger, concatArray } from '@dozerg/merge-options';
interface T {
foo: number;
bar?: string[];
}
const obj_1 = mergeOptions(undefined, {foo: 3, bar: ['abc']}, {foo: 4, bar: ['def']});
// obj_1 = {foo: 4, bar: ['def']}
const merger: Merger<T> = {
bar: concatArray();
}
const obj_2 = mergeOptions(merger, {foo: 3, bar: ['abc']}, {foo: 4, bar: ['def']});
// obj_2 = {foo: 4, bar: ['abc', 'def']}
APIs
License
MIT © Zhao DAI [email protected]