@xyo-network/hash 5.3.24 → 5.3.26

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
@@ -1,23 +1,1516 @@
1
+ [![logo][]](https://xyo.network)
2
+
1
3
  # @xyo-network/hash
2
4
 
3
- [![logo][]](https://xyo.network)
5
+ [![npm][npm-badge]][npm-link]
6
+ [![license][license-badge]][license-link]
7
+
8
+ > Primary SDK for using XYO Protocol 2.0
9
+
10
+ ## Install
11
+
12
+ Using npm:
13
+
14
+ ```sh
15
+ npm install {{name}}
16
+ ```
17
+
18
+ Using yarn:
4
19
 
5
- Version: 5.0.2
20
+ ```sh
21
+ yarn add {{name}}
22
+ ```
6
23
 
7
- Primary SDK for using XYO Protocol 2.0
24
+ Using pnpm:
8
25
 
9
- ## Documentation
26
+ ```sh
27
+ pnpm add {{name}}
28
+ ```
10
29
 
11
- [TypeDoc Generated Documentation](https://gitbook.xyo.network/xyo-data-lab/xyo-reference/package-documentation/xyo-network__hash)
30
+ Using bun:
31
+
32
+ ```sh
33
+ bun add {{name}}
34
+ ```
12
35
 
13
- Part of [sdk-xyo-client-js](https://www.npmjs.com/package/@xyo-network/sdk-xyo-client-js)
14
36
 
15
37
  ## License
16
38
 
17
- > See the [LICENSE](LICENSE) file for license details
39
+ See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
40
+
41
+ ## Reference
42
+
43
+ ### packages
44
+
45
+ ### protocol
46
+
47
+ ### packages
48
+
49
+ ### core
50
+
51
+ ### packages
52
+
53
+ ### hash
54
+
55
+ ### .temp-typedoc
56
+
57
+ ### index
58
+
59
+ ### classes
60
+
61
+ ### <a id="ObjectHasher"></a>ObjectHasher
62
+
63
+ [**@xyo-network/hash**](#../../README)
64
+
65
+ ***
66
+
67
+ ## Extends
68
+
69
+ - `ObjectHasher`\<`T`\>
70
+
71
+ ## Type Parameters
72
+
73
+ ### T
74
+
75
+ `T` *extends* `EmptyObject` = `EmptyObject`
76
+
77
+ ## Constructors
78
+
79
+ ### Constructor
80
+
81
+ ```ts
82
+ new ObjectHasher<T>(obj): NodeObjectHasher<T>;
83
+ ```
84
+
85
+ ### Parameters
86
+
87
+ #### obj
88
+
89
+ `T`
90
+
91
+ ### Returns
92
+
93
+ `NodeObjectHasher`\<`T`\>
94
+
95
+ ### Inherited from
96
+
97
+ ```ts
98
+ ObjectHasher<T>.constructor
99
+ ```
100
+
101
+ ## Properties
102
+
103
+ ### createNodeWorker
104
+
105
+ ```ts
106
+ readonly static createNodeWorker: (func?) => Worker;
107
+ ```
108
+
109
+ ### Parameters
110
+
111
+ #### func?
112
+
113
+ () => `unknown`
114
+
115
+ ### Returns
116
+
117
+ `Worker`
118
+
119
+ ### Overrides
120
+
121
+ ```ts
122
+ ObjectHasher.createNodeWorker
123
+ ```
124
+
125
+ ***
126
+
127
+ ### allowHashPooling
128
+
129
+ ```ts
130
+ static allowHashPooling: boolean = true;
131
+ ```
132
+
133
+ ### Inherited from
134
+
135
+ ```ts
136
+ ObjectHasher.allowHashPooling
137
+ ```
138
+
139
+ ***
140
+
141
+ ### allowSubtle
142
+
143
+ ```ts
144
+ static allowSubtle: boolean = true;
145
+ ```
146
+
147
+ ### Inherited from
148
+
149
+ ```ts
150
+ ObjectHasher.allowSubtle
151
+ ```
152
+
153
+ ***
154
+
155
+ ### createBrowserWorker?
156
+
157
+ ```ts
158
+ static optional createBrowserWorker?: (url?) => Worker | undefined;
159
+ ```
160
+
161
+ ### Parameters
162
+
163
+ #### url?
164
+
165
+ `URL`
166
+
167
+ ### Returns
168
+
169
+ `Worker` \| `undefined`
170
+
171
+ ### Inherited from
172
+
173
+ ```ts
174
+ ObjectHasher.createBrowserWorker
175
+ ```
176
+
177
+ ***
178
+
179
+ ### subtleHashWorkerUrl?
180
+
181
+ ```ts
182
+ readonly static optional subtleHashWorkerUrl?: URL;
183
+ ```
184
+
185
+ ### Inherited from
186
+
187
+ ```ts
188
+ ObjectHasher.subtleHashWorkerUrl
189
+ ```
190
+
191
+ ***
192
+
193
+ ### warnIfUsingJsHash
194
+
195
+ ```ts
196
+ static warnIfUsingJsHash: boolean = true;
197
+ ```
198
+
199
+ ### Inherited from
200
+
201
+ ```ts
202
+ ObjectHasher.warnIfUsingJsHash
203
+ ```
204
+
205
+ ***
206
+
207
+ ### wasmHashWorkerUrl?
208
+
209
+ ```ts
210
+ readonly static optional wasmHashWorkerUrl?: URL;
211
+ ```
212
+
213
+ ### Inherited from
214
+
215
+ ```ts
216
+ ObjectHasher.wasmHashWorkerUrl
217
+ ```
218
+
219
+ ***
220
+
221
+ ### wasmInitialized
222
+
223
+ ```ts
224
+ readonly static wasmInitialized: Promise<void>;
225
+ ```
226
+
227
+ ### Inherited from
228
+
229
+ ```ts
230
+ ObjectHasher.wasmInitialized
231
+ ```
232
+
233
+ ***
234
+
235
+ ### wasmSupport
236
+
237
+ ```ts
238
+ readonly static wasmSupport: WasmSupport = wasmSupportStatic;
239
+ ```
240
+
241
+ ### Inherited from
242
+
243
+ ```ts
244
+ ObjectHasher.wasmSupport
245
+ ```
246
+
247
+ ## Methods
248
+
249
+ ### createWorker()
250
+
251
+ ```ts
252
+ static createWorker(url?, func?): Worker;
253
+ ```
254
+
255
+ ### Parameters
256
+
257
+ #### url?
258
+
259
+ `URL`
260
+
261
+ #### func?
262
+
263
+ () => `unknown`
264
+
265
+ ### Returns
266
+
267
+ `Worker`
268
+
269
+ ### Inherited from
270
+
271
+ ```ts
272
+ ObjectHasher.createWorker
273
+ ```
274
+
275
+ ***
276
+
277
+ ### filterExcludeByHash()
278
+
279
+ ```ts
280
+ static filterExcludeByHash<T>(objs?, hash): Promise<T[]>;
281
+ ```
282
+
283
+ ### Type Parameters
284
+
285
+ #### T
286
+
287
+ `T` *extends* `object`
288
+
289
+ ### Parameters
290
+
291
+ #### objs?
292
+
293
+ `T`[] = `[]`
294
+
295
+ #### hash
296
+
297
+ `BrandedHash` \| `BrandedHash`[]
298
+
299
+ ### Returns
300
+
301
+ `Promise`\<`T`[]\>
302
+
303
+ ### Inherited from
304
+
305
+ ```ts
306
+ ObjectHasher.filterExcludeByHash
307
+ ```
308
+
309
+ ***
310
+
311
+ ### filterIncludeByHash()
312
+
313
+ ```ts
314
+ static filterIncludeByHash<T>(objs?, hash): Promise<T[]>;
315
+ ```
316
+
317
+ ### Type Parameters
318
+
319
+ #### T
320
+
321
+ `T` *extends* `object`
322
+
323
+ ### Parameters
324
+
325
+ #### objs?
326
+
327
+ `T`[] = `[]`
328
+
329
+ #### hash
330
+
331
+ `BrandedHash` \| `BrandedHash`[]
332
+
333
+ ### Returns
334
+
335
+ `Promise`\<`T`[]\>
336
+
337
+ ### Inherited from
338
+
339
+ ```ts
340
+ ObjectHasher.filterIncludeByHash
341
+ ```
342
+
343
+ ***
344
+
345
+ ### findByHash()
346
+
347
+ ```ts
348
+ static findByHash<T>(objs?, hash): Promise<T | undefined>;
349
+ ```
350
+
351
+ ### Type Parameters
352
+
353
+ #### T
354
+
355
+ `T` *extends* `object`
356
+
357
+ ### Parameters
358
+
359
+ #### objs?
360
+
361
+ `T`[] = `[]`
362
+
363
+ #### hash
364
+
365
+ `BrandedHash`
366
+
367
+ ### Returns
368
+
369
+ `Promise`\<`T` \| `undefined`\>
370
+
371
+ ### Inherited from
372
+
373
+ ```ts
374
+ ObjectHasher.findByHash
375
+ ```
376
+
377
+ ***
378
+
379
+ ### hash()
380
+
381
+ ```ts
382
+ static hash<T>(obj): Promise<BrandedHash>;
383
+ ```
384
+
385
+ Asynchronously hashes a payload
386
+
387
+ ### Type Parameters
388
+
389
+ #### T
390
+
391
+ `T` *extends* `object`
392
+
393
+ ### Parameters
394
+
395
+ #### obj
396
+
397
+ `T`
398
+
399
+ A payload
400
+
401
+ ### Returns
402
+
403
+ `Promise`\<`BrandedHash`\>
404
+
405
+ The payload hash
406
+
407
+ ### Inherited from
408
+
409
+ ```ts
410
+ ObjectHasher.hash
411
+ ```
412
+
413
+ ***
414
+
415
+ ### hashBytes()
416
+
417
+ ```ts
418
+ static hashBytes(bytes): Promise<BrandedHash>;
419
+ ```
420
+
421
+ ### Parameters
422
+
423
+ #### bytes
424
+
425
+ `ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`\>
426
+
427
+ ### Returns
428
+
429
+ `Promise`\<`BrandedHash`\>
430
+
431
+ ### Inherited from
432
+
433
+ ```ts
434
+ ObjectHasher.hashBytes
435
+ ```
436
+
437
+ ***
438
+
439
+ ### hashFields()
440
+
441
+ ```ts
442
+ static hashFields<T>(obj): T;
443
+ ```
444
+
445
+ ### Type Parameters
446
+
447
+ #### T
448
+
449
+ `T` *extends* `object`
450
+
451
+ ### Parameters
452
+
453
+ #### obj
454
+
455
+ `T`
456
+
457
+ ### Returns
458
+
459
+ `T`
460
+
461
+ ### Inherited from
462
+
463
+ ```ts
464
+ ObjectHasher.hashFields
465
+ ```
466
+
467
+ ***
468
+
469
+ ### hashPairs()
470
+
471
+ ```ts
472
+ static hashPairs<T>(objs): Promise<[T, BrandedHash][]>;
473
+ ```
474
+
475
+ Creates an array of payload/hash tuples based on the payloads passed in
476
+
477
+ ### Type Parameters
478
+
479
+ #### T
480
+
481
+ `T` *extends* `object`
482
+
483
+ ### Parameters
484
+
485
+ #### objs
486
+
487
+ `T`[]
488
+
489
+ Any array of payloads
490
+
491
+ ### Returns
492
+
493
+ `Promise`\<\[`T`, `BrandedHash`\][]\>
494
+
495
+ An array of payload/hash tuples
496
+
497
+ ### Inherited from
498
+
499
+ ```ts
500
+ ObjectHasher.hashPairs
501
+ ```
502
+
503
+ ***
504
+
505
+ ### hashes()
506
+
507
+ ```ts
508
+ static hashes<T>(objs?): Promise<BrandedHash[] | undefined>;
509
+ ```
510
+
511
+ Creates an array of payload hashes based on the payloads passed in
512
+
513
+ ### Type Parameters
514
+
515
+ #### T
516
+
517
+ `T` *extends* `object`
518
+
519
+ ### Parameters
520
+
521
+ #### objs?
522
+
523
+ `T`[]
524
+
525
+ Any array of payloads
526
+
527
+ ### Returns
528
+
529
+ `Promise`\<`BrandedHash`[] \| `undefined`\>
530
+
531
+ An array of payload hashes
532
+
533
+ ### Inherited from
534
+
535
+ ```ts
536
+ ObjectHasher.hashes
537
+ ```
538
+
539
+ ***
540
+
541
+ ### json()
542
+
543
+ ```ts
544
+ static json<T>(payload, meta?): T;
545
+ ```
546
+
547
+ Returns a clone of the payload that is JSON safe
548
+
549
+ ### Type Parameters
550
+
551
+ #### T
552
+
553
+ `T` *extends* `object`
554
+
555
+ ### Parameters
556
+
557
+ #### payload
558
+
559
+ `T`
560
+
561
+ #### meta?
562
+
563
+ `boolean` = `false`
564
+
565
+ Keeps underscore (meta) fields if set to true
566
+
567
+ ### Returns
568
+
569
+ `T`
570
+
571
+ Returns a clone of the payload that is JSON safe
572
+
573
+ ### Inherited from
574
+
575
+ ```ts
576
+ ObjectHasher.json
577
+ ```
578
+
579
+ ***
580
+
581
+ ### ~~jsonPayload()~~
582
+
583
+ ```ts
584
+ static jsonPayload<T>(payload, meta?): T;
585
+ ```
586
+
587
+ ### Type Parameters
588
+
589
+ #### T
590
+
591
+ `T` *extends* `object`
592
+
593
+ ### Parameters
594
+
595
+ #### payload
596
+
597
+ `T`
598
+
599
+ #### meta?
600
+
601
+ `boolean` = `false`
602
+
603
+ ### Returns
604
+
605
+ `T`
606
+
607
+ ### Deprecated
608
+
609
+ us json instead
610
+
611
+ ### Inherited from
612
+
613
+ ```ts
614
+ ObjectHasher.jsonPayload
615
+ ```
616
+
617
+ ***
618
+
619
+ ### stringifyHashFields()
620
+
621
+ ```ts
622
+ static stringifyHashFields<T>(obj): string;
623
+ ```
624
+
625
+ ### Type Parameters
626
+
627
+ #### T
628
+
629
+ `T` *extends* `object`
630
+
631
+ ### Parameters
632
+
633
+ #### obj
634
+
635
+ `T`
636
+
637
+ ### Returns
638
+
639
+ `string`
640
+
641
+ ### Inherited from
642
+
643
+ ```ts
644
+ ObjectHasher.stringifyHashFields
645
+ ```
646
+
647
+ ***
648
+
649
+ ### subtleHash()
650
+
651
+ ```ts
652
+ static subtleHash(data): Promise<ArrayBuffer>;
653
+ ```
654
+
655
+ ### Parameters
656
+
657
+ #### data
658
+
659
+ `Uint8Array`\<`ArrayBuffer`\>
660
+
661
+ ### Returns
662
+
663
+ `Promise`\<`ArrayBuffer`\>
664
+
665
+ ### Inherited from
666
+
667
+ ```ts
668
+ ObjectHasher.subtleHash
669
+ ```
670
+
671
+ ***
672
+
673
+ ### wasmHash()
674
+
675
+ ```ts
676
+ static wasmHash(data): Promise<BrandedHash>;
677
+ ```
678
+
679
+ ### Parameters
680
+
681
+ #### data
682
+
683
+ `Uint8Array`
684
+
685
+ ### Returns
686
+
687
+ `Promise`\<`BrandedHash`\>
688
+
689
+ ### Inherited from
690
+
691
+ ```ts
692
+ ObjectHasher.wasmHash
693
+ ```
694
+
695
+ ***
696
+
697
+ ### hash()
698
+
699
+ ```ts
700
+ hash(): Promise<BrandedHash>;
701
+ ```
702
+
703
+ ### Returns
704
+
705
+ `Promise`\<`BrandedHash`\>
706
+
707
+ ### Inherited from
708
+
709
+ ```ts
710
+ ObjectHasher.hash
711
+ ```
712
+
713
+ ***
714
+
715
+ ### json()
716
+
717
+ ```ts
718
+ json(meta?): T;
719
+ ```
720
+
721
+ Returns a clone of the payload that is JSON safe
722
+
723
+ ### Parameters
724
+
725
+ #### meta?
726
+
727
+ `boolean` = `false`
728
+
729
+ Keeps underscore (meta) fields if set to true
730
+
731
+ ### Returns
732
+
733
+ `T`
734
+
735
+ Returns a clone of the payload that is JSON safe
736
+
737
+ ### Inherited from
738
+
739
+ ```ts
740
+ ObjectHasher.json
741
+ ```
742
+
743
+ ### functions
744
+
745
+ ### <a id="hasEmptyFields"></a>hasEmptyFields
746
+
747
+ [**@xyo-network/hash**](#../../README)
748
+
749
+ ***
750
+
751
+ ```ts
752
+ function hasEmptyFields<T>(obj): boolean;
753
+ ```
754
+
755
+ ## Type Parameters
756
+
757
+ ### T
758
+
759
+ `T` *extends* `object`
760
+
761
+ ## Parameters
762
+
763
+ ### obj
764
+
765
+ `T`
766
+
767
+ ## Returns
768
+
769
+ `boolean`
770
+
771
+ ### index-browser
772
+
773
+ ### classes
774
+
775
+ ### <a id="ObjectHasher"></a>ObjectHasher
776
+
777
+ [**@xyo-network/hash**](#../../README)
778
+
779
+ ***
780
+
781
+ ## Extends
782
+
783
+ - `ObjectHasher`\<`T`\>
784
+
785
+ ## Type Parameters
786
+
787
+ ### T
788
+
789
+ `T` *extends* `EmptyObject` = `EmptyObject`
790
+
791
+ ## Constructors
792
+
793
+ ### Constructor
794
+
795
+ ```ts
796
+ new ObjectHasher<T>(obj): BrowserObjectHasher<T>;
797
+ ```
798
+
799
+ ### Parameters
800
+
801
+ #### obj
802
+
803
+ `T`
804
+
805
+ ### Returns
806
+
807
+ `BrowserObjectHasher`\<`T`\>
808
+
809
+ ### Inherited from
810
+
811
+ ```ts
812
+ ObjectHasher<T>.constructor
813
+ ```
814
+
815
+ ## Properties
816
+
817
+ ### createBrowserWorker
818
+
819
+ ```ts
820
+ readonly static createBrowserWorker: (url?) => Worker;
821
+ ```
822
+
823
+ ### Parameters
824
+
825
+ #### url?
826
+
827
+ `URL`
828
+
829
+ ### Returns
830
+
831
+ `Worker`
832
+
833
+ ### Overrides
834
+
835
+ ```ts
836
+ ObjectHasher.createBrowserWorker
837
+ ```
838
+
839
+ ***
840
+
841
+ ### createNodeWorker
842
+
843
+ ```ts
844
+ readonly static createNodeWorker: (func?) => Worker;
845
+ ```
846
+
847
+ ### Parameters
848
+
849
+ #### func?
850
+
851
+ () => `unknown`
852
+
853
+ ### Returns
854
+
855
+ `Worker`
856
+
857
+ ### Overrides
858
+
859
+ ```ts
860
+ ObjectHasher.createNodeWorker
861
+ ```
862
+
863
+ ***
864
+
865
+ ### subtleHashWorkerUrl
866
+
867
+ ```ts
868
+ readonly static subtleHashWorkerUrl: URL | undefined;
869
+ ```
870
+
871
+ ### Overrides
872
+
873
+ ```ts
874
+ ObjectHasher.subtleHashWorkerUrl
875
+ ```
876
+
877
+ ***
878
+
879
+ ### wasmHashWorkerUrl
880
+
881
+ ```ts
882
+ readonly static wasmHashWorkerUrl: URL | undefined;
883
+ ```
884
+
885
+ ### Overrides
886
+
887
+ ```ts
888
+ ObjectHasher.wasmHashWorkerUrl
889
+ ```
890
+
891
+ ***
892
+
893
+ ### allowHashPooling
894
+
895
+ ```ts
896
+ static allowHashPooling: boolean = true;
897
+ ```
898
+
899
+ ### Inherited from
900
+
901
+ ```ts
902
+ ObjectHasher.allowHashPooling
903
+ ```
904
+
905
+ ***
906
+
907
+ ### allowSubtle
908
+
909
+ ```ts
910
+ static allowSubtle: boolean = true;
911
+ ```
912
+
913
+ ### Inherited from
914
+
915
+ ```ts
916
+ ObjectHasher.allowSubtle
917
+ ```
918
+
919
+ ***
920
+
921
+ ### warnIfUsingJsHash
922
+
923
+ ```ts
924
+ static warnIfUsingJsHash: boolean = true;
925
+ ```
926
+
927
+ ### Inherited from
928
+
929
+ ```ts
930
+ ObjectHasher.warnIfUsingJsHash
931
+ ```
932
+
933
+ ***
934
+
935
+ ### wasmInitialized
936
+
937
+ ```ts
938
+ readonly static wasmInitialized: Promise<void>;
939
+ ```
940
+
941
+ ### Inherited from
942
+
943
+ ```ts
944
+ ObjectHasher.wasmInitialized
945
+ ```
946
+
947
+ ***
948
+
949
+ ### wasmSupport
950
+
951
+ ```ts
952
+ readonly static wasmSupport: WasmSupport = wasmSupportStatic;
953
+ ```
954
+
955
+ ### Inherited from
956
+
957
+ ```ts
958
+ ObjectHasher.wasmSupport
959
+ ```
960
+
961
+ ## Methods
962
+
963
+ ### createWorker()
964
+
965
+ ```ts
966
+ static createWorker(url?, func?): Worker;
967
+ ```
968
+
969
+ ### Parameters
970
+
971
+ #### url?
972
+
973
+ `URL`
974
+
975
+ #### func?
976
+
977
+ () => `unknown`
978
+
979
+ ### Returns
980
+
981
+ `Worker`
982
+
983
+ ### Inherited from
984
+
985
+ ```ts
986
+ ObjectHasher.createWorker
987
+ ```
988
+
989
+ ***
990
+
991
+ ### filterExcludeByHash()
992
+
993
+ ```ts
994
+ static filterExcludeByHash<T>(objs?, hash): Promise<T[]>;
995
+ ```
996
+
997
+ ### Type Parameters
998
+
999
+ #### T
1000
+
1001
+ `T` *extends* `object`
1002
+
1003
+ ### Parameters
1004
+
1005
+ #### objs?
1006
+
1007
+ `T`[] = `[]`
1008
+
1009
+ #### hash
1010
+
1011
+ `BrandedHash` \| `BrandedHash`[]
1012
+
1013
+ ### Returns
1014
+
1015
+ `Promise`\<`T`[]\>
1016
+
1017
+ ### Inherited from
1018
+
1019
+ ```ts
1020
+ ObjectHasher.filterExcludeByHash
1021
+ ```
1022
+
1023
+ ***
1024
+
1025
+ ### filterIncludeByHash()
1026
+
1027
+ ```ts
1028
+ static filterIncludeByHash<T>(objs?, hash): Promise<T[]>;
1029
+ ```
1030
+
1031
+ ### Type Parameters
1032
+
1033
+ #### T
1034
+
1035
+ `T` *extends* `object`
1036
+
1037
+ ### Parameters
1038
+
1039
+ #### objs?
1040
+
1041
+ `T`[] = `[]`
1042
+
1043
+ #### hash
1044
+
1045
+ `BrandedHash` \| `BrandedHash`[]
1046
+
1047
+ ### Returns
1048
+
1049
+ `Promise`\<`T`[]\>
1050
+
1051
+ ### Inherited from
1052
+
1053
+ ```ts
1054
+ ObjectHasher.filterIncludeByHash
1055
+ ```
1056
+
1057
+ ***
1058
+
1059
+ ### findByHash()
1060
+
1061
+ ```ts
1062
+ static findByHash<T>(objs?, hash): Promise<T | undefined>;
1063
+ ```
1064
+
1065
+ ### Type Parameters
1066
+
1067
+ #### T
1068
+
1069
+ `T` *extends* `object`
1070
+
1071
+ ### Parameters
1072
+
1073
+ #### objs?
1074
+
1075
+ `T`[] = `[]`
1076
+
1077
+ #### hash
1078
+
1079
+ `BrandedHash`
1080
+
1081
+ ### Returns
1082
+
1083
+ `Promise`\<`T` \| `undefined`\>
1084
+
1085
+ ### Inherited from
1086
+
1087
+ ```ts
1088
+ ObjectHasher.findByHash
1089
+ ```
1090
+
1091
+ ***
1092
+
1093
+ ### hash()
1094
+
1095
+ ```ts
1096
+ static hash<T>(obj): Promise<BrandedHash>;
1097
+ ```
1098
+
1099
+ Asynchronously hashes a payload
1100
+
1101
+ ### Type Parameters
1102
+
1103
+ #### T
1104
+
1105
+ `T` *extends* `object`
1106
+
1107
+ ### Parameters
1108
+
1109
+ #### obj
1110
+
1111
+ `T`
1112
+
1113
+ A payload
1114
+
1115
+ ### Returns
1116
+
1117
+ `Promise`\<`BrandedHash`\>
1118
+
1119
+ The payload hash
1120
+
1121
+ ### Inherited from
1122
+
1123
+ ```ts
1124
+ ObjectHasher.hash
1125
+ ```
1126
+
1127
+ ***
1128
+
1129
+ ### hashBytes()
1130
+
1131
+ ```ts
1132
+ static hashBytes(bytes): Promise<BrandedHash>;
1133
+ ```
1134
+
1135
+ ### Parameters
1136
+
1137
+ #### bytes
1138
+
1139
+ `ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`\>
1140
+
1141
+ ### Returns
1142
+
1143
+ `Promise`\<`BrandedHash`\>
1144
+
1145
+ ### Inherited from
1146
+
1147
+ ```ts
1148
+ ObjectHasher.hashBytes
1149
+ ```
1150
+
1151
+ ***
1152
+
1153
+ ### hashFields()
1154
+
1155
+ ```ts
1156
+ static hashFields<T>(obj): T;
1157
+ ```
1158
+
1159
+ ### Type Parameters
1160
+
1161
+ #### T
1162
+
1163
+ `T` *extends* `object`
1164
+
1165
+ ### Parameters
1166
+
1167
+ #### obj
1168
+
1169
+ `T`
1170
+
1171
+ ### Returns
1172
+
1173
+ `T`
1174
+
1175
+ ### Inherited from
1176
+
1177
+ ```ts
1178
+ ObjectHasher.hashFields
1179
+ ```
1180
+
1181
+ ***
1182
+
1183
+ ### hashPairs()
1184
+
1185
+ ```ts
1186
+ static hashPairs<T>(objs): Promise<[T, BrandedHash][]>;
1187
+ ```
1188
+
1189
+ Creates an array of payload/hash tuples based on the payloads passed in
1190
+
1191
+ ### Type Parameters
1192
+
1193
+ #### T
1194
+
1195
+ `T` *extends* `object`
1196
+
1197
+ ### Parameters
1198
+
1199
+ #### objs
1200
+
1201
+ `T`[]
1202
+
1203
+ Any array of payloads
1204
+
1205
+ ### Returns
1206
+
1207
+ `Promise`\<\[`T`, `BrandedHash`\][]\>
1208
+
1209
+ An array of payload/hash tuples
1210
+
1211
+ ### Inherited from
1212
+
1213
+ ```ts
1214
+ ObjectHasher.hashPairs
1215
+ ```
1216
+
1217
+ ***
1218
+
1219
+ ### hashes()
1220
+
1221
+ ```ts
1222
+ static hashes<T>(objs?): Promise<BrandedHash[] | undefined>;
1223
+ ```
1224
+
1225
+ Creates an array of payload hashes based on the payloads passed in
1226
+
1227
+ ### Type Parameters
1228
+
1229
+ #### T
1230
+
1231
+ `T` *extends* `object`
1232
+
1233
+ ### Parameters
1234
+
1235
+ #### objs?
1236
+
1237
+ `T`[]
1238
+
1239
+ Any array of payloads
1240
+
1241
+ ### Returns
1242
+
1243
+ `Promise`\<`BrandedHash`[] \| `undefined`\>
1244
+
1245
+ An array of payload hashes
1246
+
1247
+ ### Inherited from
1248
+
1249
+ ```ts
1250
+ ObjectHasher.hashes
1251
+ ```
1252
+
1253
+ ***
1254
+
1255
+ ### json()
1256
+
1257
+ ```ts
1258
+ static json<T>(payload, meta?): T;
1259
+ ```
1260
+
1261
+ Returns a clone of the payload that is JSON safe
1262
+
1263
+ ### Type Parameters
1264
+
1265
+ #### T
1266
+
1267
+ `T` *extends* `object`
1268
+
1269
+ ### Parameters
1270
+
1271
+ #### payload
1272
+
1273
+ `T`
1274
+
1275
+ #### meta?
1276
+
1277
+ `boolean` = `false`
1278
+
1279
+ Keeps underscore (meta) fields if set to true
1280
+
1281
+ ### Returns
1282
+
1283
+ `T`
1284
+
1285
+ Returns a clone of the payload that is JSON safe
1286
+
1287
+ ### Inherited from
1288
+
1289
+ ```ts
1290
+ ObjectHasher.json
1291
+ ```
1292
+
1293
+ ***
1294
+
1295
+ ### ~~jsonPayload()~~
1296
+
1297
+ ```ts
1298
+ static jsonPayload<T>(payload, meta?): T;
1299
+ ```
1300
+
1301
+ ### Type Parameters
1302
+
1303
+ #### T
1304
+
1305
+ `T` *extends* `object`
1306
+
1307
+ ### Parameters
1308
+
1309
+ #### payload
1310
+
1311
+ `T`
1312
+
1313
+ #### meta?
1314
+
1315
+ `boolean` = `false`
1316
+
1317
+ ### Returns
1318
+
1319
+ `T`
1320
+
1321
+ ### Deprecated
1322
+
1323
+ us json instead
1324
+
1325
+ ### Inherited from
1326
+
1327
+ ```ts
1328
+ ObjectHasher.jsonPayload
1329
+ ```
1330
+
1331
+ ***
1332
+
1333
+ ### stringifyHashFields()
1334
+
1335
+ ```ts
1336
+ static stringifyHashFields<T>(obj): string;
1337
+ ```
1338
+
1339
+ ### Type Parameters
1340
+
1341
+ #### T
1342
+
1343
+ `T` *extends* `object`
1344
+
1345
+ ### Parameters
1346
+
1347
+ #### obj
1348
+
1349
+ `T`
1350
+
1351
+ ### Returns
1352
+
1353
+ `string`
1354
+
1355
+ ### Inherited from
1356
+
1357
+ ```ts
1358
+ ObjectHasher.stringifyHashFields
1359
+ ```
1360
+
1361
+ ***
1362
+
1363
+ ### subtleHash()
1364
+
1365
+ ```ts
1366
+ static subtleHash(data): Promise<ArrayBuffer>;
1367
+ ```
1368
+
1369
+ ### Parameters
1370
+
1371
+ #### data
1372
+
1373
+ `Uint8Array`\<`ArrayBuffer`\>
1374
+
1375
+ ### Returns
1376
+
1377
+ `Promise`\<`ArrayBuffer`\>
1378
+
1379
+ ### Inherited from
1380
+
1381
+ ```ts
1382
+ ObjectHasher.subtleHash
1383
+ ```
1384
+
1385
+ ***
1386
+
1387
+ ### wasmHash()
1388
+
1389
+ ```ts
1390
+ static wasmHash(data): Promise<BrandedHash>;
1391
+ ```
1392
+
1393
+ ### Parameters
1394
+
1395
+ #### data
1396
+
1397
+ `Uint8Array`
1398
+
1399
+ ### Returns
1400
+
1401
+ `Promise`\<`BrandedHash`\>
1402
+
1403
+ ### Inherited from
1404
+
1405
+ ```ts
1406
+ ObjectHasher.wasmHash
1407
+ ```
1408
+
1409
+ ***
1410
+
1411
+ ### hash()
1412
+
1413
+ ```ts
1414
+ hash(): Promise<BrandedHash>;
1415
+ ```
1416
+
1417
+ ### Returns
1418
+
1419
+ `Promise`\<`BrandedHash`\>
1420
+
1421
+ ### Inherited from
1422
+
1423
+ ```ts
1424
+ ObjectHasher.hash
1425
+ ```
1426
+
1427
+ ***
1428
+
1429
+ ### json()
1430
+
1431
+ ```ts
1432
+ json(meta?): T;
1433
+ ```
1434
+
1435
+ Returns a clone of the payload that is JSON safe
1436
+
1437
+ ### Parameters
1438
+
1439
+ #### meta?
1440
+
1441
+ `boolean` = `false`
1442
+
1443
+ Keeps underscore (meta) fields if set to true
1444
+
1445
+ ### Returns
1446
+
1447
+ `T`
1448
+
1449
+ Returns a clone of the payload that is JSON safe
1450
+
1451
+ ### Inherited from
1452
+
1453
+ ```ts
1454
+ ObjectHasher.json
1455
+ ```
1456
+
1457
+ ### functions
1458
+
1459
+ ### <a id="removeEmptyFields"></a>removeEmptyFields
1460
+
1461
+ [**@xyo-network/hash**](#../../README)
1462
+
1463
+ ***
1464
+
1465
+ ```ts
1466
+ function removeEmptyFields<T>(obj): T;
1467
+ ```
1468
+
1469
+ ## Type Parameters
1470
+
1471
+ ### T
1472
+
1473
+ `T` *extends* `object`
1474
+
1475
+ ## Parameters
1476
+
1477
+ ### obj
1478
+
1479
+ `T`
1480
+
1481
+ ## Returns
1482
+
1483
+ `T`
1484
+
1485
+ ### <a id="sortFields"></a>sortFields
1486
+
1487
+ [**@xyo-network/hash**](#../../README)
1488
+
1489
+ ***
1490
+
1491
+ ```ts
1492
+ function sortFields<T>(obj): T;
1493
+ ```
1494
+
1495
+ ## Type Parameters
1496
+
1497
+ ### T
1498
+
1499
+ `T` *extends* `object`
1500
+
1501
+ ## Parameters
1502
+
1503
+ ### obj
1504
+
1505
+ `T`
1506
+
1507
+ ## Returns
18
1508
 
19
- ## Credits
1509
+ `T`
20
1510
 
21
- [Made with 🔥 and ❄️ by XYO](https://xyo.network)
22
1511
 
23
- [logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
1512
+ [logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
1513
+ [npm-badge]: https://img.shields.io/npm/v/@xyo-network/hash.svg
1514
+ [npm-link]: https://www.npmjs.com/package/@xyo-network/hash
1515
+ [license-badge]: https://img.shields.io/npm/l/@xyo-network/hash.svg
1516
+ [license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE