{"name":"map-obj","version":"5.0.2","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":"4257d4dd8564efa2372c6964eb16463cb3af898d","bugs":{"url":"https://github.com/sindresorhus/map-obj/issues"},"homepage":"https://github.com/sindresorhus/map-obj#readme","_id":"map-obj@5.0.2","_nodeVersion":"12.22.1","_npmVersion":"8.3.2","dist":{"integrity":"sha512-K6K2NgKnTXimT3779/4KxSvobxOtMmx1LBZ3NwRxT/MDIR3Br/fQ4Q+WCX5QxjyUR8zg5+RV9Tbf2c5pAWTD2A==","shasum":"174ad9f7e5e4e777a219126d9a734ff3e14a1c68","tarball":"http://registry-npm.ywwl.com/map-obj/download/map-obj-5.0.2.tgz","fileCount":5,"unpackedSize":9397,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICt373N/6aftl+xlHhixqjCBthawwrvkpe1XGfLbpcQgAiA0/EBECb7j0EIu6IMbaSi5xlm8vI1uPQUYBsQNWAKstg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiskFyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmopfA//ZYDoidfcSMRec5ZNfLxM6LGBZEmud4snIThqOjV/DzG4k69k\r\nYME6mn6RAyY1b30knc9ig9zX1abwC518UEubiHZvXSDTwoLU8PXk/L4txJeH\r\nRtfyplSzJRKqHvGR9mT9lA9Y+d2+Id2kWPyoyD57MnO6yYCrX7nYDpUZjtca\r\nu3NW/AWjr5pURcLl/ktfieOtMcp3ZEcydI8VcoNyQGNS+C6Oi0AIxuV7C74B\r\nLdQCyW9v4Du+RoZ+KkgQAP06HvP9TEdPeZwEgIonKUzyGqxwivRc7p6w4nJW\r\nZV9joWymB85C20C1GVQ8EWo/meUAttwNxeWtHpNIlukMinn6FvwZXRFV+giI\r\nqIzgQr2C7vvHqKu0tkUIWSlwGSSFVTpDyp7BOqNyN1BxB7cJwZan1P04CH1U\r\nqG5A8O260iT+GU6YjeRBs5YO9wVvxMXvcgISLlhX2NTP8o3aV9zlQTv0ScKV\r\nVkVfUpJjKs/GOlc9ditQNslVs7wdxuJFNpKCdkSlY9+08aBPfpiLJsS37+2x\r\nHJtheZuqg3dlqhwx4BO2TN1OYaH3fyG9tvQI37FRpXMSvHU+5U6QD9rrM8Ye\r\nXjygpgoX6sflbcJb3FeVbSxGCDk89IxjXFA/OwrzYKy1UMlQ8W4dzRTXl7Hr\r\nhhB9X08xzbAD6ENGwbN/fsObd0BW6fyvIBA=\r\n=vMJ6\r\n-----END PGP SIGNATURE-----\r\n","size":3089,"noattachment":false,"key":"/map-obj/-/map-obj-5.0.2.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.2_1655849330183_0.9052497581569097"},"_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":1655849330354,"_cnpm_publish_time":1655849330354,"dist-tags":{"latest":"7.0.0"}}