{"name":"map-obj","version":"4.3.0","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":"1e5c466ee0f293e91465ecd53d74ecdeb90cb4e4","bugs":{"url":"https://github.com/sindresorhus/map-obj/issues"},"homepage":"https://github.com/sindresorhus/map-obj#readme","_id":"map-obj@4.3.0","_nodeVersion":"12.22.1","_npmVersion":"7.20.3","dist":{"integrity":"sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==","shasum":"9304f906e93faae70880da102a9f1df0ea8bb05a","tarball":"http://registry-npm.ywwl.com/map-obj/download/map-obj-4.3.0.tgz","fileCount":5,"unpackedSize":9492,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAZ+Q/xnPNsT+S2SPM80eNCXhbzreQTplyoroLkWIIwnAiBMYCK3Qa96NhPDgZgFfhaYRfq4te/zHI5ZNGTebT6bIg=="}],"size":3196,"noattachment":false,"key":"/map-obj/-/map-obj-4.3.0.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_4.3.0_1632046473840_0.14921344042886675"},"_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":1632046473997,"_cnpm_publish_time":1632046473997,"dist-tags":{"latest":"7.0.0"}}