123 lines
8.7 KiB
JSON
123 lines
8.7 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"name": "shoe",
|
|
"raw": "shoe@~0.0.15",
|
|
"rawSpec": "~0.0.15",
|
|
"scope": null,
|
|
"spec": ">=0.0.15 <0.1.0",
|
|
"type": "range"
|
|
},
|
|
"/root/gitbook/node_modules/phantom"
|
|
]
|
|
],
|
|
"_from": "shoe@>=0.0.15 <0.1.0",
|
|
"_id": "shoe@0.0.15",
|
|
"_inCache": true,
|
|
"_installable": true,
|
|
"_location": "/shoe",
|
|
"_npmUser": {
|
|
"email": "mail@substack.net",
|
|
"name": "substack"
|
|
},
|
|
"_npmVersion": "1.3.7",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"name": "shoe",
|
|
"raw": "shoe@~0.0.15",
|
|
"rawSpec": "~0.0.15",
|
|
"scope": null,
|
|
"spec": ">=0.0.15 <0.1.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/phantom"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/shoe/-/shoe-0.0.15.tgz",
|
|
"_shasum": "baed8f1a7f08f530b66f0914287fcaa65b12443a",
|
|
"_shrinkwrap": null,
|
|
"_spec": "shoe@~0.0.15",
|
|
"_where": "/root/gitbook/node_modules/phantom",
|
|
"author": {
|
|
"email": "mail@substack.net",
|
|
"name": "James Halliday",
|
|
"url": "http://substack.net"
|
|
},
|
|
"browserify": "browser.js",
|
|
"bugs": {
|
|
"url": "https://github.com/substack/shoe/issues"
|
|
},
|
|
"bundleDependencies": [
|
|
"sockjs-client"
|
|
],
|
|
"dependencies": {
|
|
"sockjs": "0.3.7",
|
|
"sockjs-client": "*"
|
|
},
|
|
"description": "streaming sockjs for node and the browser",
|
|
"devDependencies": {
|
|
"tape": "~1.0.4",
|
|
"testling": "~1.4.1",
|
|
"through": "~2.3.4"
|
|
},
|
|
"directories": {
|
|
"example": "example"
|
|
},
|
|
"dist": {
|
|
"integrity": "sha512-XM5aTvK9kzdYYYZ0sr4pqteQ1jeHucXgSa6ueQE7CrDZTa+1bXGbQWT5EPyIw4LYhZ0fur43cGZgnifJJPfSOQ==",
|
|
"shasum": "baed8f1a7f08f530b66f0914287fcaa65b12443a",
|
|
"signatures": [
|
|
{
|
|
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
|
|
"sig": "MEQCID+2SV8BMlxu2uligRBbu9CEyMDs02uLerWfbh8s+/LXAiAipGcOG6ApVt8qR8fcIK+3xpu/iFG7+BgMKOEZIiME5A=="
|
|
}
|
|
],
|
|
"tarball": "https://registry.npmjs.org/shoe/-/shoe-0.0.15.tgz"
|
|
},
|
|
"engine": {
|
|
"node": ">=0.6"
|
|
},
|
|
"homepage": "https://github.com/substack/shoe",
|
|
"keywords": [
|
|
"websocket",
|
|
"stream",
|
|
"sock",
|
|
"browserify"
|
|
],
|
|
"license": "MIT",
|
|
"main": "index.js",
|
|
"maintainers": [
|
|
{
|
|
"email": "mail@substack.net",
|
|
"name": "substack"
|
|
}
|
|
],
|
|
"name": "shoe",
|
|
"optionalDependencies": {},
|
|
"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\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 through = require('through');\n\nvar result = document.getElementById('result');\n\nvar stream = shoe('/invert');\nstream.pipe(through(function (msg) {\n result.appendChild(document.createTextNode(msg));\n this.queue(String(Number(msg)^1));\n})).pipe(stream);\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 shoe = require('shoe');\nvar dnode = require('dnode');\n\nvar result = document.getElementById('result');\nvar stream = shoe('/dnode');\n\nvar d = dnode();\nd.on('remote', function (remote) {\n remote.transform('beep', function (s) {\n result.textContent = 'beep => ' + s;\n });\n});\nd.pipe(stream).pipe(d);\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\nwith express or connect\n-----------------------\n\nyou must pass the return value of `app.listen(port)`\n\n``` js\nvar shoe = require('shoe');\n\nvar express = require('express')\nvar app = express()\n\nvar sock = shoe(function (stream) { ... });\n\n// *** must pass expcess/connect apps like this:\nsock.install(app.listen(9999), '/dnode');\n```\n\nwith reconnect\n--------------\n\nyou can use [reconnect](https://github.com/dominictarr/reconnect) just in case your sock ends or gets disconnected.\n\n``` js\nvar shoe = require('shoe');\nvar reconnect = require('reconnect');\nvar es = require('event-stream');\nvar result = document.getElementById('result');\n\nvar r = reconnect(function (stream) {\n\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}).connect('/invert')\n\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`shoe` will emit a `'connect'` event when the connection is actually open,\n(just like in [net](http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener)).\nwrites performed before the `'connect'` event will be buffered. passing in `cb` to \nshoe is a shortcut for `shoe(uri).on('connect', cb)`\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",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git://github.com/substack/shoe.git"
|
|
},
|
|
"scripts": {
|
|
"test": "testling ."
|
|
},
|
|
"testling": {
|
|
"browsers": [
|
|
"ie/8..latest",
|
|
"chrome/latest",
|
|
"firefox/latest",
|
|
"safari/latest",
|
|
"opera/latest",
|
|
"iphone/latest",
|
|
"ipad/latest",
|
|
"android/latest"
|
|
],
|
|
"files": "test/browser.js",
|
|
"server": "test/server.js"
|
|
},
|
|
"version": "0.0.15"
|
|
}
|