{"id":14997,"library":"typescript-map","title":"TypeScript Map Implementation","description":"This library, `typescript-map`, provides a lightweight, TypeScript-first implementation of an ES6 Map-like data structure. Currently at version 0.1.0, it is designed for scenarios where a full ES6 Map polyfill is not desired or where bundle size is a critical concern, weighing in at just over 1 kilobyte gzipped. A key differentiator is its deliberate simplicity: it does not employ a hashing function. While this keeps the implementation small and straightforward, it means the library is explicitly *not* recommended for use with more than a few hundred keys or in performance-critical \"hot path\" operations, where native `Map` or more robust alternatives like `es6-map` would be superior. The release cadence appears to be slow or inactive given the low version number and its niche purpose. It is primarily intended for TypeScript projects needing a basic, type-safe map collection without significant overhead.","status":"maintenance","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/only_cliches/typescript-map","tags":["javascript","collection","es6","shim","harmony","list","hash","map","polyfill"],"install":[{"cmd":"npm install typescript-map","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-map","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-map","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary class is a named export, not a default export. For TypeScript and modern JavaScript (ESM).","wrong":"import TSMap from 'typescript-map'","symbol":"TSMap","correct":"import { TSMap } from 'typescript-map'"},{"note":"For CommonJS environments, access the `TSMap` class from the module's property.","wrong":"const { TSMap } = require('typescript-map');","symbol":"TSMap","correct":"const TSMap = require('typescript-map').TSMap;"},{"note":"When used directly in a browser without a module loader, the library exposes `TSMap` as a global variable. Be mindful of global scope pollution.","symbol":"TSMap","correct":"<script src=\"tsmap.min.js\"></script> // Then use global TSMap"}],"quickstart":{"code":"import { TSMap } from 'typescript-map';\n\n// Basic usage, similar to native Map\nconst myMap = new TSMap();\nmyMap.set('foo', 'bar');\nconsole.log(myMap.get('foo')); // Prints: bar\n\n// With TypeScript generics for type safety\nconst typedMap = new TSMap<string, number>();\ntypedMap.set('apple', 1);\ntypedMap.set('banana', 2);\nconsole.log(typedMap.get('apple')); // Prints: 1\n\n// Initialize with an array of key-value pairs\nconst initMap = new TSMap<string, string>([\n  ['key1', 'valueA'],\n  ['key2', 'valueB']\n]);\nconsole.log(initMap.size); // Prints: 2\n\n// Example of a custom function: fromJSON\nconst jsonMap = new TSMap().fromJSON({\n    name: 'Alice',\n    age: 30,\n    city: 'New York'\n}, false);\nconsole.log(jsonMap.get('name')); // Prints: Alice","lang":"typescript","description":"Demonstrates basic instantiation, setting and getting values, type-safe usage with generics, initialization with an array, and a custom `fromJSON` method."},"warnings":[{"fix":"If a full ES6 Map polyfill is required, use `es6-map` or a similar solution. This library is an alternative for specific use cases.","message":"This library is not an ES6 Map polyfill. It provides a similar interface but is a separate implementation. Do not expect it to patch `Map` or behave identically to the native `Map` specification in every edge case.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"For large datasets or 'hot path' scenarios, use the native `Map` object or a robust polyfill/library that employs hashing (e.g., `es6-map`).","message":"Performance will degrade significantly for maps containing hundreds or thousands of keys, or when used in performance-critical code paths. The implementation does not use a hashing function to keep it small and simple.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Prefer using module bundlers (like Webpack or Rollup) with ES modules or CommonJS imports to encapsulate the library's scope and avoid global variable conflicts.","message":"When included directly in a browser via a `<script>` tag, the `TSMap` class is exposed as a global variable. This can lead to global namespace pollution or conflicts with other libraries.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.0':27 '1':55 'altern':111 'appear':122 'basic':146 'bundl':44 'cadenc':121 'collect':151,156 'concern':49 'critic':48,101 'current':24 'data':22 'deliber':63 'design':30 'desir':41 'differenti':60 'employ':68 'es6':18,36,114,157 'es6-map':113 'explicit':85 'first':14 'full':35 'function':71 'given':128 'gzip':57 'harmoni':159 'hash':70,161 'hot':102 'hundr':95 'implement':3,15,76 'inact':127 'intend':140 'javascript':155 'keep':74 'key':59,96 'kilobyt':56 'librari':5,83 'lightweight':11 'like':21,112 'list':160 'low':130 'map':2,8,20,37,107,115,150,162 'map-lik':19 'mean':81 'nativ':106 'need':144 'nich':135 'number':132 'oper':104 'overhead':154 'path':103 'perform':100 'performance-crit':99 'polyfil':38,163 'primarili':139 'project':143 'provid':9 'purpos':136 'recommend':87 'releas':120 'robust':110 'safe':149 'scenario':32 'shim':158 'signific':153 'simplic':64 'size':45 'slow':125 'small':77 'straightforward':79 'structur':23 'superior':118 'type':148 'type-saf':147 'typescript':1,7,13,142 'typescript-first':12 'typescript-map':6 'use':89 'version':26,131 'weigh':50 'without':152 'would':116","created_at":"2026-04-20T18:44:42.669508+00:00","updated_at":"2026-04-20T18:44:42.669508+00:00","problems":[{"fix":"Ensure you are instantiating the class with `new TSMap()` and that your CommonJS import is `const TSMap = require('typescript-map').TSMap;`.","cause":"Attempting to call `TSMap` directly without the `new` keyword, or incorrect CommonJS import.","error":"TypeError: TSMap is not a constructor"},{"fix":"Verify that `TSMap` has been correctly imported and instantiated (e.g., `const myMap = new TSMap();`).","cause":"Trying to call methods on an uninitialized or incorrectly imported `TSMap` instance.","error":"Error: Cannot read properties of undefined (reading 'set')"},{"fix":"This library is not a polyfill for the native `Map`. If native `Map` compatibility is required, consider using `es6-map` or adapting your code to accept `TSMap` where appropriate, or converting `TSMap` to a standard object if only basic iteration is needed.","cause":"Passing a `TSMap` instance to a function or API that specifically expects a native `Map` object.","error":"Argument of type 'TSMap<string, number>' is not assignable to parameter of type 'Map<string, number>'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/only_cliches/typescript-map","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/typescript-map","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}