Skip to content
/ pickv Public

Pick object properties recursively based on type names

License

Notifications You must be signed in to change notification settings

mgenware/pickv

Repository files navigation

pickv

Pick object properties recursively based on type names.

Installation

yarn add pickv

Usage

import pickv from 'pickv';

class A {
  constructor() {
    this.a = 1;
    this.b = 2;
    this.c = 3;
  }
}

pickv(
  {
    prop: 'hello',
    nested: {
      array: [new A(), { a: 1, b: 2 }],
    },
  },
  {
    // Pick a set of properties from type A.
    A: ['b', 'c'],
  },
);
/*
  Prints:
  {
    prop: 'hello',
    nested: {
      array: [{ b: 2, c: 3 }, { a: 1, b: 2 }],
    },
  }
*/

About

Pick object properties recursively based on type names

Resources

License

Stars

Watchers

Forks

Packages

No packages published