-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrowser.js
31 lines (28 loc) · 815 Bytes
/
browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module.exports = function (socket, chan) {
return {
_send: function (path, meth, data, cb) {
var meta = { path: path, meth: meth };
if ("object" === typeof path) {
meta = path;
meta.meth = meth;
}
cb || (cb = data, data = null);
socket.send(chan || 'api', meta, data, cb);
},
get: function (path, data, cb) {
return this._send(path, 'GET', data, cb);
},
delete: function (path, data, cb) {
return this._send(path, 'DELETE', data, cb);
},
put: function (path, data, cb) {
return this._send(path, 'PUT', data, cb);
},
post: function (path, data, cb) {
return this._send(path, 'POST', data, cb);
},
patch: function (path, data, cb) {
return this._send(path, 'PATCH', data, cb);
},
};
};