{"id":22021463,"url":"https://github.com/lamansky/map8","last_synced_at":"2025-03-23T10:19:11.938Z","repository":{"id":57148616,"uuid":"144646889","full_name":"lamansky/map8","owner":"lamansky","description":"The most feature-rich drop-in Map replacement ever. Supports sorting, nested layers, customizable loose key comparison, multiple values per key, value time-to-live expiration, and much more.","archived":false,"fork":false,"pushed_at":"2018-08-14T00:14:18.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T19:40:48.400Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamansky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-14T00:13:01.000Z","updated_at":"2018-08-14T00:14:19.000Z","dependencies_parsed_at":"2022-08-31T23:50:28.897Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/map8","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmap8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmap8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmap8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmap8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/map8/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084917,"owners_count":20558304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T06:12:12.491Z","updated_at":"2025-03-23T10:19:11.899Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Map8\n\nThe most feature-rich drop-in Map replacement ever. Supports sorting, nested layers, customizable loose key comparison, multiple values per key, value time-to-live expiration, and much more. By default, Map8 just acts like a normal built-in Map, so you can enable only what you need.\n\n## Installation\n\nRequires [Node.js](https://nodejs.org/) 8.3.0 or above.\n\n```bash\nnpm i map8\n```\n\n## API\n\nThe module exports a single class.\n\n### Constructor Parameters\n\n1. Optional: `entries` (iterable): The initial `[...key, value]` entries for the Map.\n2. Optional: `layerOptions` (array): An array of option objects, one for each layer of the map. These options are:\n    * `loose` (boolean): Whether or not to compare keys _and_ values loosely. Default is `false`.\n    * `looseKeys` (boolean): Whether or not to compare keys loosely. Defaults to the value of `loose`.\n    * `looseValues` (boolean): Whether or not to compare values loosely. Defaults to the value of `loose`.\n    * `multi` (boolean): Whether or not to allow multiple values per key on this level. If `true`, then the `set` method (for example) will add a value instead of overwriting the existing one. Default is `false`.\n    * `ttl` (positive integer): The number of milliseconds a value will remain in the map before it expires. If omitted or set to `0`, value expiration will be disabled.\n    * `setProxy` (function): A function that is called whenever a value is set on the current map level. The callback is passed two arguments: the key and the value. The callback may optionally modify the key/value by returning a two-element array. If the callback returns nothing, the key/value will remain as-is. You could also use a set-proxy to validate values and throw errors, for example.\n    * `sortKeys` (boolean or array): Whether or not map entries on this level should be sorted by key. Defaults to `false`. If set to `true`, default sorting behavior will be used: numbers and strings will be sorted as-is, and all other values will be coerced to strings before being compared. If `sortKeys` is an array, its elements can be any combination of functions, arrays, or other values. A function will be considered to be a sort callback that will be passed two values and will be expected to return `-1`, `0`, or `1`. An array will be considered to be a nested keychain for Map/Object keys. Any other value will be considered to be a single key for Map/Object keys. User-provided single sort-keys should be wrapped in an array to avoid ambiguity.\n    * `sortValues` (boolean or array): Same as `sortKeys`, but for values. Only applies when `multi` is `true`. Defaults to `false`.\n    * `weak` (boolean): Whether or not objects should be weakly stored on this level. If set to `true`, objects will be omitted from entry/key/value iterators. Defaults to `false`.\n\n### Methods\n\nFor an understanding of what these methods do, please have a look at `test.js` in the source code.\n\n#### Has\n\n* `hasKey (...keys)` (alias: `has`)\n* `hasAnyKey (...keys)`\n* `hasEntry (...keys, value)`\n* `hasValue ([...keys], value)`\n* `hasDeepValue ([...keys], value)`\n\n#### Get\n\n* `get (...keys)`\n* `getAny (...keys)`\n* `getElse (...keys, fallback)`\n* `getAnyElse (...keys, fallback)`\n* `getElseThrow (...keys, error)`\n* `getAnyElseThrow (...keys, error)`\n* `getElseSet (...keys, value)`\n\n#### Set\n\n* `branchSet (extraLayerOptions, ...keys, value)`\n* `set (...keys, value)`\n* `branchSetThenGet (extraLayerOptions, ...keys, value)`\n* `setThenGet (...keys, value)`\n* `branchSetAll (extraLayerOptions, ...entries)`\n* `setAll (...entries)`\n\n#### Edit\n\n* `branchEdit (extraLayerOptions, ...keys, callback)`\n* `edit (...keys, callback)`\n* `branchEditThenGet (extraLayerOptions, ...keys, callback)`\n* `editThenGet (...keys, callback)`\n* `branchEditAll (extraLayerOptions, callbacks)`\n* `editAll (callbacks)`\n\n#### Delete\n\n* `deleteKey (...keys)` (alias: `delete`)\n* `deleteEntry (...keys, value)`\n* `deleteValue ([...keys], value)`\n\n#### Entries\n\n* `toObject ([...keys])`\n* `entries ([...keys])`\n* `entriesArray ([...keys])`\n* `groupedEntries ([...keys])`\n* `groupedEntriesArray ([...keys])`\n* `deepEntries ([...keys])`\n* `deepEntriesArray ([...keys])`\n\n#### Keys\n\n* `keys ([...keys])`\n* `keysArray ([...keys])`\n* `deepKeys ([...keys])`\n* `deepKeysArray ([...keys])`\n\n#### Values\n\n* `toObject ([...keys])`\n* `values ([...keys])`\n* `valuesArray ([...keys])`\n* `groupedValues ([...keys])`\n* `groupedValuesArray ([...keys])`\n* `deepValues ([...keys])`\n* `deepValuesArray ([...keys])`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fmap8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fmap8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fmap8/lists"}