{"id":22021461,"url":"https://github.com/lamansky/construct-map","last_synced_at":"2025-03-23T10:19:10.133Z","repository":{"id":57206264,"uuid":"122167688","full_name":"lamansky/construct-map","owner":"lamansky","description":"[Node.js] Turns entries into a Map or other key-value collection.","archived":false,"fork":false,"pushed_at":"2018-03-07T09:11:59.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T11:07:08.443Z","etag":null,"topics":["collection","construct","entries","javascript","map","node","node-module","object"],"latest_commit_sha":null,"homepage":"","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-02-20T07:31:13.000Z","updated_at":"2023-09-08T17:36:57.000Z","dependencies_parsed_at":"2022-09-11T05:20:35.697Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/construct-map","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fconstruct-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fconstruct-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fconstruct-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fconstruct-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/construct-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084919,"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":["collection","construct","entries","javascript","map","node","node-module","object"],"created_at":"2024-11-30T06:12:12.221Z","updated_at":"2025-03-23T10:19:10.101Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","readme":"# construct-map\n\nTurns entries into a Map or other key-value collection.\n\nUseful when you’re not sure ahead of time what type of collection it’ll be.\n\n## Installation\n\nRequires [Node.js](https://nodejs.org/) 6.0.0 or above.\n\n```bash\nnpm i construct-map\n```\n\n## API\n\nThe module exports a single function.\n\n### Parameters\n\n1. `Cls` (object, function, or string): The class to construct, an instance of the desired class, or the global string name of the class. The class to which this argument refers can be just about any built-in collection (`Array`, `Map`, `Object`, `Set`, Typed Arrays, `WeakMap`, `WeakSet`), or any class that accepts an `entries` iterable as the first argument of its constructor.\n2. `entries` (iterable): A collection of key-value pairs. (If constructing an `Array`, `Set`, `WeakSet`, or Typed Array, the keys will be ignored.)\n\n### Return Value\n\nA `Cls` object constructed with `entries`.\n\n## Example\n\n```javascript\nconst constructMap = require('construct-map')\n\nconst map = constructMap(Map, [['key', 'value']])\nmap.get('key') // 'value'\n\nconstructMap(Object, [['key', 'value']]) // {key: 'value'}\n\n// The module is particularly useful for reassembling a collection\n// after performing some operation on its entries.\nconst doSomething = x =\u003e x\nconst obj = {key: 'value'}\nconstructMap(obj, doSomething(Object.entries(obj))) // {key: 'value'}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fconstruct-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fconstruct-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fconstruct-map/lists"}