@kingjs/descriptor.pluck

Overwrites each property value on a descriptor with a property value on `this` descriptor which shares the same name, and then deletes the property on `this` descriptor.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
04Jun 21, 2021Jul 20, 2018Minified + gzip package size for @kingjs/descriptor.pluck in KB

Readme

@kingjs/descriptor.pluck

Overwrites each property value on a descriptor with a property value on this descriptor which shares the same name, and then deletes the property on this descriptor.

Usage

Pluck the properties representing fruits off of a descriptor containing properties representing foods tastiness rating.

var pluck = require('@kingjs/descriptor.pluck');

var food = {
  banana: 100,
  apple: 50,
  chicken: 20,
  salad: 5
};

var fruits = {
  banana: undefined,
  apple: undefined,
  orange: undefined
};

var result = {
  food: pluck.call(food, fruits),
  fruits
};

result:

{
  food: {
    chicken: 20,
    salad: 5
  },

  fruits: {
    banana: 100,
    apple 50,
    orange: undefined
  }
}

API

declare function pluck(
  this: Descriptor, 
  descriptor: Descriptor
): Descriptor

Interfaces

  • Descriptor: see [@kingjs/descriptor][descriptor]

    Parameters

  • this: The descriptor whose properties will be copied to properties with matching names on descriptor and then deleted.
  • descriptor: The descriptor whose properties will be overwritten with values found in properties of the same name on this.

    Returns

    Returns this.

    Install

    With npm installed, run
    $ npm install @kingjs/descriptor.pluck
    

    License

    MIT

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.