{"_id":"@miyauci/upsert","_rev":"6-9852ef543fc9ef01df3c4e3091218a76","name":"@miyauci/upsert","dist-tags":{"beta":"1.2.0-beta.1","latest":"1.2.0"},"versions":{"1.0.0-beta.1":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.0.0-beta.1","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"77a2ae453c9f273ab8541d4f4996e5a818e22f3d","_id":"@miyauci/upsert@1.0.0-beta.1","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-Zv4Qm2ebv7q2FQfdUGN9u/wK+3RTR/FePhXr090hVYOsMdW1p5D1E6IlTVMsDDa3mX/BjF1FDP5EqSWHM50HAw==","shasum":"442d90195693718209bab83e1fa37c3a03055a1a","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.0.0-beta.1.tgz","fileCount":25,"unpackedSize":22667,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBsdNDjMlat7crOpiQ2jrxJspObvv6R9EM9MDHX27H+UAiAER1AfTAHXdRZA9k6NCY8eiaPW5y0HCnJPxoUIBD1+sA=="}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.0.0-beta.1_1686639292945_0.6337573165926291"},"_hasShrinkwrap":false},"1.0.0-beta.2":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.0.0-beta.2","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"2d01c408eeb7bf7e23ee4c8e94c5c504b16055c2","readme":"# upsert\n\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/upsert)\n[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/upsert/mod.ts)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/TomokiMiyauci/upsert)](https://github.com/TomokiMiyauci/upsert/releases)\n[![codecov](https://codecov.io/github/TomokiMiyauci/upsert/branch/main/graph/badge.svg)](https://codecov.io/gh/TomokiMiyauci/upsert)\n[![GitHub](https://img.shields.io/github/license/TomokiMiyauci/upsert)](https://github.com/TomokiMiyauci/upsert/blob/main/LICENSE)\n\n[![test](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml/badge.svg)](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml)\n[![NPM](https://nodei.co/npm/@miyauci/upsert.png?mini=true)](https://nodei.co/npm/@miyauci/upsert/)\n\nMaps for emplace, TC39\n[proposal-upsert](https://github.com/tc39/proposal-upsert) implementation.\n\n## Entrypoint\n\nThis project provides ponyfill and polyfill.\n\nPolyfill has a side effect, so its endpoints are isolated.\n\nThe entrypoint of each are as follows:\n\n| Type     | Entrypoint    |\n| -------- | ------------- |\n| Ponyfill | `mod.ts`      |\n| Polyfill | `polyfill.ts` |\n\n## Emplace\n\nAdd a value to a map like if it does not already have something at `key`, and\nwill also update an existing value at `key`.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, {\n  insert: () => 0,\n  update: (existing) => existing + 1,\n});\nassert(map.has(key));\n```\n\n### Just insert if missing\n\nYou might omit an `update` if you're handling data that doesn't change, but can\nstill be appended.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\ndeclare const value: number;\n\nconst result = emplace(map, key, { insert: () => value });\n\nassert(map.has(key));\nassertType<IsExact<typeof result, number>>(true);\n```\n\n### Just update if present\n\nYou might want to omit an `insert` if you want to perform a function on all\nexisting values.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, { update: (existing) => existing + 1 });\n\nassertType<IsExact<typeof result, number | undefined>>(true);\n```\n\n## Emplaceable\n\nMixin for [emplace](#emplace).\n\n```ts\nimport { Emplaceable } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nclass MyMap extends Emplaceable(Map) {}\n\nassert(new MyMap().emplace);\n```\n\n## EmplaceableMap\n\n`Map` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableMap } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst map = new EmplaceableMap<string, number>();\ndeclare const key: string;\n\nmap.emplace(key, {\n  insert: () => 0,\n  update: (existing) => existing + 1,\n});\n\nassert(map.has(key));\n```\n\n## EmplaceableWeakMap\n\n`WeakMap` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableWeakMap } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\n\nconst weakMap = new EmplaceableWeakMap();\n```\n\n## Polyfill\n\nPolyfill affects the global object. You must be very careful when using it.\n\n```ts\nimport \"https://deno.land/x/upsert@$VERSION/polyfill.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nassert(Map.prototype.emplace);\nassert(WeakMap.prototype.emplace);\n```\n\n## API\n\nSee [deno doc](https://deno.land/x/upsert/mod.ts) for all APIs.\n\n## License\n\nCopyright © 2023-present [Tomoki Miyauchi](https://github.com/TomokiMiyauci).\n\nReleased under the [MIT](./LICENSE) license\n","readmeFilename":"README.md","_id":"@miyauci/upsert@1.0.0-beta.2","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-UC0jPAP8kH50l6PplLe6lc5p8TCYLzl+R2FYwMBvLMfMyWwC8M5mmb8JSij2B3Fjn1/9rBzvUkpsjMnIrqhUmg==","shasum":"eacabc9afde99c05e4dab1e446dd37896d8f672d","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.0.0-beta.2.tgz","fileCount":25,"unpackedSize":28014,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGVONW2nPFuI6l1w/JZ9H26+u81UvTLnBf/Tp6YAW4+fAiEA58jYvt/WqGZFFQUdWY68GQ/Yv4qoNCdpCRzWRqOekK8="}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.0.0-beta.2_1686646678314_0.2967940358830492"},"_hasShrinkwrap":false},"1.0.0":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.0.0","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"bf0b7e28757ffe9dc4d16750edf2cf566120a6f0","_id":"@miyauci/upsert@1.0.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-LcITnaUV3FRiYSbWLD5UPMuPvt9iDNj38EBdxpUKLBDvzHS/BWpGSGuvwQ3SKSPWafm3NtwxZR05b8dhUXW7Kw==","shasum":"86270952d5f547e0b7a9ba42c04bc69cbe47fe20","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.0.0.tgz","fileCount":25,"unpackedSize":28153,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC8asCRSYCarYy3cZ/C4U/JiBtcFfcYsE57doOqpmHpSAiBklu/xY6TZvOPUx5UEuERdsClGkSN5WlASR0HS/b9j2g=="}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.0.0_1686647466863_0.751908512994923"},"_hasShrinkwrap":false},"1.1.0-beta.1":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.1.0-beta.1","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"480963626b9c60e21ade2b43c2cc92ac81665b04","readme":"# upsert\n\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/upsert)\n[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/upsert/mod.ts)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/TomokiMiyauci/upsert)](https://github.com/TomokiMiyauci/upsert/releases)\n[![codecov](https://codecov.io/github/TomokiMiyauci/upsert/branch/main/graph/badge.svg)](https://codecov.io/gh/TomokiMiyauci/upsert)\n[![GitHub](https://img.shields.io/github/license/TomokiMiyauci/upsert)](https://github.com/TomokiMiyauci/upsert/blob/main/LICENSE)\n\n[![test](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml/badge.svg)](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml)\n[![NPM](https://nodei.co/npm/@miyauci/upsert.png?mini=true)](https://nodei.co/npm/@miyauci/upsert/)\n\nMaps for emplace, TC39\n[proposal-upsert](https://github.com/tc39/proposal-upsert) implementation.\n\n## Entrypoint\n\nThis project provides ponyfill and polyfill.\n\nPolyfill has a side effect, so its endpoints are isolated.\n\nThe entrypoint of each are as follows:\n\n| Type     | Entrypoint    |\n| -------- | ------------- |\n| Ponyfill | `mod.ts`      |\n| Polyfill | `polyfill.ts` |\n\n## Emplace\n\nAdd a value to a map like if it does not already have something at `key`, and\nwill also update an existing value at `key`.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, {\n  insert: () => 0,\n  update: (existing) => existing + 1,\n});\nassert(map.has(key));\n```\n\n### Just insert if missing\n\nYou might omit an `update` if you're handling data that doesn't change, but can\nstill be appended.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\ndeclare const value: number;\n\nconst result = emplace(map, key, { insert: () => value });\n\nassert(map.has(key));\nassertType<IsExact<typeof result, number>>(true);\n```\n\n### Just update if present\n\nYou might want to omit an `insert` if you want to perform a function on all\nexisting values.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, { update: (existing) => existing + 1 });\n\nassertType<IsExact<typeof result, number | undefined>>(true);\n```\n\n## Emplaceable\n\nMixin for [emplace](#emplace).\n\n```ts\nimport { Emplaceable } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nclass MyMap extends Emplaceable(Map) {}\n\nassert(new MyMap().emplace);\n```\n\n## EmplaceableMap\n\n`Map` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableMap } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst map = new EmplaceableMap<string, number>();\ndeclare const key: string;\n\nmap.emplace(key, {\n  insert: () => 0,\n  update: (existing) => existing + 1,\n});\n\nassert(map.has(key));\n```\n\n## EmplaceableWeakMap\n\n`WeakMap` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableWeakMap } from \"https://deno.land/x/upsert@$VERSION/mod.ts\";\n\nconst weakMap = new EmplaceableWeakMap();\n```\n\n## Polyfill\n\nPolyfill affects the global object. You must be very careful when using it.\n\n```ts\nimport \"https://deno.land/x/upsert@$VERSION/polyfill.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nassert(Map.prototype.emplace);\nassert(WeakMap.prototype.emplace);\n```\n\n## API\n\nSee [deno doc](https://deno.land/x/upsert/mod.ts) for all APIs.\n\n## License\n\nCopyright © 2023-present [Tomoki Miyauchi](https://github.com/TomokiMiyauci).\n\nReleased under the [MIT](./LICENSE) license\n","readmeFilename":"README.md","_id":"@miyauci/upsert@1.1.0-beta.1","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-tP9x7zN81UF97rmYaE/7dBqj2TES5SA0Y1p0OgNd9hQAaIGk6rT++CMHILm1O87z/3l4t/O2DkwlK2sdV09h1Q==","shasum":"8345b321800792c3cc2d39c80c8fae7ffafe5a93","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.1.0-beta.1.tgz","fileCount":25,"unpackedSize":27868,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDgRRCstvSOwTPFDRVVGT4D8n0n1oarBMyMO4N/6IpV8AIhAKpv/dK3ZDN6wsgETPCaw810Vn7OhpzPHxdcOUsyTS32"}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.1.0-beta.1_1686713863581_0.6265699506185416"},"_hasShrinkwrap":false},"1.1.0":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.1.0","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"2419f657beee4cc5bcba0de3b823292b9596751c","_id":"@miyauci/upsert@1.1.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-jJwe2Xn4sUDopqSw45vwBL5OPdZN0Ye+12SlVU2IOTLjWS+hYndLdFEO5OEQIjUbbDndin2T3t2z+HU6dag12g==","shasum":"c457eb8c943de9317d952ca9171036465453ecbb","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.1.0.tgz","fileCount":25,"unpackedSize":27861,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQChwFsc3FxFCZ6yXWKcJuUTaYbfLFoahxTpN6S6+ZtqcgIhAIpHQ+fc2Xsx1GF6FQWwaF/AfGyrV9gXQFHu3zz7ZoUB"}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.1.0_1686729802491_0.23423995582909485"},"_hasShrinkwrap":false},"1.2.0-beta.1":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.2.0-beta.1","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"1978fe0eba693448decafd2dec4df7ec25c6daec","readme":"# upsert\n\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/upsert)\n[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/upsert?doc)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/TomokiMiyauci/upsert)](https://github.com/TomokiMiyauci/upsert/releases)\n[![codecov](https://codecov.io/github/TomokiMiyauci/upsert/branch/main/graph/badge.svg)](https://codecov.io/gh/TomokiMiyauci/upsert)\n[![License](https://img.shields.io/github/license/TomokiMiyauci/upsert)](LICENSE)\n\n[![test](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml/badge.svg)](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml)\n[![NPM](https://nodei.co/npm/@miyauci/upsert.png?mini=true)](https://nodei.co/npm/@miyauci/upsert/)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\nMaps for emplace, TC39\n[proposal-upsert](https://github.com/tc39/proposal-upsert) implementation.\n\n## Table of Contents <!-- omit in toc -->\n\n- [Install](#install)\n- [Usage](#usage)\n  - [Insert](#insert)\n    - [Just insert](#just-insert)\n  - [Update](#update)\n    - [Just update](#just-update)\n  - [Emplaceable](#emplaceable)\n  - [EmplaceableMap](#emplaceablemap)\n  - [EmplaceableWeakMap](#emplaceableweakmap)\n  - [Polyfill](#polyfill)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\ndeno.land:\n\n```ts\nimport * as mod from \"https://deno.land/x/upsert/mod.ts\";\n```\n\nnpm:\n\n```bash\nnpm i @miyauci/upsert\n```\n\n## Usage\n\nAdd a value to a map like if it does not already have something at `key`, and\nwill also update an existing value at `key`.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, {\n  insert: () => 0,\n  update: (existing) => ++existing,\n});\nassert(map.has(key));\n```\n\n### Insert\n\nAdd the entry if the key does not exist.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\ndeclare const value: number;\n\nconst result = emplace(map, key, { insert: () => value });\n\nassert(map.has(key));\nassertType<IsExact<typeof result, number>>(true);\n```\n\n#### Just insert\n\nIf only inserting is required, `insert` is available.\n\n```ts\nimport { insert } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const key: string;\ndeclare const value: number;\nconst map = new Map<typeof key, typeof value>();\n\ninsert(map, key, () => value);\n\nassertEquals(map, new Map([[key, value]]));\n```\n\n### Update\n\nUpdate the entry if the key exists.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, { update: (existing) => ++existing });\n\nassertType<IsExact<typeof result, number | undefined>>(true);\n```\n\n#### Just update\n\nIf only updating is required, `update` is available.\n\n```ts\nimport { update } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const key: string;\nconst map = new Map([[key, 0]]);\n\nupdate(map, key, (existing) => ++existing);\n\nassertEquals(map, new Map([[key, 1]]));\n```\n\n### Emplaceable\n\nMixin for `emplace`.\n\n```ts\nimport { emplaceable } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nclass MyMap extends emplaceable(Map) {}\n\nassert(MyMap.prototype.emplace);\n```\n\ndecorator style:\n\n> **note** In TypeScript, decorators do not yet affect types.\n\n```ts\nimport {\n  type Emplaceable,\n  emplaceable,\n} from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\n@emplaceable\nclass MyMap<K, V> extends Map<K, V> {}\ninterface MyMap<K, V> extends Emplaceable<K, V> {}\n\nassert(MyMap.prototype.emplace);\n```\n\n### EmplaceableMap\n\n`Map` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableMap } from \"https://deno.land/x/upsert/mod.ts\";\nimport {\n  assert,\n  assertInstanceOf,\n} from \"https://deno.land/std/testing/asserts.ts\";\n\nconst map = new EmplaceableMap<string, number>();\n\nassertInstanceOf(map, Map);\nassert(map.emplace);\n```\n\n### EmplaceableWeakMap\n\n`WeakMap` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableWeakMap } from \"https://deno.land/x/upsert/mod.ts\";\nimport {\n  assert,\n  assertInstanceOf,\n} from \"https://deno.land/std/testing/asserts.ts\";\n\nconst weakMap = new EmplaceableWeakMap();\n\nassertInstanceOf(weakMap, WeakMap);\nassert(weakMap.emplace);\n```\n\n### Polyfill\n\nPolyfill affects the global object. You must be very careful when using it.\n\n```ts\nimport \"https://deno.land/x/upsert/polyfill.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nassert(Map.prototype.emplace);\nassert(WeakMap.prototype.emplace);\n```\n\n## API\n\nSee [deno doc](https://deno.land/x/upsert?doc) for all APIs.\n\n## Contributing\n\nSee [contributing](CONTRIBUTING.md).\n\n## License\n\n[MIT](LICENSE) © 2023 Tomoki Miyauchi\n","readmeFilename":"README.md","_id":"@miyauci/upsert@1.2.0-beta.1","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-f99BjFb0mnh292Optcuzv1y6NJMTaVeRJG6TxqJwQLECBeUyIA0Zx5s/gm4GJH/onqtuT3lmBAqTHZMAxdXnqQ==","shasum":"43d41dbe29e10d5953a0aa23fa93789e2462cb8c","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.2.0-beta.1.tgz","fileCount":25,"unpackedSize":38151,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWsn7MriAPC/+MMg4KI4iI1c4z/JG0zpyz8PasGCfBMgIgOl8GHk3VL0j3p2WSmjqCXxClRrM5zws5Gd7/35HXNSI="}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.2.0-beta.1_1687435725168_0.7869290384288024"},"_hasShrinkwrap":false},"1.2.0":{"module":"./esm/mod.js","main":"./script/mod.js","name":"@miyauci/upsert","version":"1.2.0","description":"Maps for emplace, TC39 proposal-upsert implementation","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"license":"MIT","homepage":"https://github.com/TomokiMiyauci/upsert","repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"sideEffects":false,"type":"module","publishConfig":{"access":"public"},"exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"},"./polyfill.js":{"import":"./esm/polyfill.js","require":"./script/polyfill.js"}},"types":"./script/mod.d.ts","gitHead":"2cbc9d7d44cd7e02ea821665139da08494781132","_id":"@miyauci/upsert@1.2.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-/0AU6bYbfCr4k5sgrgOzSSsm0AJOatqEW+PX4T8jF3OrdGkX22HCijzXyEwyjMKUEU2JLnlAXFj6ysyJkeOJwA==","shasum":"1735d3b84266f98298f5ff6a43452e466c595e80","tarball":"https://registry.npmjs.org/@miyauci/upsert/-/upsert-1.2.0.tgz","fileCount":25,"unpackedSize":38612,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTyzrHRnNojOJSmbGb4rbODdMq5u0ocqR2du5TSweH+AIgCCvEGiARTEJj2l7wjWlTTvpL2eThMNx+rj62xOqYXIg="}]},"_npmUser":{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"},"directories":{},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/upsert_1.2.0_1687529517655_0.47282639951917127"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-13T06:54:52.889Z","1.0.0-beta.1":"2023-06-13T06:54:53.126Z","modified":"2023-06-23T14:11:57.977Z","1.0.0-beta.2":"2023-06-13T08:57:58.454Z","1.0.0":"2023-06-13T09:11:07.014Z","1.1.0-beta.1":"2023-06-14T03:37:43.767Z","1.1.0":"2023-06-14T08:03:22.654Z","1.2.0-beta.1":"2023-06-22T12:08:45.348Z","1.2.0":"2023-06-23T14:11:57.842Z"},"maintainers":[{"name":"miyauci","email":"development.operation.6.6.6@gmail.com"}],"description":"Maps for emplace, TC39 proposal-upsert implementation","homepage":"https://github.com/TomokiMiyauci/upsert","keywords":["upsert","map","weak-map","insert","update","tc39","proposal-upsert"],"repository":{"type":"git","url":"git+https://github.com/TomokiMiyauci/upsert.git"},"bugs":{"url":"https://github.com/TomokiMiyauci/upsert/issues"},"license":"MIT","readme":"# upsert\n\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/upsert)\n[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/upsert?doc)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/TomokiMiyauci/upsert)](https://github.com/TomokiMiyauci/upsert/releases)\n[![codecov](https://codecov.io/github/TomokiMiyauci/upsert/branch/main/graph/badge.svg)](https://codecov.io/gh/TomokiMiyauci/upsert)\n[![License](https://img.shields.io/github/license/TomokiMiyauci/upsert)](LICENSE)\n\n[![test](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml/badge.svg)](https://github.com/TomokiMiyauci/upsert/actions/workflows/test.yaml)\n[![NPM](https://nodei.co/npm/@miyauci/upsert.png?mini=true)](https://nodei.co/npm/@miyauci/upsert/)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\nMaps for emplace, TC39\n[proposal-upsert](https://github.com/tc39/proposal-upsert) implementation.\n\n## Table of Contents <!-- omit in toc -->\n\n- [Install](#install)\n- [Usage](#usage)\n  - [Insert](#insert)\n    - [Just insert](#just-insert)\n  - [Update](#update)\n    - [Just update](#just-update)\n  - [Emplaceable](#emplaceable)\n  - [EmplaceableMap](#emplaceablemap)\n  - [EmplaceableWeakMap](#emplaceableweakmap)\n  - [Polyfill](#polyfill)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\ndeno.land:\n\n```ts\nimport * as mod from \"https://deno.land/x/upsert/mod.ts\";\n```\n\nnpm:\n\n```bash\nnpm i @miyauci/upsert\n```\n\n## Usage\n\nAdd a value to a map like if it does not already have something at `key`, and\nwill also update an existing value at `key`.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, {\n  insert: () => 0,\n  update: (existing) => ++existing,\n});\nassert(map.has(key));\n```\n\n### Insert\n\nAdd the entry if the key does not exist.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\ndeclare const value: number;\n\nconst result = emplace(map, key, { insert: () => value });\n\nassert(map.has(key));\nassertType<IsExact<typeof result, number>>(true);\n```\n\n#### Just insert\n\nIf only inserting is required, `insert` is available.\n\n```ts\nimport { insert } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const key: string;\ndeclare const value: number;\nconst map = new Map<typeof key, typeof value>();\n\ninsert(map, key, () => value);\n\nassertEquals(map, new Map([[key, value]]));\n```\n\n### Update\n\nUpdate the entry if the key exists.\n\n```ts\nimport { emplace } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nimport {\n  assertType,\n  type IsExact,\n} from \"https://deno.land/std/testing/types.ts\";\n\ndeclare const map: Map<string, number>;\ndeclare const key: string;\n\nconst result = emplace(map, key, { update: (existing) => ++existing });\n\nassertType<IsExact<typeof result, number | undefined>>(true);\n```\n\n#### Just update\n\nIf only updating is required, `update` is available.\n\n```ts\nimport { update } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\ndeclare const key: string;\nconst map = new Map([[key, 0]]);\n\nupdate(map, key, (existing) => ++existing);\n\nassertEquals(map, new Map([[key, 1]]));\n```\n\n### Emplaceable\n\nMixin for `emplace`.\n\n```ts\nimport { emplaceable } from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nclass MyMap extends emplaceable(Map) {}\n\nassert(MyMap.prototype.emplace);\n```\n\ndecorator style:\n\n> **note** In TypeScript, decorators do not yet affect types.\n\n```ts\nimport {\n  type Emplaceable,\n  emplaceable,\n} from \"https://deno.land/x/upsert/mod.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\n@emplaceable\nclass MyMap<K, V> extends Map<K, V> {}\ninterface MyMap<K, V> extends Emplaceable<K, V> {}\n\nassert(MyMap.prototype.emplace);\n```\n\n### EmplaceableMap\n\n`Map` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableMap } from \"https://deno.land/x/upsert/mod.ts\";\nimport {\n  assert,\n  assertInstanceOf,\n} from \"https://deno.land/std/testing/asserts.ts\";\n\nconst map = new EmplaceableMap<string, number>();\n\nassertInstanceOf(map, Map);\nassert(map.emplace);\n```\n\n### EmplaceableWeakMap\n\n`WeakMap` with [Emplaceable](#emplaceable) implementation.\n\n```ts\nimport { EmplaceableWeakMap } from \"https://deno.land/x/upsert/mod.ts\";\nimport {\n  assert,\n  assertInstanceOf,\n} from \"https://deno.land/std/testing/asserts.ts\";\n\nconst weakMap = new EmplaceableWeakMap();\n\nassertInstanceOf(weakMap, WeakMap);\nassert(weakMap.emplace);\n```\n\n### Polyfill\n\nPolyfill affects the global object. You must be very careful when using it.\n\n```ts\nimport \"https://deno.land/x/upsert/polyfill.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nassert(Map.prototype.emplace);\nassert(WeakMap.prototype.emplace);\n```\n\n## API\n\nSee [deno doc](https://deno.land/x/upsert?doc) for all APIs.\n\n## Contributing\n\nSee [contributing](CONTRIBUTING.md).\n\n## License\n\n[MIT](LICENSE) © 2023 Tomoki Miyauchi\n","readmeFilename":"README.md"}