{"name":"map-obj","version":"4.2.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":"81b0ba19e5360a5c00980e9dfa03e1891ccc6d7a","bugs":{"url":"https://github.com/sindresorhus/map-obj/issues"},"homepage":"https://github.com/sindresorhus/map-obj#readme","_id":"map-obj@4.2.0","_nodeVersion":"14.16.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-NAq0fCmZYGz9UFEQyndp7sisrow4GroyGeKluyKC/chuITZsPyOyC1UJZPJlVFImhXdROIP5xqouRLThT3BbpQ==","shasum":"0e8bc823e2aaca8a0942567d12ed14f389eec153","tarball":"http://registry-npm.ywwl.com/map-obj/download/map-obj-4.2.0.tgz","fileCount":5,"unpackedSize":7939,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSG8MCRA9TVsSAnZWagAA/5MP/jE18ZqsKl8q9EEpMqlV\nhTfgJceUJwU1WqvJCoXpVATvIz9a16N1OHnyRtHXFnN4YrB8BFySDFbe4r4n\nRhluxPuSQGTtqyzPUubBcwePhJrZagXKetyuRf9pQixaB9fHaVjSPYHKZb7Y\ndOEXBmSpg/liRyFM/F/Pcamn26WyeTugoF4sYjKGueJVk08n+DvEkGpwHcYy\nWHXIOXyjcVejfPaLXp2Sq8wUVB+7/tHDaW/261UykakD1vyxzNSZHhTVboDp\nBSkEjCpZVQZRSM/jc8dnu7XTxHJK/iZ74wITuSrx8jeNCF225sh7NrrDrA9F\nxJTRiUpgDeTuUrUMdiKqggy2lVnlyHaZM6JL/IKtATQd46+xntCB7IL2a9yl\nGvhYoRmKShfsFTtWYGNRsBCtUc6Z7SwsuIVIFbnlEZlTlk8/f/adNA2fquo9\nWEc86C62zjjGfOdGvO2WjNsPmMmFJ+OHGwAVFbyQXqqMJ+SEpYhw4xJW2CdT\n45D6SlIdlbWxUsU9d4BliAdIWve1dk/UV96bfVhgS/FAiTXK2nxo1Ws5x2D3\n2scgNFkITLQJ+3YLXrzC9koxoxZLURhjwfsDlrzXUQKwdiU3kXNSnD29DPiY\nwqo7rXpan0sRvKqTboy/zKyQJG3pMlT7gg8tGbBwDC/RpVyMCy13PtuLanJs\nCvDv\r\n=AHWV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICMV8MjuUK1uZTwTUCNzmrrqOW5IMtnuxoD364spKp+/AiBhWZDT7abAsUgZO8n7Zjl2fgcM5HunqZLKDkpxduESKg=="}],"size":2824,"noattachment":false,"key":"/map-obj/-/map-obj-4.2.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-obj_4.2.0_1615359756344_0.3099350644767842"},"_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":1615359756520,"_cnpm_publish_time":1615359756520,"dist-tags":{"latest":"7.0.0"}}