{"_id":"map-obj@7.0.0","bugs":{"url":"https://github.com/sindresorhus/map-obj/issues"},"dist":{"shasum":"042def3ce90f0dc52c9460d4bdbbe1ade9bef53f","tarball":"http://registry-npm.ywwl.com/map-obj/download/map-obj-7.0.0.tgz","fileCount":5,"integrity":"sha512-u8zj/RXtq+8FEtGLJlYcFIpSKNk/B3lgv5RtYtLKJ6jcxGRYHoEq2NDRAEOz9EdlRmLod+v4OUfxBvOGlG0XSQ==","signatures":[{"sig":"MEYCIQC/wxHpuN2FQN5Jv6jh8iNeJYkA5LJ86R0dWJ5nsRwmCgIhAJoCnRYQ6izgU5JhpqW5R3B+dYEC2CDs94xHt1hv4osP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF1vEIPXc/Z1F43JAseVS1r17ANogA/ybPUXD/NlQwnhAiAeXZpT3tG/yOgMfspkV/3GZaoT1FLh/kfeTXbH3PHt3g=="}],"unpackedSize":17229,"size":4503,"noattachment":false,"key":"/map-obj/-/map-obj-7.0.0.tgz"},"name":"map-obj","type":"module","types":"./index.d.ts","author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"engines":{"node":">=22"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"a5977f73a2b933443d849a897481dcf072344f21","license":"MIT","scripts":{"test":"xo && node --test && nz"},"version":"7.0.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"homepage":"https://github.com/sindresorhus/map-obj#readme","keywords":["map","object","key","keys","value","values","iterate","iterator","rename","modify","deep","recurse","recursive"],"repository":{"url":"git+https://github.com/sindresorhus/map-obj.git","type":"git"},"_npmVersion":"12.2.0","description":"Map object keys and values into a new object","directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"sideEffects":false,"_nodeVersion":"26.11.1","_hasShrinkwrap":false,"devDependencies":{"nz":"^0.1.0","xo":"^5.0.1","@typescript/native":"npm:typescript@^7.0.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/map-obj_7.0.0_1791876279277_0.6943348382029915"},"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\n// Swap keys and values\nconst newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);\n//=> {bar: 'foo'}\n\n// Convert keys to lowercase (shallow)\nconst newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value]);\n//=> {foo: true, bar: {bAz: true}}\n\n// Convert keys to lowercase (deep recursion)\nconst newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value], {deep: true});\n//=> {foo: true, bar: {baz: true}}\n\n// Filter out specific values\nconst newObject = mapObject({one: 1, two: 2}, (key, value) => value === 1 ? [key, value] : mapObjectSkip);\n//=> {one: 1}\n\n// Include symbol keys\nconst symbol = Symbol('foo');\nconst newObject = mapObject({bar: 'baz', [symbol]: 'qux'}, (key, value) => [key, value], {includeSymbols: true});\n//=> {bar: 'baz', [Symbol(foo)]: 'qux'}\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> [!NOTE]\n> When `options.deep` is `true`, the mapper receives keys and values from nested objects and arrays. The `sourceKey` parameter is typed as `string | symbol` and `sourceValue` as `unknown` to reflect the actual runtime behavior when recursing into unknown shapes. The third argument `source` is always the original input object, not the current nested owner.\n\n##### mapperOptions\n\nType: `object`\n\n###### shouldRecurse\n\nType: `boolean`\\\nDefault: `true`\n\nWhether to recurse into `targetValue`.\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\nBuilt-in objects like `RegExp`, `Error`, `Date`, `Map`, `Set`, `WeakMap`, `WeakSet`, `Promise`, `ArrayBuffer`, `DataView`, typed arrays (Uint8Array, etc.), and `Blob` are not recursed into. Special objects like Jest matchers are also automatically excluded.\n\n##### includeSymbols\n\nType: `boolean`\\\nDefault: `false`\n\nInclude symbol keys in the iteration.\n\nBy default, symbol keys are completely ignored and not passed to the mapper function. When enabled, the mapper will also be called with symbol keys from the source object, allowing them to be transformed or included in the result. Only enumerable symbol properties are included.\n\n##### target\n\nType: `object`\\\nDefault: `{}`\n\nThe target object to map properties onto.\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","publish_time":1791876279381,"_cnpm_publish_time":1791876279381,"dist-tags":{"latest":"7.0.0"}}