Comparing version 0.0.1 to 0.0.2
50
index.js
@@ -1,1 +0,49 @@ | ||
// nothing here so far | ||
var dgram = require('dgram'); | ||
var async = require('async'); | ||
function Client(id, host, port) { | ||
this.host = host || 'localhost'; | ||
this.port = (port || 2000) + id; | ||
this.socket = dgram.createSocket('udp4') | ||
this.q = async.queue(this.sender.bind(this)); | ||
} | ||
Client.prototype.sender = function(message, cb) { | ||
var b = new Buffer(message); | ||
this.socket.send(b, 0, b.length, this.port, this.host, function(err) { | ||
if (err) throw err; | ||
setTimeout(cb, 5); | ||
}); | ||
}; | ||
Client.prototype.clear = function() { | ||
this.q.push('CLEAR'); | ||
}; | ||
Client.prototype.close = function() { | ||
this.q.push('CLOSE'); | ||
}; | ||
Client.prototype.names = function(arr) { | ||
this.q.push('NAMES ' + arr.join(' ')); | ||
}; | ||
Client.prototype.labels = function(arr) { | ||
this.q.push('LABELS ' + arr.join(' ')); | ||
}; | ||
Client.prototype.push = function(arr) { | ||
var msg = 's ' + arr.join(' '); | ||
this.q.push(msg); | ||
}; | ||
module.exports = Client; |
{ | ||
"name": "charter", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/runk/node-charter", | ||
@@ -27,5 +27,3 @@ "description": "Nodejs library for Charter App", | ||
}, | ||
"scripts": { | ||
"test": "mocha -R spec --recursive" | ||
}, | ||
"scripts": {}, | ||
"main": "index.js", | ||
@@ -32,0 +30,0 @@ "engine": { |
@@ -14,2 +14,14 @@ node-charter | ||
### Example | ||
```javascript | ||
var Client = require('charter'); | ||
var c = new Client(1); | ||
c.clear(); | ||
c.names(['default']); | ||
c.labels(['time', 'value']); | ||
for (var i = 0; i < 100; i++) | ||
c.push([i, Math.round(Math.random() * 100)]); | ||
``` |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3227
32
27