-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
45 lines (45 loc) · 6.07 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
"name": "shoe",
"version": "0.0.5",
"description": "streaming sockjs for node and the browser",
"main": "index.js",
"browserify": "browser.js",
"directories": {
"example": "example"
},
"dependencies": {
"sockjs-windows": "~0.3.1",
"sockjs-client": "git://github.com/substack/sockjs-client.git#browserify-npm"
},
"repository": {
"type": "git",
"url": "git://github.com/substack/shoe.git"
},
"homepage": "https://github.com/substack/shoe",
"keywords": [
"websocket",
"stream",
"sock",
"browserify"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT",
"engine": {
"node": ">=0.6"
},
"readme": "shoe\n====\n\nStreaming sockjs for node and the browser.\n\nThis is a more streaming,\n[more unixy](http://www.faqs.org/docs/artu/ch01s06.html)\ntake on [sockjs](https://github.com/sockjs/sockjs-node).\n\n* works with [browserify](https://github.com/substack/node-browserify)\n([modularity](http://www.faqs.org/docs/artu/ch01s06.html#id2877537))\n* stream all the things\n([composition](http://www.faqs.org/docs/artu/ch01s06.html#id2877684))\n* emits a `'log'` event instead of spamming stdout\n([silence](http://www.faqs.org/docs/artu/ch01s06.html#id2878450))\n\n![shoe point javascript](http://substack.net/images/shoe.png)\n\nexample\n=======\n\nstream all the things\n---------------------\n\nBrowser code that takes in a stream of 0s and 1s from the server and inverts\nthem:\n\n``` js\nvar shoe = require('shoe');\nvar domready = require('domready');\nvar es = require('event-stream');\n\ndomready(function () {\n var result = document.getElementById('result');\n \n var stream = shoe('/invert');\n var s = es.mapSync(function (msg) {\n result.appendChild(document.createTextNode(msg));\n return String(Number(msg)^1);\n });\n s.pipe(stream).pipe(s);\n});\n```\n\nServer code that hosts some static files and emits 0s and 1s:\n\n``` js\nvar shoe = require('shoe');\nvar http = require('http');\n\nvar ecstatic = require('ecstatic')(__dirname + '/static');\n\nvar server = http.createServer(ecstatic);\nserver.listen(9999);\n\nvar sock = shoe(function (stream) {\n var iv = setInterval(function () {\n stream.write(Math.floor(Math.random() * 2));\n }, 250);\n \n stream.on('end', function () {\n clearInterval(iv);\n });\n \n stream.pipe(process.stdout, { end : false });\n});\nsock.install(server, '/invert');\n```\n\nThe server emits 0s and 1s to the browser, the browser inverts them and sends\nthem back, and the server dumps the binary digits to stdout.\n\nBy default, there's no logspam on stdout to clutter the output, which is a\nfrustrating trend in realtimey websocket libraries that violates the\n[rule of silence](http://www.faqs.org/docs/artu/ch01s06.html#id2878450).\n\nJust wait for a client to connect and you'll see:\n\n```\n$ node server.js\n001011010101101000101110010000100\n```\n\nwith dnode\n----------\n\nSince dnode has a simple streaming api it's very simple to plug into shoe.\n\nJust hack up some browser code:\n\n``` js\nvar domready = require('domready');\nvar shoe = require('shoe');\nvar dnode = require('dnode');\n\ndomready(function () {\n var result = document.getElementById('result');\n var stream = shoe('/dnode');\n \n var d = dnode();\n d.on('remote', function (remote) {\n remote.transform('beep', function (s) {\n result.textContent = 'beep => ' + s;\n });\n });\n d.pipe(stream).pipe(d);\n});\n```\nand hack up a server piping shoe streams into dnode:\n\n``` js\nvar shoe = require('shoe');\nvar dnode = require('dnode');\n\nvar http = require('http');\nvar ecstatic = require('ecstatic')(__dirname + '/static');\n\nvar server = http.createServer(ecstatic);\nserver.listen(9999);\n\nvar sock = shoe(function (stream) {\n var d = dnode({\n transform : function (s, cb) {\n var res = s.replace(/[aeiou]{2,}/, 'oo').toUpperCase();\n cb(res);\n }\n });\n d.pipe(stream).pipe(d);\n});\nsock.install(server, '/dnode');\n```\n\nThen open up `localhost:9999` in your browser and you should see:\n\n```\nbeep => BOOP\n```\n\nbrowser methods\n===============\n\n``` js\nvar shoe = require('shoe')\n```\n\nvar stream = shoe(uri, cb)\n--------------------------\n\nReturn a readable/writable stream from the sockjs path `uri`.\n`uri` may be a full uri or just a path.\n\n`cb()` will fire when the stream is actually open, but writes will be buffered\nbefore then.\n\nserver methods\n==============\n\n``` js\nvar shoe = require('shoe')\n```\n\nAll the methods from the sockjs exports objects are attached onto the `shoe`\nfunction, but the `shoe()` function itself is special.\n\nvar sock = shoe(opts, cb)\n-------------------------\n\nCreate a server with `sockjs.createServer(opts)` except this function also adds\nthe `.install()` function below.\n\nIf `cb` is specified, it fires `cb(stream)` on `'connection'` events.\n\nsock.install(server, opts)\n--------------------------\n\nCall `sock.installHandler()` with the default option of spamming stdout with log\nmessages switched off in place of just emitting `'log'` messages\non the `sock` object instead. This is a much less spammy default that gets out\nof your way.\n\nIf `opts` is a string, use it as the `opts.prefix`.\n\nserver events\n=============\n\nAll the messages that sockjs normally emits will be available on the `sock`\nobject plus the events below:\n\nsock.on('log', function (severity, msg) { ... })\n------------------------------------------------\n\nUsing the default logger with `sock.install()` will cause these `'log'` messages\nto be emitted instead of spamming stdout.\n\ninstall\n=======\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install shoe\n```\n\nlicense\n=======\n\nMIT\n",
"readmeFilename": "README.markdown",
"bugs": {
"url": "https://github.com/substack/shoe/issues"
},
"_id": "shoe@0.0.5",
"dist": {
"shasum": "320ff6543899ca58280e1ddf3cc990876796651a"
},
"_from": "shoe@0.0.5",
"_resolved": "https://registry.npmjs.org/shoe/-/shoe-0.0.5.tgz"
}