Skip to content
This repository was archived by the owner on Mar 9, 2019. It is now read-only.

Commit 1c3bb4d

Browse files
committed
Remove msgpack dependency for tinylib/msgp#152
1 parent 9ba6af9 commit 1c3bb4d

File tree

3 files changed

+2
-31
lines changed

3 files changed

+2
-31
lines changed

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "statsum",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"author": "Jonas Finnemann Jensen <[email protected]>",
55
"description": "Client library for statsum",
66
"license": "MPL-2.0",
@@ -23,9 +23,6 @@
2323
"lodash": "^4.5.1",
2424
"url-join": "^0.0.1"
2525
},
26-
"optionalDependencies": {
27-
"msgpack": "^1.0.2"
28-
},
2926
"devDependencies": {
3027
"babel-compile": "^1.0.0",
3128
"babel-core": "^6.1.21",

src/send.js

-16
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,10 @@ let assert = require('assert');
22
let urljoin = require('url-join');
33
let got = require('got');
44
let debug = require('debug')('statsum');
5-
let msgpack = null;
6-
try {
7-
msgpack = require('msgpack');
8-
} catch (err) {
9-
debug('Failed to load msgpack (optional dependency) falling back to json');
10-
}
115

12-
// Decide whether to use JSON or msgpack.
13-
// Note: msgpack is less bandwidth, but most importantly it is faster on the
14-
// server. JSON is a tiny bit faster on node, but since we have many
15-
// clients sending to one server we should optimize for fast server
16-
// processing (the server is most likely to a bottleneck).
176
let contentType = 'application/json';
187
let serialize = (data) => JSON.stringify(data);
198
let deserialize = (data) => JSON.parse(data.toString('utf8'));
20-
if (msgpack) {
21-
contentType = 'application/msgpack';
22-
serialize = (data) => msgpack.pack(data);
23-
deserialize = (data) => msgpack.unpack(data);
24-
}
259

2610
/** Send data-point to statsum */
2711
let sendDataPoints = async (configurer, options, payload) => {

test/statsum_test.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,8 @@ suite('statsum', () => {
66
let getStream = require('get-stream');
77
let _ = require('lodash');
88
let debug = require('debug')('statsum');
9-
let msgpack = null;
10-
try {
11-
msgpack = require('msgpack');
12-
} catch (err) {
13-
debug('Failed to load msgpack (optional dependency) falling back to json');
14-
}
15-
let deserialize = (data) => JSON.parse(data.toString('utf8'));
16-
if (msgpack) {
17-
deserialize = (data) => msgpack.unpack(data);
18-
}
19-
209

10+
let deserialize = (data) => JSON.parse(data.toString('utf8'));
2111
let server = null;
2212
let baseUrl = null;
2313
let payload = null;

0 commit comments

Comments
 (0)