tmc.js 0.3.10 → 0.3.12

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/README.md CHANGED
@@ -134,11 +134,11 @@ new Tmc('your_app_key', 'your_app_secret', { autoReplyConfirmation: false })
134
134
 
135
135
  ## 支持的TOPICS
136
136
 
137
- <details><summary>共计 82+ 类别,441+ 消息数</summary>
137
+ <details><summary>共计 83+ 类别,445+ 消息数</summary>
138
138
 
139
139
  | 类别 | 消息数 |
140
140
  | --- | --- |
141
- | 淘宝交易 | 20 |
141
+ | 淘宝交易 | 21 |
142
142
  | 淘宝退款 | 13 |
143
143
  | 淘宝商品 | 13 |
144
144
  | 淘宝分销 | 23 |
@@ -154,8 +154,9 @@ new Tmc('your_app_key', 'your_app_secret', { autoReplyConfirmation: false })
154
154
  | 天猫美妆 | 2 |
155
155
  | 聚石塔 | 9 |
156
156
  | 淘宝物流 | 1 |
157
- | 阿里通信 | 17 |
157
+ | 阿里通信 | 18 |
158
158
  | 天猫魔盒 | 2 |
159
+ | 营销平台 | 1 |
159
160
  | OpenIM消息 | 1 |
160
161
  | 网上法庭 | 8 |
161
162
  | 电子发票 | 20 |
@@ -195,7 +196,7 @@ new Tmc('your_app_key', 'your_app_secret', { autoReplyConfirmation: false })
195
196
  | TVOS应用审核平台 | 1 |
196
197
  | Gifting送礼 | 1 |
197
198
  | 五道口商品 | 2 |
198
- | HOMEAI | 1 |
199
+ | HOMEAI | 2 |
199
200
  | HOMEAI消息对接 | 5 |
200
201
  | 零售通_公共 | 8 |
201
202
  | 酒店标准库基础信息变更消息 | 2 |
package/lib/message.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /* eslint max-classes-per-file: ["error", 3] */
2
2
  const { types } = require('util');
3
- const ValueFormat = require('./value-format');
4
3
  const MessageType = require('./message-type');
5
4
  const MessageKind = require('./message-kind');
6
5
  const {
@@ -9,6 +8,9 @@ const {
9
8
  const {
10
9
  TYPE, CODE, PHRASE, FLAG, TOKEN, CONTENT,
11
10
  } = require('./message-fields');
11
+ const {
12
+ Void, Byte, Int16, Int32, Int64, ByteArray, CountedString, Date: FmtDate,
13
+ } = require('./value-format');
12
14
 
13
15
  const kData = Symbol('kData');
14
16
  const kBuffer = Symbol('kBuffer');
@@ -58,10 +60,6 @@ const utf8 = 'utf8';
58
60
 
59
61
  const kOffset = Symbol('kOffset');
60
62
 
61
- const {
62
- Void, Byte, Int16, Int32, Int64, ByteArray, CountedString,
63
- } = ValueFormat;
64
-
65
63
  class Encoder {
66
64
  [kOffset] = 0;
67
65
 
@@ -156,7 +154,7 @@ class Encoder {
156
154
  }
157
155
 
158
156
  if (types.isDate(value)) {
159
- return this.put(ValueFormat.Date).putLong(value);
157
+ return this.put(FmtDate).putLong(value);
160
158
  }
161
159
 
162
160
  if (Buffer.isBuffer(value)) {
@@ -251,11 +249,11 @@ class Decoder {
251
249
 
252
250
  readBuffer() {
253
251
  const size = this.getInt();
254
- if (size === 0) {
255
- return null;
256
- }
252
+ if (size === 0) { return null; }
253
+
254
+ const buf = this[kBuffer].subarray(this[kOffset], this[kOffset] += size);
257
255
 
258
- return this[kBuffer].subarray(this[kOffset], this[kOffset] += size);
256
+ return buf;
259
257
  }
260
258
 
261
259
  readCountedString() { return this.readBuffer()?.toString(utf8); }
@@ -272,7 +270,7 @@ class Decoder {
272
270
 
273
271
  [`parse${Int64}`]() { return this.getLong(); }
274
272
 
275
- [`parse${ValueFormat.Date}`]() { return new Date(Number(this.getLong())); }
273
+ [`parse${FmtDate}`]() { return new Date(Number(this.getLong())); }
276
274
 
277
275
  [`parse${ByteArray}`]() { return this.readBuffer(); }
278
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmc.js",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Events driven and chained Taobao Message Channel(TMC) for NodeJS",
5
5
  "author": "James ZHANG",
6
6
  "license": "MIT",