{"id":17445957,"url":"https://github.com/jamen/pull-map","last_synced_at":"2025-04-02T11:22:36.180Z","repository":{"id":96785099,"uuid":"81256546","full_name":"jamen/pull-map","owner":"jamen","description":"Create sync, async, or through maps in pull-streams","archived":false,"fork":false,"pushed_at":"2017-02-07T22:27:38.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-23T11:31:37.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jamen.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2017-02-07T21:32:56.000Z","updated_at":"2021-12-19T15:39:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"13dfea52-122c-46d0-931f-205ff58690b2","html_url":"https://github.com/jamen/pull-map","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"e8b00c65f3777d3e3fb28e4b9d5f05c1e8aa54a2"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamen","download_url":"https://codeload.github.com/jamen/pull-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246803112,"owners_count":20836494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-17T18:18:51.804Z","updated_at":"2025-04-02T11:22:36.149Z","avatar_url":"https://github.com/jamen.png","language":"JavaScript","funding_links":["https://www.paypal.me/jamenmarz/5usd"],"categories":[],"sub_categories":[],"readme":"\n# pull-map\n\n\u003e Create sync, async, or through maps in pull-streams\n\n```js\nvar map = require('pull-map')\n\npull(\n  pull.values([1, 2, 3, 4, 5]),\n\n  // Sync map\n  map(num =\u003e num * 3),\n\n  // Async map\n  map((num, done) =\u003e {\n    hash(num, done)\n  }),\n\n  pull.log()\n)\n```\n\nThe [`map`](#api_map) function is like [`pull.map`](https://github.com/pull-stream/pull-stream/blob/master/docs/throughs/map.md) and [`pull.asyncMap`](https://github.com/pull-stream/pull-stream/blob/master/docs/throughs/async-map.md) combined, by sync or async depending if the `done` callback is provided.  There is also [`map.through`](#api_map_through), which passes data on `undefined`.\n\n## Installation\n\n```sh\n$ npm install --save pull-map\n```\n\n## Usage\n\n\u003ca name=\"api_map\"\u003e\u003c/a\u003e\n### `map(fn)`\n\nA [through stream]() that maps values with `map(x =\u003e ...)` or async map with `map((x, cb) =\u003e ...)`.  Async map's callback takes `cb(err, data)`.  One function for all your pull-stream mapping needs!\n\n```js\n// A sync map\nvar foo = map(source =\u003e source.toLowerCase())\n\n// An async map\nvar bar = map((source, done) =\u003e {\n  fs.readFile(source, done)\n})\n```\n\n\u003ca name=\"api_map_through\"\u003e\u003c/a\u003e\n### `map.through(fn)`\n\nThe same sync/async functionality as [`map`](#api_map), except passes on data if it receives `undefined`.  Useful when you only want to replace some of the data in the pipeline.\n\n```js\npull(\n  pull.values([1, 2.5, 3, 4.5, 5])\n  map.through(function (num) {\n    if (num !== Math.floor(num)) return -num\n  })\n  pull.collect(function (err, nums) {\n    console.log(nums)\n    // =\u003e [1, -2.5, 3, -4.5, 5]\n  })\n)\n```\n\n\u003ca name=\"api_sync_async\"\u003e\n### `map.sync(fn)`\n### `map.async(fn)`\n\nThe sync and async map methods behind [`map`](#api_map).\n\n```js\npull(\n  count(),\n  map.sync(x =\u003e x * 3)\n  map.async(function (x, done) {\n    hash(x, done)\n  }),\n  pull.log()\n)\n```\n\n## License\n\nMIT © [Jamen Marz](https://git.io/jamen)\n\n---\n\n[![version](https://img.shields.io/npm/v/pull-map.svg?style=flat-square)][package] [![travis](https://img.shields.io/travis/pull-map/jamen.svg?style=flat-square)](https://travis-ci.org/pull-map/jamen) [![downloads/month](https://img.shields.io/npm/dm/pull-map.svg?style=flat-square)][package] [![downloads](https://img.shields.io/npm/dt/pull-map.svg?style=flat-square)][package] [![license](https://img.shields.io/npm/l/pull-map.svg?style=flat-square)][package] [![support me](https://img.shields.io/badge/support%20me-paypal-green.svg?style=flat-square)](https://www.paypal.me/jamenmarz/5usd) [![follow](https://img.shields.io/github/followers/jamen.svg?style=social\u0026label=Follow)](https://github.com/jamen)\n[package]: https://npmjs.com/package/pull-map\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Fpull-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamen%2Fpull-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Fpull-map/lists"}