@leofcoin/codec-format-interface 1.3.3 → 1.4.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/dist/index.js +7 -2
- package/dist/module.js +9 -4
- package/package.json +3 -2
- package/src/codec-format-interface.js +6 -1
- package/src/codecs.js +1 -1
package/dist/index.js
CHANGED
|
@@ -211,7 +211,7 @@ var codecs = {
|
|
|
211
211
|
},
|
|
212
212
|
// chat message
|
|
213
213
|
'chat-message': {
|
|
214
|
-
codec: parseInt('
|
|
214
|
+
codec: parseInt('70636d', 16),
|
|
215
215
|
hashAlg: 'dbl-keccak-256',
|
|
216
216
|
},
|
|
217
217
|
'peernet-file' : {
|
|
@@ -515,12 +515,17 @@ class FormatInterface$1 extends BasicInterface$1 {
|
|
|
515
515
|
* @return {Buffer}
|
|
516
516
|
*/
|
|
517
517
|
async encode(decoded) {
|
|
518
|
+
let encoded;
|
|
518
519
|
if (!decoded) decoded = this.decoded;
|
|
519
520
|
const codec = new PeernetCodec(this.name);
|
|
520
|
-
|
|
521
|
+
|
|
522
|
+
if (decoded instanceof Uint8Array) encoded = decoded;
|
|
523
|
+
else encoded = await this.protoEncode(typeof decoded === 'object' ? JSON.stringify(decoded) : decoded);
|
|
524
|
+
|
|
521
525
|
const uint8Array = new Uint8Array(encoded.length + codec.codecBuffer.length);
|
|
522
526
|
uint8Array.set(codec.codecBuffer);
|
|
523
527
|
uint8Array.set(encoded, codec.codecBuffer.length);
|
|
528
|
+
|
|
524
529
|
this.encoded = uint8Array;
|
|
525
530
|
return this.encoded
|
|
526
531
|
}
|
package/dist/module.js
CHANGED
|
@@ -456,7 +456,7 @@ var codecs = {
|
|
|
456
456
|
},
|
|
457
457
|
// chat message
|
|
458
458
|
'chat-message': {
|
|
459
|
-
codec: parseInt('
|
|
459
|
+
codec: parseInt('70636d', 16),
|
|
460
460
|
hashAlg: 'dbl-keccak-256',
|
|
461
461
|
},
|
|
462
462
|
'peernet-file' : {
|
|
@@ -4130,8 +4130,8 @@ var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
|
|
|
4130
4130
|
var abi = process.versions.modules; // TODO: support old node where this is undef
|
|
4131
4131
|
var runtime = isElectron() ? 'electron' : (isNwjs() ? 'node-webkit' : 'node');
|
|
4132
4132
|
|
|
4133
|
-
var arch = os.arch();
|
|
4134
|
-
var platform = os.platform();
|
|
4133
|
+
var arch = process.env.npm_config_arch || os.arch();
|
|
4134
|
+
var platform = process.env.npm_config_platform || os.platform();
|
|
4135
4135
|
var libc = process.env.LIBC || (isAlpine(platform) ? 'musl' : 'glibc');
|
|
4136
4136
|
var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || '';
|
|
4137
4137
|
var uv = (process.versions.uv || '').split('.')[0];
|
|
@@ -4796,12 +4796,17 @@ class FormatInterface$1 extends BasicInterface$1 {
|
|
|
4796
4796
|
* @return {Buffer}
|
|
4797
4797
|
*/
|
|
4798
4798
|
async encode(decoded) {
|
|
4799
|
+
let encoded;
|
|
4799
4800
|
if (!decoded) decoded = this.decoded;
|
|
4800
4801
|
const codec = new PeernetCodec(this.name);
|
|
4801
|
-
|
|
4802
|
+
|
|
4803
|
+
if (decoded instanceof Uint8Array) encoded = decoded;
|
|
4804
|
+
else encoded = await this.protoEncode(typeof decoded === 'object' ? JSON.stringify(decoded) : decoded);
|
|
4805
|
+
|
|
4802
4806
|
const uint8Array = new Uint8Array(encoded.length + codec.codecBuffer.length);
|
|
4803
4807
|
uint8Array.set(codec.codecBuffer);
|
|
4804
4808
|
uint8Array.set(encoded, codec.codecBuffer.length);
|
|
4809
|
+
|
|
4805
4810
|
this.encoded = uint8Array;
|
|
4806
4811
|
return this.encoded
|
|
4807
4812
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/codec-format-interface",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/module.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
9
|
"c": "rollup -c"
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"varint": "^6.0.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"rollup": "^2.
|
|
30
|
+
"rollup": "^2.79.1",
|
|
30
31
|
"tape": "^5.5.3"
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -79,12 +79,17 @@ export default class FormatInterface extends BasicInterface {
|
|
|
79
79
|
* @return {Buffer}
|
|
80
80
|
*/
|
|
81
81
|
async encode(decoded) {
|
|
82
|
+
let encoded
|
|
82
83
|
if (!decoded) decoded = this.decoded;
|
|
83
84
|
const codec = new Codec(this.name)
|
|
84
|
-
|
|
85
|
+
|
|
86
|
+
if (decoded instanceof Uint8Array) encoded = decoded
|
|
87
|
+
else encoded = await this.protoEncode(typeof decoded === 'object' ? JSON.stringify(decoded) : decoded)
|
|
88
|
+
|
|
85
89
|
const uint8Array = new Uint8Array(encoded.length + codec.codecBuffer.length)
|
|
86
90
|
uint8Array.set(codec.codecBuffer)
|
|
87
91
|
uint8Array.set(encoded, codec.codecBuffer.length)
|
|
92
|
+
|
|
88
93
|
this.encoded = uint8Array
|
|
89
94
|
return this.encoded
|
|
90
95
|
}
|