Skip to main content

merge

Shallow-merges a second object into the pipeline value. Right-hand fields win.

const addPermissions = merge({role: 'admin', canEdit: true});

addPermissions({id: 1, role: 'viewer'});
// {id: 1, role: 'admin', canEdit: true}

The source can also be a zero-argument factory when it must be created at transform time:

const addMetadata = merge(() => ({processedAt: new Date().toISOString()}));

Both inputs remain unchanged. Nested objects are replaced rather than deeply merged.