{"id":20182090,"url":"https://github.com/nichoth/pull-from-api","last_synced_at":"2025-03-03T06:13:11.862Z","repository":{"id":77400166,"uuid":"79967647","full_name":"nichoth/pull-from-api","owner":"nichoth","description":"Create streams for high latency async functions","archived":false,"fork":false,"pushed_at":"2017-01-25T00:31:54.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T17:26:26.882Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/nichoth/pull-from-api#readme","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nichoth.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-25T00:11:40.000Z","updated_at":"2018-03-12T16:27:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"7175e66b-05a4-4218-a7df-41b884ead4a7","html_url":"https://github.com/nichoth/pull-from-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-from-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-from-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-from-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-from-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nichoth","download_url":"https://codeload.github.com/nichoth/pull-from-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241616680,"owners_count":19991543,"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-11-14T02:37:37.262Z","updated_at":"2025-03-03T06:13:11.845Z","avatar_url":"https://github.com/nichoth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pull from api\n\nReturn a stream that emits three events: `start`, `resolve`, and either `data` or `error`.\n\n## example\n\n```js\nvar test = require('tape')\nvar S = require('pull-stream')\nvar fromFn = require('../')\nvar fromObject = require('../from-object')\n\nfunction mock (arg, cb) {\n    process.nextTick(cb.bind(null, null, arg + ' response'))\n}\n\nvar testErr = new Error('test')\nfunction mockErr (cb) {\n    process.nextTick(cb.bind(null, testErr))\n}\n\ntest('create stream from function', function (t) {\n    t.plan(2)\n\n    var stream = fromFn(mock)('test')\n    S(\n        stream,\n        S.collect(function (err, res) {\n            t.error(err)\n            t.deepEqual(res, [\n                ['start', { args: ['test'], op: null}],\n                ['data', 'test response'],\n                ['resolve', { args: ['test'], op: null}],\n            ], 'should return the right events')\n        })\n    )\n})\n\ntest('create streams from object', function (t) {\n    t.plan(2)\n    var fns = {\n        foo: mock,\n        bar: mock\n    }\n    var streamFns = fromObject(fns)\n    S(\n        streamFns.foo('test'),\n        S.collect(function (err, res) {\n            t.error(err)\n            t.deepEqual(res, [\n                ['start', { args: ['test'], op: 'foo'}],\n                ['foo', 'test response'],\n                ['resolve', { args: ['test'], op: 'foo'}],\n            ], 'should namespace with the keys')\n        })\n    )\n})\n\ntest('error event', function (t) {\n    t.plan(2)\n    var stream = fromFn(mockErr)()\n    S(\n        stream,\n        S.collect(function (err, res) {\n            t.error(err)\n            t.deepEqual(res, [\n                ['start', { args: [], op: null }],\n                ['error', testErr],\n                ['resolve', { args: [], op: null }],\n            ], 'should return the right events')\n        })\n    )\n})\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Fpull-from-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnichoth%2Fpull-from-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Fpull-from-api/lists"}