npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

addkey

0.8.1 • Public • Published

addKey NPM version NPM monthly downloads NPM total downloads Build Status

Add a new key-value pair for each single item of the array type and filter the children

Usage

Works with arrays.

Install

Install with npm:

$ npm install --save addkey

Usage

Works with arrays.

const addKey = require("addkey");
let arr = [
  {
    id: 1,
    name: "亚瑟"
  },
  {
    id: 2,
    name: "狄仁杰"
  },
  {
    id: 3,
    name: "曹操"
  }
];
addKey(arr, { isShow: false }, (v, index, array) => {
  index === array.length - 1 ? ((v.name = ""), (v.isShow = true)) : "";
});
 
// log arr =>
 
/*  
   [
      { id: 1, name: '亚瑟', isShow: false },
      { id: 2, name: '狄仁杰', isShow: false },
      { id: 3, name: '铠', isShow: true }
   ] 
*/

License

Copyright © 2019, xiaoyueyue. Released under the MIT License.

install

npm i addkey

Downloadsweekly downloads

8

version

0.8.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability