MCPcopy Create free account
hub / github.com/chieapp/chie / nonNullAssign

Function nonNullAssign

src/util/object-utils.ts:27–33  ·  view source on GitHub ↗
(target: T, source: S)

Source from the content-addressed store, hash-verified

25
26// Like Object.assign but ignore null or undefined properties.
27export function nonNullAssign<T extends object, S extends object>(target: T, source: S): T {
28 for (const key in source) {
29 if (Object.prototype.hasOwnProperty.call(source, key) && source[key] != null)
30 target[key as unknown as keyof T] = source[key] as unknown as T[keyof T];
31 }
32 return target;
33}
34
35// Return true if |obj| is not an object or it has no properties.
36export function isEmptyObject(obj: object) {

Callers 1

serializeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected