{"_id":"@benderthecrime/pick","_rev":"1-5527e6b63fb2f01762ac54e556edcf8d","name":"@benderthecrime/pick","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@benderthecrime/pick","version":"1.0.0","description":"Returns a partial copy of an object containing only the keys specified.","keywords":["pick","object","copy","partial","keys"],"author":{"name":"Joe Groseclose","email":"@benderTheCrime"},"license":"MIT","main":"index.js","scripts":{"prepublishOnly":"npm t","test":"mocha **/*.test.js"},"dependencies":{"is-plain-obj":"^2.1.0"},"devDependencies":{"chai":"^4.2.0","mocha":"^7.2.0"},"_id":"@benderthecrime/pick@1.0.0","_nodeVersion":"14.0.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-8nGJTcEL9Gcvk9qGI2rFPSe1/tEaEzKOVyr7BS5vVMCOQMTplatQZkcoKFRn4M7k+32fNGGRCZRdzYlLObK1qw==","shasum":"c8956c6d426273bdd7bc2b4fb076e10701319da9","tarball":"https://registry.npmjs.org/@benderthecrime/pick/-/pick-1.0.0.tgz","fileCount":3,"unpackedSize":3294,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe1AodCRA9TVsSAnZWagAAhlIP/2K0ZwM9C8TlbY9nJNSU\nAiMZX9FoWBUYZfIpZbUWLQPDb2uIvYcOPzrw9ANzJNT2bb2fniv4D70ov4Hg\nFn2oSGDNznpmxhaNr8E7VTUCMB9YszFLAaRivN83F5F7EOUlT9WivBfbQQ9Q\nlrGT6vwd0ksCyNo5he+1LyxO6TW4Mwi2FQI/9eU+X22+/stAP/AFfm21CMHl\ngHX8caDjDjqHfkD7cSGIFkgCURUbyWdzCHB3C82QMyCauzG9IaaNaHRmU3vT\nWX5/i9cbHygKx8A9rIP8RVKJj90adf9FnGoOO1GQHD2OFXD9wBCf3bUkOqz2\ncB7nWWb4N0ETs6S8fpm914J809+3SNX1XurC7Qo1dL3Bm9DShaIokERavSmZ\n3Q6zT156k1Q/yL7/4tC+on0jwvdlijupj4QuS8xR2KrqX3EMwecXdyTndDk0\n/Fu8/4ksCiuDB5a8uGnl95Cwi+c/hLuiqBtCTDCg1p5ulqxyrEPLrIb5IUBl\nyutPFK9qG4JTLfzzDS0CwJedfNH1K855VbxnTKWP38XZ/2xSqNkiyotnB5pr\n2Mzl787TrSnCTYI7AL+z4SWDYJyxtwY6Icob1Xjdb0kdt3PcGGA76fZ2+GTm\nbY+Sp6wEDZPZ6j2trphSt9xL8MF0/Qdv7gsZnBHejoWUAZQUuj+hGvQ+Astd\n5g2W\r\n=38pO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHlIU8Lepv8FSf9EF0YW/q/NSrE+jrWc3oGBvmq7yodXAiEAoG6pW3ljzYFDsJx6HMiVB5hJyhy3hevBm4EQZvMIezw="}]},"maintainers":[{"name":"benderthecrime","email":"joe.groseclose@gmail.com"}],"_npmUser":{"name":"benderthecrime","email":"joe.groseclose@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pick_1.0.0_1590954525365_0.8801849094391372"},"_hasShrinkwrap":false}},"time":{"created":"2020-05-31T19:48:45.312Z","1.0.0":"2020-05-31T19:48:45.463Z","modified":"2022-04-04T18:22:05.518Z"},"maintainers":[{"name":"benderthecrime","email":"joe.groseclose@gmail.com"}],"description":"Returns a partial copy of an object containing only the keys specified.","keywords":["pick","object","copy","partial","keys"],"author":{"name":"Joe Groseclose","email":"@benderTheCrime"},"license":"MIT","readme":"# @benderthecrime/pick\n\nReturns a partial copy of an object containing only the keys specified.\n\n---\n\n⚠️**NOTE: This package is great for my limited use cases and there are probably better options for your production apps.**\n\n---\n\n## Installation\n\n```sh\nnpm i @benderthecrime/pick\n```\n\n## Usage\n\nRequire the module in your Node.js service:\n\n```js\nconst pick = require('@benderthecrime/pick')\nconst {pick, pickAll} = require('@benderthecrime/pick')\n```\n\nUse `pick` when you want to skip missing keys in the returned Object:\n\n```js\nconst pick = require('@benderthecrime/pick')\n\nconst user = {firstName: 'Jane', lastName: 'Doe', password: 'supersecret7'}\nconst responseFields = pick(['email', 'firstName', 'lastName'], user) // {firstName: 'Jane', lastName: 'Doe'}\n```\n\nAlternatively, `pick` can return a partially applied function:\n\n```js\nconst app = require('express')()\nconst pick = require('@benderthecrime/pick')\n\nconst pickUserResponseFields = pick(['firstName', 'lastName'])\n\napp.get('/user/self', (_, res) => {\n  const user = {firstName: 'Jane', lastName: 'Doe', password: 'supersecret7'}\n  res.send(pickUserResponseFields(user))\n})\n```\n\nUse `pickAll` when you want to include missing keys in the returned Object:\n\n```js\nconst {pickAll} = require('@benderthecrime/pick')\n\nconst user = {firstName: 'Jane', lastName: 'Doe', password: 'supersecret7'}\nconst responseFields = pickAll(['email', 'firstName', 'lastName'], user) // {email: undefined, firstName: 'Jane', lastName: 'Doe'}\n```\n\nSimilarly to `pick`, `pickAll` can also return a partial:\n\n```js\nconst app = require('express')()\nconst {pickAll} = require('@benderthecrime/pick')\n\nconst pickUserResponseFields = pickAll(['firstName', 'lastName'])\n\napp.get('/user/self', (_, res) => {\n  const user = {firstName: 'Jane', lastName: 'Doe', password: 'supersecret7'}\n  res.send(pickUserResponseFields(user))\n})\n```\n","readmeFilename":"README.md"}