{"id":26665349,"url":"https://github.com/elsehow/simple-charm","last_synced_at":"2025-03-25T17:36:57.099Z","repository":{"id":57359846,"uuid":"45877031","full_name":"elsehow/simple-charm","owner":"elsehow","description":"live-code with streaming data!","archived":false,"fork":false,"pushed_at":"2015-12-11T02:03:34.000Z","size":30,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-08T23:12:19.037Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elsehow.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}},"created_at":"2015-11-10T00:41:28.000Z","updated_at":"2015-11-27T12:40:34.000Z","dependencies_parsed_at":"2022-09-06T22:23:06.037Z","dependency_job_id":null,"html_url":"https://github.com/elsehow/simple-charm","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/elsehow%2Fsimple-charm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fsimple-charm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fsimple-charm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fsimple-charm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elsehow","download_url":"https://codeload.github.com/elsehow/simple-charm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245511374,"owners_count":20627378,"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":"2025-03-25T17:36:56.466Z","updated_at":"2025-03-25T17:36:57.091Z","avatar_url":"https://github.com/elsehow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple charm\n\nlive-code with streaming data!\n\n## installation\n\n    npm install simple-charm\n\n## usage:\n\nin one file (index.js):\n\n```javascript\nvar charm = require('simple-charm')\n  , spawn = require('child_process').spawn\n\nfunction pathTo (filename) { \n  return require('path').join(__dirname, filename)\n}\n\n// one-script prints 1 to process.stdout, over and over\nvar process  = spawn('node', [pathTo('one-script.js')])\n\n// `charm` em with app.js\nvar app = pathTo('/app.js')\n// make sure to pass an absolute path\ncharm(app, process.stdout, 'data')\n```\n\nin another file (app.js):\n \n```javascript\nmodule.exports = function (oneStream) {\n  function addTwo (x) { return x+2 }\n  var threeStream = oneStream.map(addTwo)\n  threeStream.log()\n}\n```\n\nnow you can `node index.js` and, while it's running, live-code app.js!\n\nyou can even make syntax errors - it will catch them without stopping your streams!\n\nhere, `oneStream` is a [Kefir stream](https://rpominov.github.io/kefir/), made out of our event emitter and accompanying event. map, filter, scan, [whatever](https://rpominov.github.io/kefir/), and log as you go.\n\nuse this to mix-and-match various types of emitters - [sockets](https://github.com/maxogden/websocket-stream), [serial connections](https://www.npmjs.com/package/serialport2), [any node stream](https://github.com/substack/stream-handbook), what have you\n\nsee examples/ for working with multiple streams, returning stuff back to inde.js (e.g. for logging), etc.\n\n## why\n\nlivecoding is [really great](http://toplap.org/bricolage-the-world-of-live-coding/)\n\nlong history in lisp and all that, still a core priority in clojure and clojurescript\n\nin javascript, event emitters are at the core of most asynchronous operations. i personally deal with streaming biosensor data, which sometimes comes over a bluetooth connection (serial) and sometimes through a websocket. in both cases, i need to parse and process the data. \n\n### live-coding with emitters\n\nsimple-charm lets you live-code with event emitters in node\n\nit turns the events from an emitter into [Kefir streams](https://rpominov.github.io/kefir/) - a flexible, discretized data sturcture that lets you map, filter, buffer, etc... across many values over time.\n\nthen, you write a script that processes the stream. you can change this script in real time, and your emitter's values will be sent through updated versions, without a hitch.\n\nmay it serve you well\n\n## api\n\nsingle stream:\n\n### charm(path, emitter, event)\n\nor multiple streams:\n\n### charm(path, [emitter, event], [emitter2, event2], ...)\n\npath refers to some file that exposes a function.\nthe arguments to this function will be Kefir streams, \n one for each `[emitter, event]` pair passed to charm.\n\nsee examples/multiple-streams/ for an example with multiple in-streams\n\nthis function returns a Kefir stream as well - \na stream of return values from the function in app.js\nevery time app.js is saved and hot-reloaded, \nthe new return value is emitted into to this stream.\n\nsee examples/logging/ for one use case of this\n\n\n\n## debugging\n\nbe sure to pass `charm` the absolute path of your script. see example.\n\n## LICENSE\n\nBSD-2-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsehow%2Fsimple-charm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felsehow%2Fsimple-charm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsehow%2Fsimple-charm/lists"}