-
Notifications
You must be signed in to change notification settings - Fork 0
/
edition.js
94 lines (75 loc) · 3.99 KB
/
edition.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
Fōrmulæ data package. Module for edition.
Copyright (C) 2015-2025 Laurence R. Ugalde
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
'use strict';
export class Data extends Formulae.Package {}
Data.setEditions = function() {
Formulae.addEdition(this.messages.pathData, null, this.messages.leafCreateByteBuffer, () => Expression.wrapperEdition("Data.CreateByteBuffer"));
// Extract from byte buffer
[ 8, 16, 32, 64 ].forEach(size => {
let mnemonic = Data.messages.mnemonicGetInteger + size;
let name = Data.messages.nameGetInteger1 + size + Data.messages.nameGetInteger2;
Formulae.addEdition(
this.messages.pathExtraction,
null,
name,
() => Expression.multipleEdition("Data." + mnemonic, 2, 0)
);
});
[ 32, 64 ].forEach(size => {
let mnemonic = Data.messages.mnemonicGetFloat + size;
let name = Data.messages.nameGetFloat1 + size + Data.messages.nameGetFloat2;
Formulae.addEdition(
this.messages.pathExtraction,
null,
name,
() => Expression.multipleEdition("Data." + mnemonic, 2, 0)
);
});
// Update byte buffer
[ 8, 16, 32, 64 ].forEach(size => {
let mnemonic = Data.messages.mnemonicSetInteger + size;
let name = Data.messages.nameSetInteger1 + size + Data.messages.nameSetInteger2;
Formulae.addEdition(
this.messages.pathUpdate,
null,
name,
() => Expression.multipleEdition("Data." + mnemonic, 3, 0)
);
});
[ 32, 64 ].forEach(size => {
let mnemonic = Data.messages.mnemonicSetFloat + size;
let name = Data.messages.nameSetFloat1 + size + Data.messages.nameSetFloat2;
Formulae.addEdition(
this.messages.pathUpdate,
null,
name,
() => Expression.multipleEdition("Data." + mnemonic, 3, 0)
);
});
// Conversion
Formulae.addEdition(this.messages.pathToBytes, null, this.messages.leafStringToBytes, () => Expression.wrapperEdition("Data.StringToBytes"));
Formulae.addEdition(this.messages.pathToBytes, null, this.messages.leafBase64ToBytes, () => Expression.wrapperEdition("Data.Base64ToBytes"));
Formulae.addEdition(this.messages.pathToBytes, null, this.messages.leafHexToBytes, () => Expression.wrapperEdition("Data.HexToBytes"));
Formulae.addEdition(this.messages.pathToBytes, null, this.messages.leafArrayToBytes, () => Expression.wrapperEdition("Data.ArrayToBytes"));
Formulae.addEdition(this.messages.pathFromBytes, null, this.messages.leafBytesToString, () => Expression.wrapperEdition("Data.BytesToString"));
Formulae.addEdition(this.messages.pathFromBytes, null, this.messages.leafBytesToBase64, () => Expression.wrapperEdition("Data.BytesToBase64"));
Formulae.addEdition(this.messages.pathFromBytes, null, this.messages.leafBytesToHex, () => Expression.wrapperEdition("Data.BytesToHex"));
Formulae.addEdition(this.messages.pathFromBytes, null, this.messages.leafBytesToArray, () => Expression.wrapperEdition("Data.BytesToArray"));
// Options
Formulae.addEdition(this.messages.pathSign, null, this.messages.nameUnsigned, () => Expression.replacingEdition("Data.Sign.Unsigned"));
Formulae.addEdition(this.messages.pathSign, null, this.messages.nameSigned, () => Expression.replacingEdition("Data.Sign.Signed"));
Formulae.addEdition(this.messages.pathEndianness, null, this.messages["nameLittle-endian"], () => Expression.replacingEdition("Data.Endianness.Little-endian"));
Formulae.addEdition(this.messages.pathEndianness, null, this.messages["nameBig-endian"], () => Expression.replacingEdition("Data.Endianness.Big-endian"));
};