-
Notifications
You must be signed in to change notification settings - Fork 0
utils
Iben Van de Veire edited this page Jun 2, 2026
·
1 revision
@ibenvandeveire/utils provides framework-agnostic JavaScript utilities that can be used alongside the Angular packages or in any other JavaScript/TypeScript project.
Install the package first:
npm install @ibenvandeveire/utilsThis package will follow a semver-like format, major.minor.patch, in which:
-
major: Introduces new features and breaking changes -
minor: Introduces new features and non-breaking changes -
patch: Fixes bugs and other issues
The merge util merges all provided values into a single object, as long as the value is defined.
It requires a start object to merge the remaining properties into. Each additional property is provided as a tuple of [key, value]. When the value is undefined, the property is omitted from the result.
import { merge } from '@ibenvandeveire/utils';
interface Example {
id: string;
books?: string[];
user?: { name: string };
metaData?: unknown;
}
const metaData = undefined;
const books = ['Hello world', 'Java: How To Program'];
const user = { name: 'Test' };
merge<Example>(
{
id: 'test',
},
['books', books],
['user', user],
['metaData', metaData]
);
// => result: { id: 'test', books: ['Hello world', 'Java: How To Program'], user: { name: 'Test' } }