Skip to content
This repository was archived by the owner on Sep 10, 2020. It is now read-only.

Commit 6435520

Browse files
committed
Merge pull request #11 from andyet/greenkeeper-lodash.bind-4.0.0
Update lodash.bind to version 4.0.0 🚀
2 parents d5cb97c + 9e272ab commit 6435520

File tree

6 files changed

+27
-101
lines changed

6 files changed

+27
-101
lines changed

.eslintrc

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,5 @@
11
{
2-
"plugins": [
3-
"eslint-plugin-hapi"
4-
],
5-
"rules": {
6-
"consistent-return": 0,
7-
"vars-on-top": 0,
8-
"one-var": 0,
9-
"strict": 0,
10-
"new-cap": 0,
11-
"no-console": 0,
12-
"no-constant-condition": 0,
13-
"no-empty": 0,
14-
"no-native-reassign": 0,
15-
"no-underscore-dangle": 0,
16-
"no-undef": 0,
17-
"no-process-exit": 0,
18-
"no-unused-vars": 0,
19-
"no-use-before-define": 0,
20-
"no-unused-expressions": 0,
21-
"no-regex-spaces": 0,
22-
"no-catch-shadow": 0,
23-
"global-strict": 0,
24-
"handle-callback-err": 0,
25-
"no-lonely-if": 0,
26-
"space-in-brackets": 0,
27-
"brace-style": 0,
28-
"no-shadow": 0,
29-
"hapi/no-shadow-relaxed": [1, { "ignore": ["err", "done"] }],
30-
"hapi/hapi-capitalize-modules": [1, "global-scope-only"],
31-
"hapi/hapi-scope-start": 1,
32-
"array-bracket-spacing": 1,
33-
"dot-notation": 1,
34-
"eol-last": 1,
35-
"camelcase": 1,
36-
"no-trailing-spaces": 1,
37-
"no-eq-null": 1,
38-
"no-extend-native": 1,
39-
"no-redeclare": 1,
40-
"no-loop-func": 1,
41-
"yoda": [1, "never"],
42-
"sort-vars": 1,
43-
"quotes": [2, "single"],
44-
"consistent-this": [2, "self"],
45-
"func-style": [2, "expression"],
46-
"new-parens": 2,
47-
"no-array-constructor": 2,
48-
"no-new-object": 2,
49-
"no-spaced-func": 2,
50-
"no-mixed-spaces-and-tabs": 2,
51-
"space-after-keywords": 2,
52-
"semi": [2, "always"],
53-
"semi-spacing": [2, { "before": false, "after": true }],
54-
"space-infix-ops": 2,
55-
"space-return-throw-case": 2,
56-
"space-unary-ops": [1, { "words": true, "nonwords": false }],
57-
"eqeqeq": 2,
58-
"curly": [2, "all"],
59-
"no-eval": 2,
60-
"no-else-return": 2,
61-
"no-return-assign": 2,
62-
"no-new-wrappers": 2,
63-
"comma-dangle": [2, "never"],
64-
"no-sparse-arrays": 2,
65-
"no-ex-assign": 2,
66-
"indent": [2, 4],
67-
"space-before-function-paren": 2,
68-
"func-style": [2, "expression"],
69-
"object-curly-spacing": [2, "always"],
70-
"func-names": 1,
71-
"valid-jsdoc": [2, {
72-
"requireReturn": false,
73-
"prefer": {
74-
"return": "returns"
75-
}
76-
}]
77-
}
2+
"extend": [
3+
"eslint-config-andyet/es5"
4+
]
785
}

browser/index.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

browser_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Browser test code
3+
* This code is browserified and sent to phantomjs
4+
* as part of the test suite, it is not part of the
5+
* library itself
6+
*/
7+
8+
var JsonRpcWs = require('./browser');
9+
var browserClient = JsonRpcWs.createClient();
10+
11+
Function.prototype.bind = require('function-bind');
12+
13+
browserClient.expose('info', function info (params, reply) {
14+
15+
reply(null, 'browser');
16+
});
17+
18+
window.browserClient = browserClient;

lib/connection.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var uuid = require('uuid').v4;
22
var logger = require('debug')('json-rpc-ws');
33
var Errors = require('./errors');
44
var Assert = require('assert');
5-
var Bind = require('lodash.bind');
65

76
/**
87
* Quarantined JSON.parse try/catch block in its own function
@@ -65,9 +64,9 @@ var Connection = function Connection (socket, parent) {
6564
this.parent = parent;
6665
this.responseHandlers = {};
6766
if (this.parent.browser) {
68-
this.socket.onmessage = Bind(this.message, this);
69-
this.socket.onclose = Bind(socketClosed, this);
70-
this.socket.onerror = Bind(socketError, this);
67+
this.socket.onmessage = this.message.bind(this)
68+
this.socket.onclose = socketClosed.bind(this);
69+
this.socket.onerror = socketError.bind(this);
7170
} else {
7271
this.socket.on('message', this.message.bind(this));
7372
this.socket.once('close', this.close.bind(this));
@@ -130,9 +129,6 @@ Connection.prototype.processPayload = function processPayload (payload) {
130129
logger('handler got callback %j, %j', err, reply);
131130
return this.sendResult(id, err, reply);
132131
};
133-
if (this.parent.browser) {
134-
return handler.call(this, params, Bind(handlerCallback, this));
135-
}
136132
return handler.call(this, params, handlerCallback.bind(this));
137133
}
138134
// needs a result or error at this point

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"license": "MIT",
2727
"dependencies": {
2828
"debug": "^2.2.0",
29-
"lodash.bind": "^3.1.0",
3029
"uuid": "^2.0.1",
3130
"ws": "^1.0.1"
3231
},
@@ -38,14 +37,15 @@
3837
"files": [
3938
"index.js",
4039
"browser.js",
41-
"browser/*",
4240
"lib/*"
4341
],
4442
"devDependencies": {
4543
"browserify": "^13.0.0",
4644
"code": "^2.0.1",
4745
"eslint": "^1.1.0",
46+
"eslint-config-andyet": "^1.0.0",
4847
"eslint-plugin-hapi": "^4.0.0",
48+
"function-bind": "^1.0.2",
4949
"git-validate": "^2.0.3",
5050
"jsdoc": "^3.3.2",
5151
"lab": "^8.0.0",

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ lab.experiment('json-rpc ws', function () {
255255

256256
process.env.PATH = process.env.PATH + ':./node_modules/.bin';
257257
var b = Browserify();
258-
b.add('./browser/index.js');
258+
b.add('./browser_test.js');
259259
b.bundle(function (err, buf) {
260260

261261
Code.expect(err).to.not.exist();

0 commit comments

Comments
 (0)