bare-rpc 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -187,7 +187,7 @@ module.exports = exports = class RPC {
187
187
  }
188
188
 
189
189
  switch (message.type) {
190
- case t.REQUEST:
190
+ case t.REQUEST: {
191
191
  const request =
192
192
  message.id === 0
193
193
  ? new IncomingEvent(this, message.command, message.data)
@@ -202,6 +202,7 @@ module.exports = exports = class RPC {
202
202
  else this._stream.destroy(err)
203
203
  }
204
204
  break
205
+ }
205
206
  case t.RESPONSE:
206
207
  try {
207
208
  this._onresponse(message)
package/lib/messages.js CHANGED
@@ -114,7 +114,7 @@ exports.message = {
114
114
  case t.REQUEST: {
115
115
  const command = c.uint.decode(state)
116
116
  const stream = c.uint.decode(state)
117
- const data = stream === 0 ? c.buffer.decode(state) : null
117
+ const data = stream === 0 ? c.optionalBuffer.decode(state) : null
118
118
 
119
119
  return { type, id, command, stream, data }
120
120
  }
@@ -128,13 +128,13 @@ exports.message = {
128
128
  }
129
129
 
130
130
  if (stream === 0) {
131
- return { type, id, stream, error: null, data: c.buffer.decode(state) }
131
+ return { type, id, stream, error: null, data: c.optionalBuffer.decode(state) }
132
132
  }
133
133
 
134
134
  return { type, id, stream, error: null, data: null }
135
135
  }
136
136
 
137
- case t.STREAM:
137
+ case t.STREAM: {
138
138
  const stream = c.uint.decode(state)
139
139
 
140
140
  if (stream & s.ERROR) {
@@ -142,10 +142,11 @@ exports.message = {
142
142
  }
143
143
 
144
144
  if (stream & s.DATA) {
145
- return { type, id, stream, error: null, data: c.buffer.decode(state) }
145
+ return { type, id, stream, error: null, data: c.optionalBuffer.decode(state) }
146
146
  }
147
147
 
148
148
  return { type, id, stream, error: null, data: null }
149
+ }
149
150
 
150
151
  default:
151
152
  throw errors.UNKNOWN_MESSAGE(`Unknown message '${type}'`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-rpc",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "librpc ABI compatible RPC for Bare",
5
5
  "exports": {
6
6
  ".": {
@@ -8,6 +8,7 @@
8
8
  "default": "./index.js"
9
9
  },
10
10
  "./package": "./package.json",
11
+ "./constants": "./lib/constants.js",
11
12
  "./errors": {
12
13
  "types": "./lib/errors.d.ts",
13
14
  "default": "./lib/errors.js"
@@ -20,8 +21,9 @@
20
21
  "lib"
21
22
  ],
22
23
  "scripts": {
23
- "test": "prettier . --check && bare test.js",
24
- "format": "prettier --write ."
24
+ "format": "prettier --write . && lunte --fix",
25
+ "lint": "prettier --check . && lunte",
26
+ "test": "brittle-bare --coverage test.js"
25
27
  },
26
28
  "repository": {
27
29
  "type": "git",
@@ -36,13 +38,14 @@
36
38
  "dependencies": {
37
39
  "b4a": "^1.6.6",
38
40
  "bare-stream": "^2.1.3",
39
- "compact-encoding": "^2.15.0",
41
+ "compact-encoding": "^3.0.0",
40
42
  "safety-catch": "^1.0.2"
41
43
  },
42
44
  "devDependencies": {
43
45
  "bare-buffer": "^3.0.1",
44
46
  "bare-ipc": "^1.1.0",
45
47
  "brittle": "^3.2.1",
48
+ "lunte": "^1.7.0",
46
49
  "prettier": "^3.4.2",
47
50
  "prettier-config-holepunch": "^2.0.0"
48
51
  },