Skip to content
Snippets Groups Projects
Commit 473daf61 authored by Adrien M's avatar Adrien M
Browse files

fixed browserification - ignored websocket in package

parent faab2283
No related branches found
No related tags found
No related merge requests found
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
</head> </head>
<body> <body>
<script src="https://cdn.steemjs.com/lib/steem.min.js"></script> <script src="steem.min.js"></script>
<script> <script>
steem.getAccounts(['ned', 'dan'], function(err, response){ steem.api.getAccounts(['ned', 'dan'], function(err, response){
console.log(err, response); console.log(err, response);
}); });
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
var WebSocket = require('ws'); var isNode = require('detect-node');
if (isNode)
var WebSocketNode = require('ws');
var Steem = { var Steem = {
url: 'wss://steemit.com/wspa', url: 'wss://steemit.com/wspa',
...@@ -20,8 +22,11 @@ Steem.setWebSocket = function(url) { ...@@ -20,8 +22,11 @@ Steem.setWebSocket = function(url) {
Steem.init = function(callback) { Steem.init = function(callback) {
if (!this.isReady) { if (!this.isReady) {
this.ws = new WebSocket(this.url); if (isNode) {
this.ws.setMaxListeners(0); this.ws = new WebSocketNode(this.url);
this.ws.setMaxListeners(0);
} else
this.ws = new WebSocket(this.url);
this.ws.addEventListener('close', function() { this.ws.addEventListener('close', function() {
this.isOpen = false; this.isOpen = false;
}.bind(this)); }.bind(this));
...@@ -1001,4 +1006,4 @@ Steem.streamOperations = function(callback) { ...@@ -1001,4 +1006,4 @@ Steem.streamOperations = function(callback) {
}; };
module.exports = Steem; module.exports = Steem;
\ No newline at end of file
module.exports = { steem = {
api: require('./api'), api: require('./api'),
formatter: require('./formatter'), formatter: require('./formatter'),
}; };
\ No newline at end of file
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "node test.js", "test": "node test.js",
"build": "browserify lib/browser.js -o | uglifyjs > lib/steem.min.js && browserify lib/browser.js -o | uglifyjs > examples/steem.min.js" "build": "browserify lib/browser.js -o examples/steem.js && uglifyjs examples/steem.js -o examples/steem.min.js"
},
"browser": {
"ws": false
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -24,6 +27,7 @@ ...@@ -24,6 +27,7 @@
}, },
"homepage": "https://github.com/adcpm/steem#readme", "homepage": "https://github.com/adcpm/steem#readme",
"dependencies": { "dependencies": {
"detect-node": "^2.0.3",
"moment": "^2.14.1", "moment": "^2.14.1",
"steemauth": "0.0.4", "steemauth": "0.0.4",
"ws": "^1.1.1" "ws": "^1.1.1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment