{"_id":"@antoniovdlc/map","_rev":"2-5ee1ef2edd4726f294b4a597751b73a1","name":"@antoniovdlc/map","dist-tags":{"latest":"1.0.1"},"versions":{"0.1.0":{"name":"@antoniovdlc/map","version":"0.1.0","description":"Custom array map functions","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc src/*.ts --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"vitest run --coverage","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc src/*.ts --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["array","map","select","pick"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/map.git"},"bugs":{"url":"https://github.com/AntonioVdlC/map/issues"},"homepage":"https://github.com/AntonioVdlC/map#readme","license":"MIT","devDependencies":{"@rollup/plugin-typescript":"^8.3.0","c8":"^7.11.0","eslint":"^8.9.0","eslint-config-prettier":"^8.4.0","husky":"^7.0.4","lint-staged":"^12.3.4","prettier":"^2.5.1","rimraf":"^3.0.2","rollup":"^2.68.0","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.5.4","vite":"^2.9.1","vitest":"^0.9.3"},"dependencies":{"get-value-key":"^0.1.2"},"gitHead":"3b42af8070a6b665734963a897ba4e53b6c06a32","_id":"@antoniovdlc/map@0.1.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-b/IwJv8L5PfMfoTYcNcnfZgUht8mZg5/gAgE6d8L7ijZJ8U2Pn3BhYd70s3g2VUN0dqmeRz+4EME5UCEMr49MA==","shasum":"d95e62229c697471257b0d13c8feaebc15748dfe","tarball":"https://registry.npmjs.org/@antoniovdlc/map/-/map-0.1.0.tgz","fileCount":6,"unpackedSize":7950,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDzTaFddXIlmpValJVzHMLq78xPZkR7zfaiolvOZu9oSAiBkOYX8VPgW7EMhUjogUQgC4O1HTmVHiKorCvuWy/79CA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiVs2XACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoNiQ//XqMxToKBDpiGKQlmiEkCNjqxiCdqAiosj4faFKGrH+R8k3XW\r\nSDlucl1v5dcvvw6tBFlV0uv4X3A8OOvuO3dQtBInPGKVtNgGcV5V1xXWtbYM\r\nkcj5c0cSMOXwhRHlb0P+Iu9BdswjBI6R+HUg1L/n+oSxqWs66iD7HLbcbE4C\r\nQVO7/uQiyQSpLRMaxo6SvtMKjMH0nhTyVmnRSH+5oxLd6BVi8XeUjtwsN8YY\r\nlIwH1NbdV9O8kuReejAQkBRslc9CqOY+EOHLcwRj2nhr46eXuk9Bf0P80uYR\r\nPVt+3736ZBTCtW2CmXI/Ek4+ssZhXno67G66ZNP33rSDuSnM4SjKFkIuUUYf\r\nY3V1Q8PhOTQGqB/peSrWuH7hs8ttk2QlNdXBe1QkpbNB6soxWWwaRN1yJAER\r\n8m+JyUmKYKJ/rbl5xbqPHtVpNf3GvQUGmMpMBlH9xSo6opNTKAy5a2TLfliT\r\nXNM6tetAN/TbOYsCBYT8UwIolpk6ez3OndIxmMhvjkGQ1LNsmJ84yAkM40Jx\r\nvMuB/Z0zUUyqp8Siftc1Vl4xarX5WeQR7l8lAmOAvRQk2fskTLF0EF50QlwB\r\nlVcXMUDhSwMS//j12eQQmepl1OLGg0TKTZTjMwb7QryIPSpS6zn3Vou/NRnG\r\nMIIq3auc16d9dI8kPM2x6NDXxPnU9Il/pQk=\r\n=YZz0\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map_0.1.0_1649855895087_0.38216561120871484"},"_hasShrinkwrap":false},"1.0.0":{"name":"@antoniovdlc/map","version":"1.0.0","description":"Custom array map functions","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc src/*.ts --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"vitest run --coverage","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc src/*.ts --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["array","map","select","pick"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/map.git"},"bugs":{"url":"https://github.com/AntonioVdlC/map/issues"},"homepage":"https://github.com/AntonioVdlC/map#readme","license":"MIT","devDependencies":{"@rollup/plugin-typescript":"^8.3.0","c8":"^7.11.0","eslint":"^8.9.0","eslint-config-prettier":"^8.4.0","husky":"^7.0.4","lint-staged":"^12.3.4","prettier":"^2.5.1","rimraf":"^3.0.2","rollup":"^2.68.0","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.5.4","vite":"^2.9.1","vitest":"^0.9.3"},"dependencies":{"get-value-key":"^0.1.2"},"gitHead":"a54006573590243f73b8991a5bd5e7f5acb3735e","_id":"@antoniovdlc/map@1.0.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-OAn5GjdIa/VUBZ7wZFZh+nOChH6mojqcUPYc5LzEATS9Vm8wu4IYsPlTR3T10+u5SsfJzNq4sV9GgyNxvneW5Q==","shasum":"f496802e764ce0ce6acda189fe70f8ad7a05a882","tarball":"https://registry.npmjs.org/@antoniovdlc/map/-/map-1.0.0.tgz","fileCount":6,"unpackedSize":7950,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAxx6L9FKwns9HyQBFeqK2LCMdqUEWGK8nJb2OBAvV9MAiEA/hzxlhcQZhVisU2OxLR/lohA8h6IJ931zjqwPpabRS0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiWe50ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqZSw/+LpugPrpN09QZ6JHNQRXcH3/yBjZ+2NfcopXZqCKqbHD1DlVi\r\n5suV/jfbVQdzsiBfzmxQcKgbHmse7qCEQOSFY3uc4tKRnaQG+6mIVgIYHG/a\r\n9s+qP1osBn2IWJac87/ikXSBZE0dGvWaOvZWlyZeY3Hmtxl0yI0IwrPw8mBE\r\nt/Z636gKQbzkzlk99LzYP56E4q2lhTlcRT0S7BRHnhK/uj3aLsoLLUPp8Bo5\r\nbLME7qIxJlrwLjllw9vieirsrONStxs5ALUIN98hIADVdr9ad3SPXOVUh3ju\r\nKqVUcywJthSG4E6p4x5TiN6z1TPav+cWdlS1i25hrPoVLpOlWIozYdOcGV/P\r\nGS1me+glAtY35f7PriGYZS/cPOSJZeCQ2pJYI3TU8Vm61HjHHKkHpfWpmrPx\r\ns3qQg/lcDSkLk6JMvaMTfWnr0dJcuSyNjvQh67zHhpMFxABbzDyUawYK4uK6\r\nH3CP6J616UwUflTEuCcPy25xihwUryhsn9IiFtZcdFXoDA72/vlcizdPsVdF\r\nFXSRQSbTkEDLkbhDrrMXNiD38CGxOLNoYGmSyzS5mysP+nx6tTSlt2w6B95P\r\nFb4iNAMyu37w9o541vlrxeE89BsEhnM2jIUBUkHYfnDOJduJ5oPpYJxw0phL\r\nVNkiWpLIXVdOOUKvOd5KGZkiVs25pNQao/A=\r\n=iNS6\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map_1.0.0_1650060916224_0.7282067220821002"},"_hasShrinkwrap":false},"1.0.1":{"name":"@antoniovdlc/map","version":"1.0.1","description":"Custom array map functions","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc src/*.ts --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"vitest run --coverage","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc src/*.ts --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["array","map","select","pick"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/map.git"},"bugs":{"url":"https://github.com/AntonioVdlC/map/issues"},"homepage":"https://github.com/AntonioVdlC/map#readme","license":"MIT","devDependencies":{"@rollup/plugin-typescript":"^8.3.0","c8":"^7.11.0","eslint":"^8.9.0","eslint-config-prettier":"^8.4.0","husky":"^7.0.4","lint-staged":"^13.1.0","prettier":"^2.5.1","rimraf":"^3.0.2","rollup":"^2.68.0","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.5.4","vite":"^2.9.1","vitest":"^0.9.3"},"dependencies":{"get-value-key":"^0.1.3"},"gitHead":"b82c5f2d7a6b6a0ad8dee4545754289ee309eb2e","_id":"@antoniovdlc/map@1.0.1","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-iyz9CsC3uz6qgQqYCdtQggNji8NmOIOztvrwH4FZrc1yKkx97ZR6ZgTZW8/lDokZGYPci+53W9EU/8C8IkAUHw==","shasum":"775a965bc30cb01f1bc8696f81fb2b078399fe90","tarball":"https://registry.npmjs.org/@antoniovdlc/map/-/map-1.0.1.tgz","fileCount":6,"unpackedSize":7964,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCSVLfRMiaWbfBd2cBsD5V8aCX15vj0AykhgMoJzlS03wIgBbgS3p6AF0lUiIk79GghmQqCJDHIwe2L2tSDRLKhedY="}]},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map_1.0.1_1700415039363_0.3161753512253114"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-13T13:18:15.026Z","0.1.0":"2022-04-13T13:18:15.304Z","modified":"2023-11-19T17:30:39.710Z","1.0.0":"2022-04-15T22:15:16.393Z","1.0.1":"2023-11-19T17:30:39.537Z"},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"description":"Custom array map functions","homepage":"https://github.com/AntonioVdlC/map#readme","keywords":["array","map","select","pick"],"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/map.git"},"author":{"name":"Antonio Villagra De La Cruz"},"bugs":{"url":"https://github.com/AntonioVdlC/map/issues"},"license":"MIT","readme":"# map\n\n[![version](https://img.shields.io/npm/v/@antoniovdlc/map.svg)](http://npm.im/@antoniovdlc/map)\n[![issues](https://img.shields.io/github/issues-raw/antoniovdlc/map.svg)](https://github.com/AntonioVdlC/map/issues)\n[![downloads](https://img.shields.io/npm/dt/@antoniovdlc/map.svg)](http://npm.im/@antoniovdlc/map)\n[![license](https://img.shields.io/npm/l/@antoniovdlc/map.svg)](http://opensource.org/licenses/MIT)\n\nCustom map functions for arrays.\n\n## Installation\n\nThis package is distributed via npm:\n\n```\nnpm install @antoniovdlc/map\n```\n\n## Motivation\n\nMapping over arrays is a common operation in JavaScript, so this library provides some common custom map functions to have a more declarative way of mapping over arrays.\n\n## Usage\n\nYou can use this library either as an ES module or a CommonJS package:\n```js\nimport { select, pick } from \"@antoniovdlc/map\";\n```\n*- or -*\n```js\nconst { select, pick } = require(\"@antoniovdlc/map\");\n```\n\n## Examples\n\n### select\n\nThe `select` map function picks a single value based on a key path in an arry of objects:\n\n```js\nimport { select } from \"@antoniovdlc/map\";\n\nconst arr = [\n  { name: \"Bob\", age: 23 },\n  { name: \"Alice\", age: 32 },\n  { name: \"Tom\", age: 60 },\n  { name: \"Candice\", age: 45 },\n];\narr.map(select(\"age\")); // [23, 32, 60, 45]\n```\n\nIf in some objects, the key path doesn't exist, the returned value for that index will be `null`:\n```js\nimport { select } from \"@antoniovdlc/map\";\n\nconst arr = [\n  { name: \"Bob\", age: 23 },\n  { name: \"Alice\", age: 32 },\n  { name: \"Tom\", age: 60 },\n  { name: \"Tim\" },\n  { name: \"Candice\", age: 45 },\n];\narr.map(select(\"age\")); // [23, 32, 60, null, 45]\n```\n\n### pick\n\nThe `pick` map function is similar to the `select` one, but it allows for picking multiple key paths in an array of objects:\n```js\nconst arr = [\n  { name: { first: \"Bob\", last: \"Garcia\" }, age: 23 },\n  { name: { first: \"Alice\", last: \"Doe\" }, age: 32 },\n  { name: { first: \"Tom\", last: \"Dupont\" }, age: 60 },\n  { name: { first: \"Candice\", last: \"Smith\" }, age: 45 },\n];\narr.map(pick(\"name.first\", \"age\"));\n/*\n[\n  { name: { first: \"Bob\" }, age: 23 },\n  { name: { first: \"Alice\" }, age: 32 },\n  { name: { first: \"Tom\" }, age: 60 },\n  { name: { first: \"Candice\" }, age: 45 },\n];\n*/\n```\n\nThe `pick` map function always returns an array of objects, even if it is only passed a single key path:\n```js\nconst arr = [\n  { name: \"Bob\", age: 23 },\n  { name: \"Alice\", age: 32 },\n  { name: \"Tom\", age: 60 },\n  { name: \"Candice\", age: 45 },\n];\narr.map(pick(\"age\"));\n// [{ age: 23 }, { age: 32 }, { age: 60 }, { age: 45 }];\n```\n\nFinally, it ignores key paths that don't exist in the objects:\n```js\nconst arr = [\n  {\n    name: { first: \"Bob\", last: \"Garcia\" },\n    age: { value: 23, birthday: { year: 1999, month: 3 } },\n  },\n  {\n    name: { first: \"Alice\", last: \"Doe\" },\n    age: { value: 32, date: { year: 1990, month: 1 } },\n  },\n  {\n    name: { last: \"Dupont\" },\n    age: { value: 60, date: { year: 1962, month: 10 } },\n  },\n  {\n    name: { first: \"Candice\", last: \"Smith\" },\n    age: { value: 45, birthday: { month: 8 } },\n  },\n];\narr.map(pick(\"name.first\", \"age.birthday.year\"));\n/*\n[\n  { name: { first: \"Bob\" }, age: { birthday: { year: 1999 } } },\n  { name: { first: \"Alice\" } },\n  null,\n  { name: { first: \"Candice\" } },\n]\n*/\n```\n\n## License\nMIT","readmeFilename":"README.md"}