{"name":"map-obj","version":"5.0.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"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["map","object","key","keys","value","values","iterate","iterator","rename","modify","deep","recurse","recursive"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.18.0","xo":"^0.45.0"},"types":"./index.d.ts","gitHead":"27e93234ecb7f9ac483f3800b31a2e10e532e79f","bugs":{"url":"https://github.com/sindresorhus/map-obj/issues"},"homepage":"https://github.com/sindresorhus/map-obj#readme","_id":"map-obj@5.0.1","_nodeVersion":"12.22.1","_npmVersion":"8.3.2","dist":{"integrity":"sha512-p3Qoax94q4c4Pb4etNi2lQSQGlqOA4PoD3ARovo7NllRoObZHwNEYd40fz4qgX1zTFK4geU/R1kbowl5hU5OVg==","shasum":"7623fb9f565284860977a96f9295fa155d31644c","tarball":"http://registry-npm.ywwl.com/map-obj/download/map-obj-5.0.1.tgz","fileCount":5,"unpackedSize":9338,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHOF3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrX5g//b57kEXIlm46l19n0IVPH/Fqt71yzlcmOQR340O86Tb0O6Zps\r\nOBdzBw/B0z1ViT3wuKwW4cFSoUzJlLlbsdvaB7apSSZt8Yl94l11qMK2Ahh5\r\nm3tnai1Ge1OAy4nnaRiw0HGMmog7EY2F+82VrAZvZY1hlxsBRIeOKtKDWG08\r\nJ74VVgOIeo3HHx2fs1BWtg6Cez2Y5QaHbDSJtPzwnxn8EhNQ9KLJoIX7zUOh\r\nskKX9MQ+IBg5V0Cx8IxVbXfpuip/1kux2kbuwsGFEByQBmLnRiBjprDIh2sd\r\nhRvDdXoK58pJ9/TvG88AC4KdM4psWhDswv+9u+b3zmoTteaeJg6/A9u2WJyk\r\njACRTKfAWeEmtNZkhIpd7OUOh7AAi+n5lS7LyMoA76q2RvZ0doOaw+qtBaH1\r\nuzuaz3ICoDD+ElP6lfqNViDZBpSo1L4VarKi86eHH8Gd/Ilu8a9F/BULCqbu\r\nZNiUXHbQiJBKPaxeNHex5yijk52hRhq1F35Q5P5/iFsih8xkZdFMK0SkPdoa\r\nuYr7qwzbUpnNkYSnU4fJeOKaoGqlzhkbrObxe+fqJk8VksGkhFn4weDVrado\r\nlNQlh+EmyG1UR996f4xTMP8i1wnyCDtG0WAf0SekLIkJfPn9tw5jEYeD/8fK\r\nIarkRmqpHFVWYPIdU2S9a90Wjjp2wQXKVyo=\r\n=PXhc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIIddkDeYZaaG0K8tBeFbgM5w4zH2rq2Zx2Swx5TvT5gIgJO4LTkzbMG9ol/ZtUig5zGFha+1tkUQnNmjEJ4735A0="}],"size":3070,"noattachment":false,"key":"/map-obj/-/map-obj-5.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-obj_5.0.1_1646059894956_0.8518763740331532"},"_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":1646059895102,"_cnpm_publish_time":1646059895102,"dist-tags":{"latest":"7.0.0"}}