fable 3.1.51 → 3.1.52
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 +87 -2
- package/dist/fable.js +7 -5
- package/dist/fable.js.map +1 -1
- package/dist/fable.min.js +1 -1
- package/dist/fable.min.js.map +1 -1
- package/docs/.nojekyll +0 -0
- package/docs/README.md +95 -0
- package/docs/_sidebar.md +42 -0
- package/docs/architecture.md +326 -0
- package/docs/cover.md +11 -0
- package/docs/index.html +51 -0
- package/docs/services/README.md +76 -0
- package/docs/services/anticipate.md +331 -0
- package/docs/services/csv-parser.md +152 -0
- package/docs/services/data-format.md +277 -0
- package/docs/services/data-generation.md +142 -0
- package/docs/services/dates.md +216 -0
- package/docs/services/environment-data.md +44 -0
- package/docs/services/expression-parser-functions/README.md +178 -0
- package/docs/services/expression-parser-functions/abs.md +84 -0
- package/docs/services/expression-parser-functions/aggregationhistogram.md +83 -0
- package/docs/services/expression-parser-functions/aggregationhistogrambyobject.md +64 -0
- package/docs/services/expression-parser-functions/arrayconcat.md +64 -0
- package/docs/services/expression-parser-functions/avg.md +81 -0
- package/docs/services/expression-parser-functions/bucketset.md +69 -0
- package/docs/services/expression-parser-functions/ceil.md +70 -0
- package/docs/services/expression-parser-functions/cleanvaluearray.md +66 -0
- package/docs/services/expression-parser-functions/cleanvalueobject.md +68 -0
- package/docs/services/expression-parser-functions/compare.md +72 -0
- package/docs/services/expression-parser-functions/concat.md +73 -0
- package/docs/services/expression-parser-functions/concatraw.md +73 -0
- package/docs/services/expression-parser-functions/cos.md +75 -0
- package/docs/services/expression-parser-functions/count.md +73 -0
- package/docs/services/expression-parser-functions/countset.md +65 -0
- package/docs/services/expression-parser-functions/countsetelements.md +63 -0
- package/docs/services/expression-parser-functions/createarrayfromabsolutevalues.md +63 -0
- package/docs/services/expression-parser-functions/createvalueobjectbyhashes.md +69 -0
- package/docs/services/expression-parser-functions/cumulativesummation.md +96 -0
- package/docs/services/expression-parser-functions/dateadddays.md +79 -0
- package/docs/services/expression-parser-functions/dateaddhours.md +74 -0
- package/docs/services/expression-parser-functions/dateaddmilliseconds.md +65 -0
- package/docs/services/expression-parser-functions/dateaddminutes.md +72 -0
- package/docs/services/expression-parser-functions/dateaddmonths.md +74 -0
- package/docs/services/expression-parser-functions/dateaddseconds.md +66 -0
- package/docs/services/expression-parser-functions/dateaddweeks.md +73 -0
- package/docs/services/expression-parser-functions/dateaddyears.md +74 -0
- package/docs/services/expression-parser-functions/datedaydifference.md +84 -0
- package/docs/services/expression-parser-functions/datefromparts.md +81 -0
- package/docs/services/expression-parser-functions/datehourdifference.md +64 -0
- package/docs/services/expression-parser-functions/datemathadd.md +72 -0
- package/docs/services/expression-parser-functions/datemilliseconddifference.md +64 -0
- package/docs/services/expression-parser-functions/dateminutedifference.md +64 -0
- package/docs/services/expression-parser-functions/datemonthdifference.md +66 -0
- package/docs/services/expression-parser-functions/dateseconddifference.md +64 -0
- package/docs/services/expression-parser-functions/dateweekdifference.md +65 -0
- package/docs/services/expression-parser-functions/dateyeardifference.md +64 -0
- package/docs/services/expression-parser-functions/distributionhistogram.md +96 -0
- package/docs/services/expression-parser-functions/distributionhistogrambyobject.md +64 -0
- package/docs/services/expression-parser-functions/entryinset.md +72 -0
- package/docs/services/expression-parser-functions/euler.md +77 -0
- package/docs/services/expression-parser-functions/exp.md +74 -0
- package/docs/services/expression-parser-functions/findfirstvaluebyexactmatch.md +67 -0
- package/docs/services/expression-parser-functions/findfirstvaluebystringincludes.md +67 -0
- package/docs/services/expression-parser-functions/flatten.md +76 -0
- package/docs/services/expression-parser-functions/floor.md +70 -0
- package/docs/services/expression-parser-functions/gaussianelimination.md +75 -0
- package/docs/services/expression-parser-functions/generatearrayofobjectsfromsets.md +70 -0
- package/docs/services/expression-parser-functions/getvalue.md +90 -0
- package/docs/services/expression-parser-functions/getvaluearray.md +64 -0
- package/docs/services/expression-parser-functions/getvalueobject.md +67 -0
- package/docs/services/expression-parser-functions/if.md +109 -0
- package/docs/services/expression-parser-functions/iterativeseries.md +107 -0
- package/docs/services/expression-parser-functions/join.md +75 -0
- package/docs/services/expression-parser-functions/joinraw.md +64 -0
- package/docs/services/expression-parser-functions/largestinset.md +63 -0
- package/docs/services/expression-parser-functions/leastsquares.md +66 -0
- package/docs/services/expression-parser-functions/linest.md +58 -0
- package/docs/services/expression-parser-functions/log.md +74 -0
- package/docs/services/expression-parser-functions/match.md +71 -0
- package/docs/services/expression-parser-functions/matrixinverse.md +67 -0
- package/docs/services/expression-parser-functions/matrixmultiply.md +71 -0
- package/docs/services/expression-parser-functions/matrixtranspose.md +72 -0
- package/docs/services/expression-parser-functions/matrixvectormultiply.md +69 -0
- package/docs/services/expression-parser-functions/max.md +73 -0
- package/docs/services/expression-parser-functions/mean.md +63 -0
- package/docs/services/expression-parser-functions/median.md +79 -0
- package/docs/services/expression-parser-functions/min.md +73 -0
- package/docs/services/expression-parser-functions/mode.md +66 -0
- package/docs/services/expression-parser-functions/objectkeystoarray.md +66 -0
- package/docs/services/expression-parser-functions/objectvaluessortbyexternalobjectarray.md +65 -0
- package/docs/services/expression-parser-functions/objectvaluestoarray.md +67 -0
- package/docs/services/expression-parser-functions/percent.md +75 -0
- package/docs/services/expression-parser-functions/pi.md +77 -0
- package/docs/services/expression-parser-functions/polynomialregression.md +69 -0
- package/docs/services/expression-parser-functions/predict.md +71 -0
- package/docs/services/expression-parser-functions/rad.md +85 -0
- package/docs/services/expression-parser-functions/randomfloat.md +63 -0
- package/docs/services/expression-parser-functions/randomfloatbetween.md +72 -0
- package/docs/services/expression-parser-functions/randomfloatupto.md +65 -0
- package/docs/services/expression-parser-functions/randominteger.md +56 -0
- package/docs/services/expression-parser-functions/randomintegerbetween.md +72 -0
- package/docs/services/expression-parser-functions/randomintegerupto.md +64 -0
- package/docs/services/expression-parser-functions/resolvehtmlentities.md +64 -0
- package/docs/services/expression-parser-functions/round.md +111 -0
- package/docs/services/expression-parser-functions/setconcatenate.md +64 -0
- package/docs/services/expression-parser-functions/sin.md +83 -0
- package/docs/services/expression-parser-functions/slice.md +80 -0
- package/docs/services/expression-parser-functions/smallestinset.md +63 -0
- package/docs/services/expression-parser-functions/sorthistogram.md +70 -0
- package/docs/services/expression-parser-functions/sorthistogrambykeys.md +69 -0
- package/docs/services/expression-parser-functions/sortset.md +75 -0
- package/docs/services/expression-parser-functions/sqrt.md +85 -0
- package/docs/services/expression-parser-functions/stdev.md +81 -0
- package/docs/services/expression-parser-functions/stdeva.md +58 -0
- package/docs/services/expression-parser-functions/stdevp.md +83 -0
- package/docs/services/expression-parser-functions/stringcountsegments.md +66 -0
- package/docs/services/expression-parser-functions/stringgetsegments.md +74 -0
- package/docs/services/expression-parser-functions/subtractingsummation.md +66 -0
- package/docs/services/expression-parser-functions/sum.md +78 -0
- package/docs/services/expression-parser-functions/tan.md +78 -0
- package/docs/services/expression-parser-functions/tofixed.md +75 -0
- package/docs/services/expression-parser-functions/var.md +67 -0
- package/docs/services/expression-parser-functions/vara.md +58 -0
- package/docs/services/expression-parser-functions/varp.md +66 -0
- package/docs/services/expression-parser-functions/when.md +98 -0
- package/docs/services/expression-parser.md +314 -0
- package/docs/services/file-persistence.md +279 -0
- package/docs/services/logging.md +237 -0
- package/docs/services/logic.md +166 -0
- package/docs/services/manifest.md +256 -0
- package/docs/services/math.md +279 -0
- package/docs/services/meta-template.md +268 -0
- package/docs/services/object-cache.md +171 -0
- package/docs/services/operation.md +207 -0
- package/docs/services/progress-time.md +167 -0
- package/docs/services/progress-tracker-set.md +222 -0
- package/docs/services/rest-client.md +296 -0
- package/docs/services/settings-manager.md +265 -0
- package/docs/services/template.md +233 -0
- package/docs/services/utility.md +304 -0
- package/docs/services/uuid.md +162 -0
- package/package.json +1 -1
- package/source/services/Fable-Service-DataFormat.js +1 -0
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js +6 -4
- package/test/ExpressionParser_tests.js +3 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Manifest Service
|
|
2
|
+
|
|
3
|
+
The Manifest service (powered by [manyfest](https://github.com/stevenvelozo/manyfest)) provides object navigation and manipulation using hash/address paths, supporting complex data access patterns.
|
|
4
|
+
|
|
5
|
+
## Access
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// On-demand service - instantiate when needed
|
|
9
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
10
|
+
|
|
11
|
+
// Or use the factory method (creates unregistered instance)
|
|
12
|
+
const manifest = fable.newManyfest();
|
|
13
|
+
|
|
14
|
+
// With definition
|
|
15
|
+
const manifest = fable.newManyfest({
|
|
16
|
+
Scope: 'User',
|
|
17
|
+
Descriptors: {
|
|
18
|
+
'Name': { Hash: 'name', Type: 'String' },
|
|
19
|
+
'Email': { Hash: 'email', Type: 'String' }
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Core Concepts
|
|
25
|
+
|
|
26
|
+
### Hash/Address Notation
|
|
27
|
+
|
|
28
|
+
Navigate objects using dot-notation paths:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
const obj = {
|
|
32
|
+
user: {
|
|
33
|
+
profile: {
|
|
34
|
+
name: 'John',
|
|
35
|
+
contacts: [
|
|
36
|
+
{ type: 'email', value: 'john@example.com' }
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
manifest.getValueByHash(obj, 'user.profile.name'); // 'John'
|
|
43
|
+
manifest.getValueByHash(obj, 'user.profile.contacts[0].value'); // 'john@example.com'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Getting Values
|
|
47
|
+
|
|
48
|
+
### getValueByHash
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
const data = { a: { b: { c: 'value' } } };
|
|
52
|
+
|
|
53
|
+
manifest.getValueByHash(data, 'a.b.c'); // 'value'
|
|
54
|
+
manifest.getValueByHash(data, 'a.b'); // { c: 'value' }
|
|
55
|
+
manifest.getValueByHash(data, 'x.y.z'); // undefined
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### With Default Value
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
manifest.getValueByHash(data, 'missing.path', 'default'); // 'default'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Array Access
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const data = { items: ['a', 'b', 'c'] };
|
|
68
|
+
|
|
69
|
+
manifest.getValueByHash(data, 'items[0]'); // 'a'
|
|
70
|
+
manifest.getValueByHash(data, 'items[2]'); // 'c'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Setting Values
|
|
74
|
+
|
|
75
|
+
### setValueByHash
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
const data = {};
|
|
79
|
+
|
|
80
|
+
manifest.setValueByHash(data, 'user.name', 'John');
|
|
81
|
+
// data is now { user: { name: 'John' } }
|
|
82
|
+
|
|
83
|
+
manifest.setValueByHash(data, 'user.age', 30);
|
|
84
|
+
// data is now { user: { name: 'John', age: 30 } }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Creating Nested Structures
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
const data = {};
|
|
91
|
+
manifest.setValueByHash(data, 'deep.nested.path.value', 'hello');
|
|
92
|
+
// Creates: { deep: { nested: { path: { value: 'hello' } } } }
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Array Setting
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
const data = { items: [] };
|
|
99
|
+
manifest.setValueByHash(data, 'items[0]', 'first');
|
|
100
|
+
manifest.setValueByHash(data, 'items[1]', 'second');
|
|
101
|
+
// data.items is ['first', 'second']
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Checking Existence
|
|
105
|
+
|
|
106
|
+
### checkAddressExists
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
const data = { a: { b: 'value' } };
|
|
110
|
+
|
|
111
|
+
manifest.checkAddressExists(data, 'a.b'); // true
|
|
112
|
+
manifest.checkAddressExists(data, 'a.c'); // false
|
|
113
|
+
manifest.checkAddressExists(data, 'x.y.z'); // false
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Manifest Definitions
|
|
117
|
+
|
|
118
|
+
Define schemas for structured data:
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
const userManifest = fable.newManyfest({
|
|
122
|
+
Scope: 'User',
|
|
123
|
+
Descriptors: {
|
|
124
|
+
'Full Name': {
|
|
125
|
+
Hash: 'profile.fullName',
|
|
126
|
+
Type: 'String',
|
|
127
|
+
Default: 'Unknown'
|
|
128
|
+
},
|
|
129
|
+
'Age': {
|
|
130
|
+
Hash: 'profile.age',
|
|
131
|
+
Type: 'Number',
|
|
132
|
+
Default: 0
|
|
133
|
+
},
|
|
134
|
+
'Email': {
|
|
135
|
+
Hash: 'contact.email',
|
|
136
|
+
Type: 'String'
|
|
137
|
+
},
|
|
138
|
+
'Active': {
|
|
139
|
+
Hash: 'status.isActive',
|
|
140
|
+
Type: 'Boolean',
|
|
141
|
+
Default: true
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Using Descriptors
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// Get all descriptor names
|
|
151
|
+
const names = userManifest.getDescriptorNames();
|
|
152
|
+
// ['Full Name', 'Age', 'Email', 'Active']
|
|
153
|
+
|
|
154
|
+
// Get descriptor by name
|
|
155
|
+
const emailDescriptor = userManifest.getDescriptor('Email');
|
|
156
|
+
// { Hash: 'contact.email', Type: 'String' }
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Boxed Properties
|
|
160
|
+
|
|
161
|
+
Access properties with special characters using brackets:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
const data = {
|
|
165
|
+
'my-special-key': 'value1',
|
|
166
|
+
'another key': 'value2'
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
manifest.getValueByHash(data, '["my-special-key"]'); // 'value1'
|
|
170
|
+
manifest.getValueByHash(data, "['another key']"); // 'value2'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Use Cases
|
|
174
|
+
|
|
175
|
+
### Dynamic Form Handling
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
function updateFormData(formData, fieldPath, value) {
|
|
179
|
+
const manifest = fable.newManyfest();
|
|
180
|
+
manifest.setValueByHash(formData, fieldPath, value);
|
|
181
|
+
return formData;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Usage
|
|
185
|
+
let form = {};
|
|
186
|
+
form = updateFormData(form, 'user.firstName', 'John');
|
|
187
|
+
form = updateFormData(form, 'user.lastName', 'Doe');
|
|
188
|
+
form = updateFormData(form, 'user.address.city', 'New York');
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Configuration Access
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
function getConfig(path, defaultValue) {
|
|
195
|
+
const manifest = fable.newManyfest();
|
|
196
|
+
return manifest.getValueByHash(fable.settings, path, defaultValue);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Usage
|
|
200
|
+
const timeout = getConfig('API.timeout', 30000);
|
|
201
|
+
const debug = getConfig('Logging.debug', false);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Data Transformation
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
function transformData(source, mappings) {
|
|
208
|
+
const manifest = fable.newManyfest();
|
|
209
|
+
const result = {};
|
|
210
|
+
|
|
211
|
+
Object.entries(mappings).forEach(([targetPath, sourcePath]) => {
|
|
212
|
+
const value = manifest.getValueByHash(source, sourcePath);
|
|
213
|
+
if (value !== undefined) {
|
|
214
|
+
manifest.setValueByHash(result, targetPath, value);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Usage
|
|
222
|
+
const transformed = transformData(apiResponse, {
|
|
223
|
+
'userName': 'data.user.name',
|
|
224
|
+
'userEmail': 'data.user.contact.email',
|
|
225
|
+
'createdAt': 'metadata.created'
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Safe Property Access
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
function safeGet(obj, path, defaultValue = null) {
|
|
233
|
+
const manifest = fable.newManyfest();
|
|
234
|
+
const value = manifest.getValueByHash(obj, path);
|
|
235
|
+
return value !== undefined ? value : defaultValue;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Safely access deeply nested properties
|
|
239
|
+
const city = safeGet(user, 'address.city', 'Unknown');
|
|
240
|
+
const phone = safeGet(user, 'contacts[0].phone', 'N/A');
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Integration with Other Services
|
|
244
|
+
|
|
245
|
+
The Manifest service is used internally by:
|
|
246
|
+
- `Utility.getValueByHash()`
|
|
247
|
+
- `Utility.setValueByHash()`
|
|
248
|
+
- Math service for object set operations
|
|
249
|
+
- Expression parser for variable resolution
|
|
250
|
+
|
|
251
|
+
## Notes
|
|
252
|
+
|
|
253
|
+
- Paths are case-sensitive
|
|
254
|
+
- Non-existent intermediate objects are created automatically when setting
|
|
255
|
+
- Array indices use bracket notation: `items[0]`
|
|
256
|
+
- Special characters in keys require bracket notation with quotes
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# Math Service
|
|
2
|
+
|
|
3
|
+
The Math service provides arbitrary precision mathematical operations using `big.js` under the hood. All operations return string values to preserve precision.
|
|
4
|
+
|
|
5
|
+
## Access
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// Auto-instantiated, available directly
|
|
9
|
+
fable.Math
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Constants
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
fable.Math.pi // Pi to 100 decimal places
|
|
16
|
+
fable.Math.euler // Euler's number to 100 decimal places
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Rounding Methods
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
fable.Math.roundDown // 0 - Truncate toward zero
|
|
23
|
+
fable.Math.roundHalfUp // 1 - Round to nearest, ties away from zero
|
|
24
|
+
fable.Math.roundHalfEven // 2 - Round to nearest, ties to even
|
|
25
|
+
fable.Math.roundUp // 3 - Always round away from zero
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Basic Operations
|
|
29
|
+
|
|
30
|
+
### Addition
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
fable.Math.addPrecise('1.5', '2.5'); // Returns '4'
|
|
34
|
+
fable.Math.addPrecise(1.5, 2.5); // Also works with numbers
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Subtraction
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
fable.Math.subtractPrecise('10', '3.5'); // Returns '6.5'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Multiplication
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
fable.Math.multiplyPrecise('2.5', '4'); // Returns '10'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Division
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
fable.Math.dividePrecise('10', '3'); // Returns '3.33333...'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Power
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
fable.Math.powerPrecise('2', '10'); // Returns '1024'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Modulo
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
fable.Math.modPrecise('10', '3'); // Returns '1'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Square Root
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
fable.Math.sqrtPrecise('16'); // Returns '4'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Absolute Value
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
fable.Math.absPrecise('-5.5'); // Returns '5.5'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Floor and Ceiling
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
fable.Math.floorPrecise('3.7'); // Returns '3'
|
|
83
|
+
fable.Math.ceilPrecise('3.2'); // Returns '4'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Rounding and Formatting
|
|
87
|
+
|
|
88
|
+
### Round to Decimal Places
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
fable.Math.roundPrecise('3.14159', 2); // Returns '3.14'
|
|
92
|
+
fable.Math.roundPrecise('3.14159', 2, fable.Math.roundUp); // Returns '3.15'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Fixed Decimal Places
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
fable.Math.toFixedPrecise('3.1', 4); // Returns '3.1000'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Comparison Operations
|
|
102
|
+
|
|
103
|
+
### Compare Values
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
fable.Math.comparePrecise('5', '3'); // Returns 1 (left > right)
|
|
107
|
+
fable.Math.comparePrecise('3', '5'); // Returns -1 (left < right)
|
|
108
|
+
fable.Math.comparePrecise('5', '5'); // Returns 0 (equal)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Compare Within Tolerance
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
fable.Math.comparePreciseWithin('1.0001', '1.0002', '0.001'); // Returns 0 (within tolerance)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Boolean Comparisons
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
fable.Math.gtPrecise('5', '3'); // Returns true
|
|
121
|
+
fable.Math.gtePrecise('5', '5'); // Returns true
|
|
122
|
+
fable.Math.ltPrecise('3', '5'); // Returns true
|
|
123
|
+
fable.Math.ltePrecise('5', '5'); // Returns true
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Parsing
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
fable.Math.parsePrecise('123.456'); // Returns '123.456'
|
|
130
|
+
fable.Math.parsePrecise('invalid', '0'); // Returns '0' (default value)
|
|
131
|
+
fable.Math.parsePrecise('not a number', null); // Returns null
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Percentage
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
fable.Math.percentagePrecise('25', '100'); // Returns '25' (25 is 25% of 100)
|
|
138
|
+
fable.Math.percentagePrecise('1', '4'); // Returns '25' (1 is 25% of 4)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Trigonometry
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
fable.Math.sin(Math.PI / 2); // Returns 1
|
|
145
|
+
fable.Math.cos(0); // Returns 1
|
|
146
|
+
fable.Math.tan(0); // Returns 0
|
|
147
|
+
fable.Math.radPrecise('180'); // Converts degrees to radians
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Logarithms and Exponentials
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
fable.Math.logPrecise('100', 10); // Returns log base 10 of 100
|
|
154
|
+
fable.Math.logPrecise('8', 2); // Returns log base 2 of 8
|
|
155
|
+
fable.Math.expPrecise('2'); // Returns e^2
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Statistical Functions (Sets)
|
|
159
|
+
|
|
160
|
+
### Count Elements
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
fable.Math.countSetElements([1, 2, 3, 4, 5]); // Returns 5
|
|
164
|
+
fable.Math.countSetElements({a: 1, b: 2}); // Returns 2
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Sum
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
fable.Math.sumPrecise([1, 2, 3, 4, 5]); // Returns '15'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Mean (Average)
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
fable.Math.meanPrecise([1, 2, 3, 4, 5]); // Returns '3'
|
|
177
|
+
fable.Math.averagePrecise([1, 2, 3, 4, 5]); // Same as meanPrecise
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Median
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
fable.Math.medianPrecise([1, 2, 3, 4, 5]); // Returns '3'
|
|
184
|
+
fable.Math.medianPrecise([1, 2, 3, 4]); // Returns '2.5'
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Mode
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
fable.Math.modePrecise([1, 2, 2, 3, 3, 3]); // Returns ['3']
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Min/Max
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
fable.Math.minPrecise([5, 2, 8, 1, 9]); // Returns '1'
|
|
197
|
+
fable.Math.maxPrecise([5, 2, 8, 1, 9]); // Returns '9'
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Variance and Standard Deviation
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
// Sample variance (default)
|
|
204
|
+
fable.Math.variancePrecise([1, 2, 3, 4, 5]);
|
|
205
|
+
|
|
206
|
+
// Population variance
|
|
207
|
+
fable.Math.populationVariancePrecise([1, 2, 3, 4, 5]);
|
|
208
|
+
|
|
209
|
+
// Sample standard deviation
|
|
210
|
+
fable.Math.standardDeviationPrecise([1, 2, 3, 4, 5]);
|
|
211
|
+
|
|
212
|
+
// Population standard deviation
|
|
213
|
+
fable.Math.populationStandardDeviationPrecise([1, 2, 3, 4, 5]);
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Sorting
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
fable.Math.sortSetPrecise([3, 1, 4, 1, 5]); // Returns ['1', '1', '3', '4', '5']
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Histogram
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
fable.Math.histogramPrecise([1, 2, 2, 3, 3, 3]);
|
|
226
|
+
// Returns { '1': 1, '2': 2, '3': 3 }
|
|
227
|
+
|
|
228
|
+
fable.Math.bucketSetPrecise([1, 2, 3, 4, 5, 6], 2);
|
|
229
|
+
// Bucketize by size 2
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Linear Algebra
|
|
233
|
+
|
|
234
|
+
### Matrix Operations
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
// Matrix transpose
|
|
238
|
+
fable.Math.matrixTranspose([[1, 2], [3, 4]]);
|
|
239
|
+
|
|
240
|
+
// Matrix multiplication
|
|
241
|
+
fable.Math.matrixMultiply([[1, 2], [3, 4]], [[5, 6], [7, 8]]);
|
|
242
|
+
|
|
243
|
+
// Matrix inverse
|
|
244
|
+
fable.Math.matrixInverse([[1, 2], [3, 4]]);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Regression
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
// Least squares regression
|
|
251
|
+
const coefficients = fable.Math.leastSquares(
|
|
252
|
+
[1, 2, 3, 4, 5], // X values
|
|
253
|
+
[2, 4, 5, 4, 5] // Y values
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
// Predict from regression model
|
|
257
|
+
fable.Math.predictFromRegressionModel(coefficients, 6);
|
|
258
|
+
|
|
259
|
+
// Polynomial regression
|
|
260
|
+
fable.Math.polynomialRegression(xValues, yValues, degree);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Cumulative Operations
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
const data = [
|
|
267
|
+
{ value: 10 },
|
|
268
|
+
{ value: 20 },
|
|
269
|
+
{ value: 30 }
|
|
270
|
+
];
|
|
271
|
+
|
|
272
|
+
// Cumulative summation
|
|
273
|
+
fable.Math.cumulativeSummation(data, 'value', 'cumulative');
|
|
274
|
+
// Adds 'cumulative' property: 10, 30, 60
|
|
275
|
+
|
|
276
|
+
// Subtracting summation (starting from a value)
|
|
277
|
+
fable.Math.subtractingSummation(data, 'value', 'remaining', '100');
|
|
278
|
+
// Subtracts from 100: 90, 70, 40
|
|
279
|
+
```
|