{"name":"map-obj","version":"4.2.1","description":"Map object keys and values into a new object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/map-obj.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["map","object","key","keys","value","values","iterate","iterator","rename","modify","deep","recurse","recursive"],"devDependencies":{"ava":"^2.0.0","tsd":"^0.14.0","xo":"^0.24.0"},"gitHead":"6a1010987d229a81a14b80015aaca83f3bc791e8","bugs":{"url":"https://github.com/sindresorhus/map-obj/issues"},"homepage":"https://github.com/sindresorhus/map-obj#readme","_id":"map-obj@4.2.1","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-+WA2/1sPmDj1dlvvJmB5G6JKfY9dpn7EVBUL06+y6PoljPkh+6V1QihwxNkbcGxCRjt2b0F9K0taiCuo7MbdFQ==","shasum":"e4ea399dbc979ae735c83c863dd31bdf364277b7","tarball":"http://registry-npm.ywwl.com/map-obj/download/map-obj-4.2.1.tgz","fileCount":5,"unpackedSize":8017,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbTmNCRA9TVsSAnZWagAAERsQAJ6iRbkaux6TSyWLbHhb\n5IZK+lGLnUUDHuIiQ/wfJ/Gm0yFEVQpGncuIDkgdV0LAHsd6Grz6AMa+1jcV\ndNeycqPlxqvCpWYWFa2AY95AOxbr+bBzHX5HzlozwgjkD0w2p0R4zaIIjw/B\ntkOqGZcdrgJ1yb8cR2pMoZjctjt1erIaQO0RoA9RUXxkl0+fGw3FS90jK2Wn\n8RgPlNLx8IFI3IfizI2AeWrCV+BycopFac4DrtmwElPkNJAdBPZj7A6c+OTa\noSEP91X7MCsEZF9v96SjBm9YGM18rdVmf9g7TfVDe9EMGuLnChN36fkmEGOD\nxO7sdAmEAKZLjBO+18i5wy75kbu9s3kv9qnKPjFxIQ2khrr0yDAqGRVvXCzq\nMuaIA5FkO099ZUA40qcDLEcGtfgj51do99nvFij0ypu3i00wafn2mcP4LdMb\n6qEIsGRRSsmXD2VZeG2ZXaKHqFZDagIZXKZE9VVe17tcef7TX+nqwnjUq15H\nxXgLVfegEwqHIxD8tqpRqJfLUcdXMBAFY/W8YFDUlpIz797YKSBREO/Jt4/p\n5GALsgBXyx2Yf4tEr0my0La5SIwZ+0/fQoM3Qc01Bw8WHtYfdTMngedqZnYW\n0YJFduXi6yX5wsJKg42JpUzq0SwX6T8WhqnMZ7HVxFj+fQCny7VUDRab6ISQ\nu9M+\r\n=5yOR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwpyucNLlR4UB3Av9jJVQ2WRDRDSYFsbAPCYT6/Y5wOAIhAKYTpOkBhTZl648bNS1rk2Fbl8kf2kBPFo4sK1MUTHCT"}],"size":2863,"noattachment":false,"key":"/map-obj/-/map-obj-4.2.1.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-obj_4.2.1_1617770893048_0.6852322629466565"},"_hasShrinkwrap":false,"readme":"# map-obj\n\n> Map object keys and values into a new object\n\n## Install\n\n```sh\nnpm install map-obj\n```\n\n## Usage\n\n```js\nimport mapObject, {mapObjectSkip} from 'map-obj';\n\nconst newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);\n//=> {bar: 'foo'}\n\nconst newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value]);\n//=> {foo: true, bar: {bAz: true}}\n\nconst newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value], {deep: true});\n//=> {foo: true, bar: {baz: true}}\n\nconst newObject = mapObject({one: 1, two: 2}, (key, value) => value === 1 ? [key, value] : mapObjectSkip);\n//=> {one: 1}\n```\n\n## API\n\n### mapObject(source, mapper, options?)\n\n#### source\n\nType: `object`\n\nThe source object to copy properties from.\n\n#### mapper\n\nType: `(sourceKey, sourceValue, source) => [targetKey, targetValue, mapperOptions?] | mapObjectSkip`\n\nA mapping function.\n\n##### mapperOptions\n\nType: `object`\n\n###### shouldRecurse\n\nType: `boolean`\\\nDefault: `true`\n\nWhether `targetValue` should be recursed.\n\nRequires `deep: true`.\n\n#### options\n\nType: `object`\n\n##### deep\n\nType: `boolean`\\\nDefault: `false`\n\nRecurse nested objects and objects in arrays.\n\n##### target\n\nType: `object`\\\nDefault: `{}`\n\nThe target object to map properties on to.\n\n### mapObjectSkip\n\nReturn this value from a `mapper` function to exclude the key from the new object.\n\n```js\nimport mapObject, {mapObjectSkip} from 'map-obj';\n\nconst object = {one: 1, two: 2}\nconst mapper = (key, value) => value === 1 ? [key, value] : mapObjectSkip\nconst result = mapObject(object, mapper);\n\nconsole.log(result);\n//=> {one: 1}\n```\n\n## Related\n\n- [filter-obj](https://github.com/sindresorhus/filter-obj) - Filter object keys and values into a new object\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-map-obj?utm_source=npm-map-obj&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","publish_time":1617770893189,"_cnpm_publish_time":1617770893189,"dist-tags":{"latest":"7.0.0"}}