New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

map-tiny

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-tiny

Map over promises with concurrency control. Same API as p-map, ships ESM + CJS with zero dependencies.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

tiny-map

npm version npm downloads CI TypeScript License: MIT

Map over promises with concurrency control. Same API as p-map, but ships both ESM and CJS with zero dependencies.

import { pMap } from "tiny-map";

const pages = await pMap(urls, (url) => fetch(url).then((r) => r.text()), {
  concurrency: 5,
});

~1.2 KB gzipped. Zero dependencies. Replaces p-map without the ESM-only headache.

Demo

Demo built with remotion-readme-kit

Install

npm install tiny-map

Usage

import { pMap } from "tiny-map";

const users = await pMap([1, 2, 3, 4, 5], (id) => fetchUser(id), {
  concurrency: 3,
});

Skip items from results

import { pMap, pMapSkip } from "tiny-map";

const adults = await pMap(users, (user) => {
  if (user.age < 18) return new pMapSkip();
  return user;
});

Async iterables

async function* generateIds() {
  for (let i = 0; i < 100; i++) yield i;
}

const results = await pMap(generateIds(), (id) => process(id), {
  concurrency: 10,
});

Collect all errors

try {
  await pMap(items, riskyOperation, { stopOnError: false, concurrency: 5 });
} catch (error) {
  // AggregateError with all failures
  console.log(error.errors);
}

Cancel with AbortSignal

const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);

await pMap(urls, fetchPage, {
  concurrency: 3,
  signal: controller.signal,
});

Differences from p-map

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().

p-maptiny-map
CJS supportv5 only (v6+ ESM-only)ESM + CJS
Dependenciesnone0
TypeScriptseparate @typesnative
Exportdefaultnamed

Migrating from p-map

- import pMap from "p-map";
+ import { pMap } from "tiny-map";

One line. Everything else stays the same.

API

pMap(input, mapper, options?)

Maps over input with the mapper function, limiting concurrency.

  • input - Iterable or AsyncIterable
  • mapper(element, index) - function returning a value or promise
  • options.concurrency - max parallel executions (default: Infinity)
  • options.stopOnError - throw on first error or collect all (default: true)
  • options.signal - AbortSignal for cancellation

Returns Promise<NewElement[]> with results in input order.

pMapSkip

Return new pMapSkip() from the mapper to exclude that element from results.

The tiny-* family

Drop-in replacements for sindresorhus async utilities. All ship ESM + CJS with zero dependencies.

PackageReplacesWhat it does
tiny-limitp-limitConcurrency limiter
tiny-mapp-mapConcurrent map with order
tiny-retryp-retryRetry with exponential backoff
tiny-queuep-queuePriority task queue
tiny-msmsParse/format durations
tiny-escapeescape-string-regexpEscape regex chars

Want all async utilities in one import? Use tiny-async.

Author

Made by ofershap

LinkedIn GitHub

If this saved you from ERR_REQUIRE_ESM, star the repo or open an issue if something breaks.

License

MIT © Ofer Shapira

Keywords

p-map

FAQs

Package last updated on 05 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts