{"id":47605251,"url":"https://github.com/ofershap/tiny-map","last_synced_at":"2026-04-01T19:09:48.113Z","repository":{"id":342388147,"uuid":"1173810781","full_name":"ofershap/tiny-map","owner":"ofershap","description":"Map over promises with concurrency control. Drop-in p-map replacement. ESM + CJS, zero deps, TypeScript.","archived":false,"fork":false,"pushed_at":"2026-03-12T18:18:22.000Z","size":778,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-13T00:28:57.342Z","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/ofershap.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"ofershap"}},"created_at":"2026-03-05T19:21:48.000Z","updated_at":"2026-03-12T18:18:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ofershap/tiny-map","commit_stats":null,"previous_names":["ofershap/tiny-map"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ofershap/tiny-map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofershap%2Ftiny-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofershap%2Ftiny-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofershap%2Ftiny-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofershap%2Ftiny-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ofershap","download_url":"https://codeload.github.com/ofershap/tiny-map/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofershap%2Ftiny-map/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-04-01T19:09:47.651Z","updated_at":"2026-04-01T19:09:48.098Z","avatar_url":"https://github.com/ofershap.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ofershap"],"categories":[],"sub_categories":[],"readme":"# tiny-map\n\n[![npm version](https://img.shields.io/npm/v/tiny-pmap.svg)](https://www.npmjs.com/package/tiny-pmap)\n[![npm downloads](https://img.shields.io/npm/dm/tiny-pmap.svg)](https://www.npmjs.com/package/tiny-pmap)\n[![CI](https://github.com/ofershap/tiny-map/actions/workflows/ci.yml/badge.svg)](https://github.com/ofershap/tiny-map/actions/workflows/ci.yml)\n[![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nMap over promises with concurrency control. Same API as [`p-map`](https://github.com/sindresorhus/p-map), but ships both ESM and CJS with zero dependencies.\n\n```ts\nimport { pMap } from \"tiny-pmap\";\n\nconst pages = await pMap(urls, (url) =\u003e fetch(url).then((r) =\u003e r.text()), {\n  concurrency: 5,\n});\n```\n\n\u003e ~1.2 KB gzipped. Zero dependencies. Replaces p-map without the ESM-only headache.\n\n![Demo](assets/demo.gif)\n\n\u003csub\u003eDemo built with \u003ca href=\"https://github.com/ofershap/remotion-readme-kit\"\u003eremotion-readme-kit\u003c/a\u003e\u003c/sub\u003e\n\n## Install\n\n```bash\nnpm install tiny-pmap\n```\n\n## Usage\n\n```ts\nimport { pMap } from \"tiny-pmap\";\n\nconst users = await pMap([1, 2, 3, 4, 5], (id) =\u003e fetchUser(id), {\n  concurrency: 3,\n});\n```\n\n### Skip items from results\n\n```ts\nimport { pMap, pMapSkip } from \"tiny-pmap\";\n\nconst adults = await pMap(users, (user) =\u003e {\n  if (user.age \u003c 18) return new pMapSkip();\n  return user;\n});\n```\n\n### Async iterables\n\n```ts\nasync function* generateIds() {\n  for (let i = 0; i \u003c 100; i++) yield i;\n}\n\nconst results = await pMap(generateIds(), (id) =\u003e process(id), {\n  concurrency: 10,\n});\n```\n\n### Collect all errors\n\n```ts\ntry {\n  await pMap(items, riskyOperation, { stopOnError: false, concurrency: 5 });\n} catch (error) {\n  // AggregateError with all failures\n  console.log(error.errors);\n}\n```\n\n### Cancel with AbortSignal\n\n```ts\nconst controller = new AbortController();\nsetTimeout(() =\u003e controller.abort(), 5000);\n\nawait pMap(urls, fetchPage, {\n  concurrency: 3,\n  signal: controller.signal,\n});\n```\n\n## Differences from `p-map`\n\n`p-map` v7+ is ESM-only. If you `require(\"p-map\")` in a CommonJS project, you get `ERR_REQUIRE_ESM`. `tiny-map` works with both `import` and `require()`.\n\n|              | `p-map`                | `tiny-map` |\n| ------------ | ---------------------- | ---------- |\n| CJS support  | v5 only (v6+ ESM-only) | ESM + CJS  |\n| Dependencies | none                   | 0          |\n| TypeScript   | separate @types        | native     |\n| Export       | default                | named      |\n\n## Migrating from p-map\n\n```diff\n- import pMap from \"p-map\";\n+ import { pMap } from \"tiny-pmap\";\n```\n\nOne line. Everything else stays the same.\n\n## API\n\n### `pMap(input, mapper, options?)`\n\nMaps over `input` with the `mapper` function, limiting concurrency.\n\n- `input` - `Iterable` or `AsyncIterable`\n- `mapper(element, index)` - function returning a value or promise\n- `options.concurrency` - max parallel executions (default: `Infinity`)\n- `options.stopOnError` - throw on first error or collect all (default: `true`)\n- `options.signal` - `AbortSignal` for cancellation\n\nReturns `Promise\u003cNewElement[]\u003e` with results in input order.\n\n### `pMapSkip`\n\nReturn `new pMapSkip()` from the mapper to exclude that element from results.\n\n## The tiny-\\* family\n\nDrop-in replacements for sindresorhus async utilities. All ship ESM + CJS with zero dependencies.\n\n| Package                                                | Replaces             | What it does                   |\n| ------------------------------------------------------ | -------------------- | ------------------------------ |\n| [tiny-limit](https://github.com/ofershap/tiny-limit)   | p-limit              | Concurrency limiter            |\n| **tiny-map**                                           | p-map                | Concurrent map with order      |\n| [tiny-retry](https://github.com/ofershap/tiny-retry)   | p-retry              | Retry with exponential backoff |\n| [tiny-queue](https://github.com/ofershap/tiny-queue)   | p-queue              | Priority task queue            |\n| [tiny-ms](https://github.com/ofershap/tiny-ms)         | ms                   | Parse/format durations         |\n| [tiny-escape](https://github.com/ofershap/tiny-escape) | escape-string-regexp | Escape regex chars             |\n\nWant all async utilities in one import? Use [`tiny-pasync`](https://github.com/ofershap/tiny-async).\n\n## Author\n\n[![Made by ofershap](https://gitshow.dev/api/card/ofershap)](https://gitshow.dev/ofershap)\n\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2?style=flat\u0026logo=linkedin\u0026logoColor=white)](https://linkedin.com/in/ofershap)\n[![GitHub](https://img.shields.io/badge/GitHub-Follow-181717?style=flat\u0026logo=github\u0026logoColor=white)](https://github.com/ofershap)\n\n---\n\nIf this saved you from `ERR_REQUIRE_ESM`, [star the repo](https://github.com/ofershap/tiny-map) or [open an issue](https://github.com/ofershap/tiny-map/issues) if something breaks.\n\n---\n\n\u003csub\u003eREADME built with [README Builder](https://ofershap.github.io/readme-builder/)\u003c/sub\u003e\n\n## License\n\n[MIT](LICENSE) \u0026copy; [Ofer Shapira](https://github.com/ofershap)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofershap%2Ftiny-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofershap%2Ftiny-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofershap%2Ftiny-map/lists"}