@lunuy/assign-partial
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

assign-partial

Copy fields from one to another one based specified keys. Based typescript type manipulation, you can use autocomplete on field names!

Usage

import { assignPartial } from '@lunuy/assign-partial';

{
    const obj1 = {
        a: 1,
        b: 'hi'
    }
    const obj2 = {
        a: 2,
        b: 34,
        c: 'hello'
    }

    // You can't copy 'b' field because type of 'b' field of two objects are not matched.(Not assignable)
    // You can't copy 'c' field because destination object(obj1) doesn't have 'c' field.
    assignPartial(obj1, obj2, ['a']);
    console.log(obj1);
}

Readme

Keywords

Package Sidebar

Install

npm i @lunuy/assign-partial

Weekly Downloads

0

Version

1.0.0

License

Unlicense

Unpacked Size

2.11 kB

Total Files

4

Last publish

Collaborators

  • lunuy