{"id":21018558,"url":"https://github.com/damartripamungkas/mapping-data","last_synced_at":"2026-05-09T07:05:14.965Z","repository":{"id":233493798,"uuid":"787328299","full_name":"damartripamungkas/mapping-data","owner":"damartripamungkas","description":"📋 Mapping data with map or object in the same interface and support types Key and value in typescript","archived":false,"fork":false,"pushed_at":"2024-04-16T12:44:33.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T21:41:49.734Z","etag":null,"topics":["data-mapping","fast-store-data","js","map","mapping","mapping-data","nodejs","object","state","store","store-data","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/mapping-data","language":"TypeScript","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/damartripamungkas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-16T10:11:14.000Z","updated_at":"2024-07-08T10:20:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"3b0e64d1-be5d-4a0f-b35d-0ab4864ff6eb","html_url":"https://github.com/damartripamungkas/mapping-data","commit_stats":null,"previous_names":["damartripamungkas/mapping-data"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/damartripamungkas/mapping-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damartripamungkas%2Fmapping-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damartripamungkas%2Fmapping-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damartripamungkas%2Fmapping-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damartripamungkas%2Fmapping-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damartripamungkas","download_url":"https://codeload.github.com/damartripamungkas/mapping-data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damartripamungkas%2Fmapping-data/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32810382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-mapping","fast-store-data","js","map","mapping","mapping-data","nodejs","object","state","store","store-data","typescript"],"created_at":"2024-11-19T10:26:33.516Z","updated_at":"2026-05-09T07:05:14.929Z","avatar_url":"https://github.com/damartripamungkas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    MAPPING-DATA\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"GitHub top language\" src=\"https://img.shields.io/github/languages/top/damartripamungkas/mapping-data?color=04D361\u0026labelColor=000000\"\u003e\n  \n  \u003ca href=\"#\"\u003e\n    \u003cimg alt=\"Made by\" src=\"https://img.shields.io/static/v1?label=made%20by\u0026message=damartripamungkas\u0026color=04D361\u0026labelColor=000000\"\u003e\n  \u003c/a\u003e\n  \n  \u003cimg alt=\"Repository size\" src=\"https://img.shields.io/github/repo-size/damartripamungkas/mapping-data?color=04D361\u0026labelColor=000000\"\u003e\n  \n  \u003ca href=\"#\"\u003e\n    \u003cimg alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/damartripamungkas/mapping-data?color=04D361\u0026labelColor=000000\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n### 📖 Description :\n\nThis package is made for those of you who want the key and value to have the same type of type, because using `new Map()` and defining the type to the map then only the key works while the value does not, I give an example below:\n\n#### Using Map\n\n```typescript\ntype TypeStateAs = {\n  name: string\n  age: number\n  human: boolean\n}\nconst state = new Map\u003ckeyof TypeStateAs, TypeStateAs[keyof TypeStateAs]\u003e()\nstate.set(`name`, true) // is not an error, even though the value type is not boolean. expect this to be an error\n```\n\n#### Using Package\n\n```typescript\nimport { MappingMap } from \"mapping-data\"\n\ntype TypeStateAs = {\n  name: string\n  age: number\n  human: boolean\n}\nconst state = new MappingMap\u003ckeyof TypeStateAs, TypeStateAs[keyof TypeStateAs], TypeStateAs\u003e()\nstate.set(`name`, true) // this is will throw error in editor code, because value type `name` is string\n```\n\n### 🔮 Cheatsheet\n\nIf you only need types for the `.set()` and `.get()` functions without having to use classes from the package you can import and define them as below :\n\n```typescript\nimport type { MappingMap } from \"mapping-data\"\n\ntype TypeStateAs = {\n  name: string\n  age: number\n  human: boolean\n}\nconst state: MappingMap\u003ckeyof TypeStateAs, TypeStateAs[keyof TypeStateAs], TypeStateAs\u003e = new Map() as any\nstate.set(`name`, true) // this is will throw error in editor code, because value type `name` is string\n```\n\n### 💻 Step to install :\n\n```\nnpm install mapping-data\n```\n\n### ✏️ Example :\n\nsee full [here](./test/test.js)\n\n```typescript\nimport { MappingMap, MappingObj } from \"mapping-data\"\n\ntype TypeStateAs = {\n  name: string\n  age: number\n  human: boolean\n}\nconst state = new MappingMap\u003ckeyof TypeStateAs, TypeStateAs[keyof TypeStateAs], TypeStateAs\u003e()\nstate.set(`name`, `damar`)\nstate.get(`name`) // damar\nstate.jsonObject() // {name:\"damar\"}\nstate.jsonString() // \"{\"name\":\"damar\"}\"\n```\n\n### 🧾 Pre-Requisistes :\n\n```\nnode.js\n```\n\n### 📝 License :\n\nLicensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamartripamungkas%2Fmapping-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamartripamungkas%2Fmapping-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamartripamungkas%2Fmapping-data/lists"}