{"id":15497282,"url":"https://github.com/jwerle/domstream","last_synced_at":"2025-03-14T03:18:00.675Z","repository":{"id":148540503,"uuid":"11458592","full_name":"jwerle/domstream","owner":"jwerle","description":"Turn DOM element events into streams","archived":false,"fork":false,"pushed_at":"2013-07-16T20:18:39.000Z","size":144,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T01:01:59.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/jwerle.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-16T19:47:30.000Z","updated_at":"2014-09-04T22:51:15.000Z","dependencies_parsed_at":"2023-03-29T00:54:16.938Z","dependency_job_id":null,"html_url":"https://github.com/jwerle/domstream","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/jwerle%2Fdomstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fdomstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fdomstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fdomstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwerle","download_url":"https://codeload.github.com/jwerle/domstream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515525,"owners_count":20303258,"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-02T08:32:29.026Z","updated_at":"2025-03-14T03:18:00.650Z","avatar_url":"https://github.com/jwerle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# domstream\n\nTurn DOM element events into streams\n\n## Installation\n\n`$ component install jwerle/domstream`\n\n## Usage\n\n***binding the 'mousemove' and 'mouseout' events as starting and ending points to a stream on a DOM element***\n\n```js\nvar domstream = require('domstream')\n  , el = document.getElementById('el')\n  , stream = domstream(el).source({start: 'mousemove', end: 'mouseout'})\n\nstream.through(\n  function write (data) {\n    this.push({x:data.x, y:data.y});\n  },\n  function end (buf) {\n    for (var i = 0; i \u003c buf.length; ++i) {\n      var d = buf.shift()\n      console.log(d.x, d.y)\n    }\n  });\n```\n\nThe above is just short hand for:\n\n```js\nstream.on('data', function (data) {\n  stream.push({x: data.x, y: data.y})\n});\n\nstream.on('end', function () {\n  var buf = stream.read();\n  for (var i = 0; i \u003c buf.length; ++i) {\n    var d = buf.shift()\n    console.log(d.x, d.y)\n  }\n});\n```\n\n## API\n\n### domstream(el)\n\nAccepts a DOM Node and returns a readable/writable `DOMStream` influenced from node.js\n\n```js\nvar stream = domstream(document.getElementById('node'));\n```\n\n#### Events\n\n##### 'readable'\n\nWhen there is data ready to be consumed, this event will fire.\n\n##### 'data'\n\nEmitted when data is written to stream.\n\n##### 'end'\n\nEmitted when the end of stream event has been emitted.\n\n##### 'error'\n\nEmitted if there was an error receiving data.\n\n### #source(opts)\n\n* `.start` - The event that when emitted instantiates the 'data' event of the stream\n* `.end` - The event that when emitted instantiates the end of the stream which will emit the 'end' event\n\n```js\nstream.source({start: 'dragstart', end: 'dragend'});\n```\n\n### #write(data)\n\nWrites data to stream\n\n```js\nstream.write({some: 'data'});\n```\n\n### #push(data) | queue(data)\n\nPushes a chunk to the stream buffer\n\n```js\nstream.push({data: 'for later'});\n```\n\n### #unshift(data)\n\nUnshifts a chunk to the stream buffer\n\n```js\nstream.unshift({data: 'for later'});\n```\n\n### #read(size, offset)\n\nReads a given optional size to read from the stream buffer\n\n```js\nvar data = stream.read(5);\n```\n\n```js\nvar buf = stream.read();\n```\n\n### #end(data)\n\nWrites data to stream and emits end event\n\n```js\nstream.end({even: 'more data'});\n```\n\n### #use(fn)\n\nPushes a function to the `startStack` array for acting like middle ware to data emitted from for the start event defined with `bind()` or `source()`\n\n```js\nstream.use(function (data, next) {\n  data.property = \"value\";\n  next();\n});\n```\n\n### #through(write, end)\n\nDefines a write and end handle for the stream handle\n\n```js\nstream.through(\nfunction write (data) {\n  this.push(data);\n},\nfunction end () {\n  console.log(this.read());\n});\n```\n\n### #pipe(dest, opts)\n\nPipes stream to a Writeable stream (lightly ported from node.js)\n\n```js\nstream.pipe(otherStream);\n```\n\n## License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Fdomstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwerle%2Fdomstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Fdomstream/lists"}