@leofcoin/codec-format-interface 1.7.7 → 1.7.9

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.
@@ -1,5 +1,5 @@
1
- import BasicInterface from "./basic-interface.js";
2
- import Hash from "./codec-hash.js";
1
+ import BasicInterface from './basic-interface.js';
2
+ import Hash from './codec-hash.js';
3
3
  export default class FormatInterface extends BasicInterface implements FormatInterface {
4
4
  #private;
5
5
  hashFormat: string;
@@ -17,6 +17,11 @@ export default class FormatInterface extends BasicInterface implements FormatInt
17
17
  name?: string;
18
18
  });
19
19
  get format(): string;
20
+ beforeHashing(decoded: {
21
+ [index: string]: any;
22
+ }): {
23
+ [index: string]: any;
24
+ };
20
25
  /**
21
26
  * @return {PeernetHash}
22
27
  */
@@ -19,7 +19,7 @@ class FormatInterface extends BasicInterface {
19
19
  this.fromUint8Array(buffer);
20
20
  else if (buffer instanceof ArrayBuffer)
21
21
  this.fromArrayBuffer(buffer);
22
- else if (typeof buffer === "string") {
22
+ else if (typeof buffer === 'string') {
23
23
  if (this.isHex(buffer))
24
24
  this.fromHex(buffer);
25
25
  else if (this.isBase58(buffer))
@@ -85,7 +85,7 @@ class FormatInterface extends BasicInterface {
85
85
  constructor(buffer, proto, options) {
86
86
  super();
87
87
  this.proto = proto;
88
- this.hashFormat = options?.hashFormat ? options.hashFormat : "bs32";
88
+ this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
89
89
  if (options?.name)
90
90
  this.name = options.name;
91
91
  this.init(buffer);
@@ -94,13 +94,16 @@ class FormatInterface extends BasicInterface {
94
94
  const upper = this.hashFormat.charAt(0).toUpperCase();
95
95
  return `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
96
96
  }
97
+ beforeHashing(decoded) {
98
+ delete decoded.hash;
99
+ return decoded;
100
+ }
97
101
  /**
98
102
  * @return {PeernetHash}
99
103
  */
100
104
  get peernetHash() {
101
- const decoded = this.decoded;
105
+ const decoded = this.beforeHashing({ ...this.decoded });
102
106
  // @ts-ignore
103
- delete decoded.hash;
104
107
  return new CodecHash(decoded, { name: this.name });
105
108
  }
106
109
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/codec-format-interface",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {