{"id":41055024,"url":"https://github.com/typescript-package/map","last_synced_at":"2026-01-22T11:35:44.059Z","repository":{"id":291384057,"uuid":"977429264","full_name":"typescript-package/map","owner":"typescript-package","description":"A lightweight TypeScript library for enhanced `map` management.","archived":false,"fork":false,"pushed_at":"2025-05-04T10:28:02.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-26T08:38:01.004Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/typescript-package.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["angular-package"],"patreon":"angularpackage","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29","https://donate.stripe.com/dR614hfDZcJE3wAcMM"]}},"created_at":"2025-05-04T07:29:20.000Z","updated_at":"2025-05-04T09:57:31.000Z","dependencies_parsed_at":"2025-05-04T10:22:06.762Z","dependency_job_id":"e0af4eee-a68a-4221-abc7-fcda96ca6400","html_url":"https://github.com/typescript-package/map","commit_stats":null,"previous_names":["typescript-package/map"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/typescript-package/map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typescript-package","download_url":"https://codeload.github.com/typescript-package/map/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fmap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28662165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":[],"created_at":"2026-01-22T11:35:43.902Z","updated_at":"2026-01-22T11:35:44.045Z","avatar_url":"https://github.com/typescript-package.png","language":"TypeScript","funding_links":["https://github.com/sponsors/angular-package","https://patreon.com/angularpackage","https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29","https://donate.stripe.com/dR614hfDZcJE3wAcMM"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.typescriptlang.org/\"\u003e\n  \u003cimg\n    src=\"https://avatars.githubusercontent.com/u/189666396?s=150\u0026u=9d55b1eb4ce258974ead76bf07ccf49ef0eb0ea7\u0026v=4\"\n    title=\"The typescript package enhances the development of typescript-based applications by providing well-structured, reusable, easy-to-use packages.\"\n  /\u003e\n\u003c/a\u003e\n\n## typescript-package/map\n\n\u003c!-- npm badge --\u003e\n[![npm version][typescript-package-npm-badge-svg]][typescript-package-npm-badge]\n[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]\n[![GitHub license][typescript-package-badge-license]][typescript-package-license]\n\nA lightweight **TypeScript** library for enhanced `map` management.\n\n## Table of contents\n\n- [Installation](#installation)\n- [Api](#api)\n  - [`CoreMap`](#coremap)\n  - [`DataMap`](#datamap)\n  - [`FactoryMap`](#factorymap)\n  - [`WeakDataMap`](#weakdatamap)\n- [Contributing](#contributing)\n- [Support](#support)\n- [Code of Conduct](#code-of-conduct)\n- [Git](#git)\n  - [Commit](#commit)\n  - [Versioning](#versioning)\n- [License](#license)\n\n## Installation\n\n### 1. Install peer `data` dependencies\n\n```bash\nnpm install @typescript-package/data --save-peer\n```\n\n### 2. Install the `map` package\n\n```bash\nnpm install @typescript-package/map --save-peer\n```\n\n## Api\n\n```typescript\nimport {\n  // Abstract.\n  CoreMap,\n  MapOnHook,\n\n  // Class.\n  DataMap,\n  FactoryMap,\n  WeakDataMap,\n} from '@typescript-package/map';\n```\n\n### `CoreMap`\n\nThe abstract core class is designed for building `Map` and `DataCore` related classes.\n\n```typescript\nimport { CoreMap } from '@typescript-package/map';\n```\n\n### `DataMap`\n\nThe `DataMap` is a concrete class that extends `Map` and encapsulates its data within a `DataCore` store, providing additional data management capabilities.\n\n```typescript\nimport { DataMap } from '@typescript-package/map';\n\n// Define a `DataCore` implementation for holding a data in `DataMap`.\nexport class CustomMapData\u003cKey, Value\u003e extends Data\u003cMap\u003cKey, Value\u003e\u003e {\n  constructor(initialValue?: Map\u003cKey, Value\u003e) {\n    super(initialValue ?? new Map());\n  }\n}\n\n// Create a new `DataMap` instance with predefined entries and customized data holder.\nexport const dataMap = new DataMap\n// \u003cstring, number, CustomMapData\u003cstring, number\u003e\u003e previous approach, now captured.\n(\n  [\n    [\"one\", 1],\n    [\"two\", 2],\n    [\"three\", 3],\n  ],\n  // new CustomMapData() // previous approach\n  CustomMapData // new approach\n); // const dataMap: DataMap\u003cstring, number, CustomMapData\u003cstring, number\u003e\u003e\n\n// Check the `CustomMapData`.\nconsole.log(`Data holder of \\`CustomMapData\\`:`, dataMap.data); // Output: CustomMapData {#locked: false, #value: Value}\n\n// Get the `CustomMapData` value.\nconsole.log(`Data holder of \\`CustomMapData\\` value:`, dataMap.data.value); // Output: Map(3) {'one' =\u003e 1, 'two' =\u003e 2, 'three' =\u003e 3}\n\n// Log the size of the map\nconsole.log(\"Size:\", dataMap.size); // Output: Size: 3\n\n// Get a value from the map\nconsole.log(\"Value for 'two':\", dataMap.get(\"two\")); // Output: Value for 'two': 2\n\n// Check if a key exists\nconsole.log(\"Has 'three'?\", dataMap.has(\"three\")); // Output: Has 'three'? true\n\n// Set a new key-value pair\ndataMap.set(\"four\", 4);\nconsole.log(\"Size after set:\", dataMap.size); // Output: Size after set: 4\n\n// Iterate over entries\ndataMap.forEach((value, key) =\u003e console.log(`${key}: ${value}`));\n// Output:\n// one: 1\n// two: 2\n// three: 3\n// four: 4\n\n// Delete an entry\ndataMap.delete(\"one\");\nconsole.log(\"Size after delete:\", dataMap.size); // Output: Size after delete: 3\n\n// Clear the map\ndataMap.clear();\nconsole.log(\"Size after clear:\", dataMap.size); // Output: Size after clear: 0\n\n```\n\n### `FactoryMap`\n\n```typescript\nimport { FactoryMap } from '@typescript-package/map';\n\n// Define custom `Map`.\nexport class CustomMap\u003cKey, Value\u003e extends Map\u003cKey, Value\u003e {\n  public newMethod() {}\n  constructor(entries?: [Key, Value][]) {\n    super(entries);\n  }\n}\n\n// Define data storage to store custom map.\nexport class TestCustomMapData\u003cKey, Value\u003e extends Data\u003cCustomMap\u003cKey, Value\u003e\u003e {\n  constructor(initialValue?: CustomMap\u003cKey, Value\u003e) {\n    super(initialValue ?? new CustomMap());\n  }\n}\n\n// Initialize the factory map with custom map and data.\nconst factoryMap = new FactoryMap(\n  [['a', {x: 1}], ['b', {x: 2}]],\n\n  // Use custom `Map`\n  CustomMap,\n\n  // Use custom storage for custom map.\n  TestCustomMapData,\n  {\n    // Define function for the default value.\n    defaultValue: () =\u003e ({x: 0}),\n\n    // Define cloner by using the `structuredClone`.\n    cloner: (value) =\u003e structuredClone(value),\n  }\n); // const factoryMap: FactoryMap\u003cstring, { x: number; }, CustomMap\u003cstring, { x: number }\u003e, TestCustomMapData\u003cstring, { x: number; }\u003e\u003e\n\nconsole.log(factoryMap.get('c')); // { x: 0 }\nconsole.log(factoryMap.get('b')); // { x: 2 }\nconsole.log(factoryMap.get('a')); // { x: 1 }\nconsole.debug(factoryMap.sort()); // sort.\n\n```\n\n### `WeakDataMap`\n\nThe `WeakDataMap` class is a concrete class that stores data in a static `WeakMap`.\n\n```typescript\nimport { WeakDataMap } from '@typescript-package/map';\n\n// Create an instance of `WeakDataMap`.\nconst weakDataMap = new WeakDataMap([\n  ['one', 1],\n  ['two', 2],\n  ['three', 3],\n]);\n\n\n// Get the value from `WeakData` static.\nconsole.log(`data: `, WeakData.get(weakDataMap.data)); // Output: Map(3) {'one' =\u003e 1, 'two' =\u003e 2, 'three' =\u003e 3}\n\n// Get a value by key\nconsole.log(weakDataMap.get('two')); // Output: 2\n\n// Add a new key-value pair\nweakDataMap.set('four', 4);\n\n// Check if a key exists\nconsole.log(weakDataMap.has('four')); // Output: true\n\n// Delete a key\nweakDataMap.delete('one');\n\n// Iterate over entries\nfor (const [key, value] of weakDataMap.entries()) {\n  console.log(key, value);\n}\n\n// Output:\n// two 2\n// three 3\n// four 4\n\n```\n\n## Contributing\n\nYour contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.\n\n## Support\n\nIf you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.\n\nSupport via:\n\n- [Stripe](https://donate.stripe.com/dR614hfDZcJE3wAcMM)\n- [Revolut](https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29)\n\nThanks for your support!\n\n## Code of Conduct\n\nBy participating in this project, you agree to follow **[Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/)**.\n\n## GIT\n\n### Commit\n\n- [AngularJS Git Commit Message Conventions][git-commit-angular]\n- [Karma Git Commit Msg][git-commit-karma]\n- [Conventional Commits][git-commit-conventional]\n\n### Versioning\n\n[Semantic Versioning 2.0.0][git-semver]\n\n**Given a version number MAJOR.MINOR.PATCH, increment the:**\n\n- MAJOR version when you make incompatible API changes,\n- MINOR version when you add functionality in a backwards-compatible manner, and\n- PATCH version when you make backwards-compatible bug fixes.\n\nAdditional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.\n\n**FAQ**\nHow should I deal with revisions in the 0.y.z initial development phase?\n\n\u003e The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.\n\nHow do I know when to release 1.0.0?\n\n\u003e If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.\n\n## License\n\nMIT © typescript-package ([license][typescript-package-license])\n\n## Packages\n\n- **[@typescript-package/affix](https://github.com/typescript-package/affix)**: A **lightweight TypeScript** library for the affix - prefix and suffix.\n- **[@typescript-package/are](https://github.com/typescript-package/are)**: Type-safe `are` checkers for validating value types in TypeScript.\n- **[@typescript-package/data](https://github.com/typescript-package/data)**: A lightweight **TypeScript** library for basic data management.\n- **[@typescript-package/descriptor](https://github.com/typescript-package/descriptor)**: A **lightweight TypeScript** library for property descriptor.\n- **[@typescript-package/guard](https://github.com/typescript-package/guard)**: Type-safe guards for guarding the value types in TypeScript.c\n- **[@typescript-package/history](https://github.com/typescript-package/history)**: A **TypeScript** package for tracking history of values.\n- **[@typescript-package/is](https://github.com/typescript-package/is)**: Type-safe is checkers for validating value types in TypeScript.\n- **[@typescript-package/name](https://github.com/typescript-package/name)**: A **lightweight TypeScript** library for the name with prefix and suffix.\n- **[@typescript-package/property](https://github.com/typescript-package/property)**: A **lightweight TypeScript** package with features to handle object properties.\n- **[@typescript-package/queue](https://github.com/typescript-package/queue)**: A **lightweight TypeScript** library for managing various queue and stack structures.\n- **[@typescript-package/range](https://github.com/typescript-package/range)**: A **lightweight TypeScript** library for managing various types of ranges.\n- **[@typescript-package/regexp](https://github.com/typescript-package/regexp)**: A **lightweight TypeScript** library for **RegExp**.\n- **[@typescript-package/set](https://github.com/typescript-package/set)**: A lightweight **TypeScript** library for enhanced `set` management.\n- **[@typescript-package/state](https://github.com/typescript-package/state)**: Simple state management for different types in **TypeScript**.\n- **[@typescript-package/storage](https://github.com/typescript-package/storage)**: The storage of data under allowed names.\n- **[@typescript-package/type](https://github.com/typescript-package/type)**: Utility types to enhance and simplify **TypeScript** development.\n- **[@typescript-package/wrapper](https://github.com/typescript-package/wrapper)**: A **lightweight TypeScript** library to wrap the text with the opening and closing chars.\n\n\u003c!-- This package: typescript-package  --\u003e\n  \u003c!-- GitHub: badges --\u003e\n  [typescript-package-badge-issues]: https://img.shields.io/github/issues/typescript-package/map\n  [isscript-package-badge-forks]: https://img.shields.io/github/forks/typescript-package/map\n  [typescript-package-badge-stars]: https://img.shields.io/github/stars/typescript-package/map\n  [typescript-package-badge-license]: https://img.shields.io/github/license/typescript-package/map\n  \u003c!-- GitHub: badges links --\u003e\n  [typescript-package-issues]: https://github.com/typescript-package/map/issues\n  [typescript-package-forks]: https://github.com/typescript-package/map/network\n  [typescript-package-license]: https://github.com/typescript-package/map/blob/master/LICENSE\n  [typescript-package-stars]: https://github.com/typescript-package/map/stargazers\n\u003c!-- This package --\u003e\n\n\u003c!-- Package: typescript-package --\u003e\n  \u003c!-- npm --\u003e\n  [typescript-package-npm-badge-svg]: https://badge.fury.io/js/@typescript-package%2Fmap.svg\n  [typescript-package-npm-badge]: https://badge.fury.io/js/@typescript-package%2Fmap\n\n\u003c!-- GIT --\u003e\n[git-semver]: http://semver.org/\n\n\u003c!-- GIT: commit --\u003e\n[git-commit-angular]: https://gist.github.com/stephenparish/9941e89d80e2bc58a153\n[git-commit-karma]: http://karma-runner.github.io/0.10/dev/git-commit-msg.html\n[git-commit-conventional]: https://www.conventionalcommits.org/en/v1.0.0/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypescript-package%2Fmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypescript-package%2Fmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypescript-package%2Fmap/lists"}