@nfdi4plants/arctrl 2.3.1 → 2.5.0
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/ARC.js +103 -12
- package/CWL/CWLTypes.js +2 -2
- package/CWL/Decode.js +2 -2
- package/CWL/Inputs.js +2 -2
- package/CWL/Outputs.js +2 -2
- package/CWL/Requirements.js +2 -2
- package/CWL/ToolDescription.js +1 -1
- package/CWL/WorkflowDescription.js +1 -1
- package/CWL/WorkflowSteps.js +1 -1
- package/ColumnIndex.js +258 -0
- package/Conversion.js +1679 -0
- package/Core/Data.js +28 -3
- package/Core/DataFile.js +19 -3
- package/Core/Helper/Collections.js +107 -4
- package/Core/Helper/DateTime.js +17 -0
- package/Core/Helper/ORCID.js +39 -0
- package/Core/Table/ArcTable.js +6 -0
- package/Core/Table/CompositeHeader.js +4 -0
- package/Json/Assay.js +1 -1
- package/Json/Decode.js +3 -3
- package/Json/Encode.js +9 -0
- package/Json/Investigation.js +5 -4
- package/Json/OntologySourceReference.js +4 -4
- package/Json/ROCrate/LDContext.js +121 -0
- package/Json/ROCrate/LDGraph.js +87 -0
- package/Json/{LDObject.js → ROCrate/LDNode.js} +55 -46
- package/Json/ROCrate/LDRef.js +25 -0
- package/Json/ROCrate/LDValue.js +66 -0
- package/Json/Study.js +5 -4
- package/Json/context/rocrate/isa_investigation_context.js +2 -2
- package/Json/context/rocrate/isa_study_context.js +15 -11
- package/Json/context/rocrate/rocrate_context.js +1 -1
- package/JsonIO/LDObject.js +30 -5
- package/README.md +12 -3
- package/ROCrate/ArcROCrateMetadata.js +14 -13
- package/ROCrate/Generic/Comment.js +115 -0
- package/ROCrate/Generic/Dataset.js +669 -0
- package/ROCrate/Generic/DefinedTerm.js +115 -0
- package/ROCrate/Generic/File.js +200 -0
- package/ROCrate/Generic/LabProcess.js +238 -0
- package/ROCrate/Generic/LabProtocol.js +275 -0
- package/ROCrate/Generic/Organization.js +71 -0
- package/ROCrate/Generic/Person.js +411 -0
- package/ROCrate/Generic/PostalAddress.js +159 -0
- package/ROCrate/Generic/PropertyValue.js +548 -0
- package/ROCrate/Generic/Sample.js +139 -0
- package/ROCrate/Generic/ScholarlyArticle.js +187 -0
- package/ROCrate/Helper.js +6 -0
- package/ROCrate/ISAProfile/Assay.js +3 -3
- package/ROCrate/ISAProfile/Data.js +7 -7
- package/ROCrate/ISAProfile/Dataset.js +7 -6
- package/ROCrate/ISAProfile/Investigation.js +3 -3
- package/ROCrate/ISAProfile/LabProcess.js +7 -7
- package/ROCrate/ISAProfile/LabProtocol.js +7 -7
- package/ROCrate/ISAProfile/Person.js +7 -7
- package/ROCrate/ISAProfile/PropertyValue.js +7 -7
- package/ROCrate/ISAProfile/Sample.js +7 -7
- package/ROCrate/ISAProfile/ScholarlyArticle.js +7 -7
- package/ROCrate/ISAProfile/Study.js +3 -3
- package/ROCrate/LDContext.js +283 -0
- package/ROCrate/LDObject.js +902 -36
- package/ROCrate/ROCrateContext.js +44 -0
- package/ROCrateIO.js +62 -0
- package/Spreadsheet/DataMap.js +11 -3
- package/Spreadsheet/DataMapTable/DataMapHeader.js +3 -2
- package/Xlsx.js +21 -8
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/DynObj.fs +31 -1
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/DynObj.fs.js +30 -1
- package/fable_modules/DynamicObj.7.0.1/DynamicObj.fs +1025 -0
- package/fable_modules/DynamicObj.7.0.1/DynamicObj.fs.js +433 -0
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/FableJS.fs +16 -0
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/FablePy.fs +14 -0
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/HashCodes.fs +15 -0
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/HashCodes.fs.js +4 -0
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Debug/netstandard2.0/DynamicObj.AssemblyInfo.fs +1 -1
- package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Release/netstandard2.0/DynamicObj.AssemblyInfo.fs +3 -3
- package/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
- package/Json/ARC.js +0 -31
- package/JsonIO/ARC.js +0 -31
- package/fable_modules/DynamicObj.4.0.3/DynamicObj.fs +0 -310
- package/fable_modules/DynamicObj.4.0.3/DynamicObj.fs.js +0 -166
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/DynamicObj.fableproj +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/FableJS.fs.js +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/PropertyHelper.fs +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/PropertyHelper.fs.js +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/ReflectionUtils.fs +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/ReflectionUtils.fs.js +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Debug/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -0
- /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { tryGetStaticPropertyInfo } from "./ReflectionUtils.fs.js";
|
|
2
|
+
import { getPropertyHelpers, tryGetDynamicPropertyHelper } from "./FableJS.fs.js";
|
|
3
|
+
import { defaultArg, value as value_4, map } from "../fable-library-js.4.24.0/Option.js";
|
|
4
|
+
import { singleton, enumerateWhile, delay, toList, sortBy, iterate, map as map_1, choose, filter } from "../fable-library-js.4.24.0/Seq.js";
|
|
5
|
+
import { isArrayLike, disposeSafe, structuralHash, equals, getEnumerator, isIterable, comparePrimitives, safeHash } from "../fable-library-js.4.24.0/Util.js";
|
|
6
|
+
import { class_type } from "../fable-library-js.4.24.0/Reflection.js";
|
|
7
|
+
import { mergeHashes, hash as hash_2, boxHashKeyValSeqBy } from "./HashCodes.fs.js";
|
|
8
|
+
import { FSharpList, reduce, isEmpty } from "../fable-library-js.4.24.0/List.js";
|
|
9
|
+
import { Dictionary } from "../fable-library-js.4.24.0/MutableMap.js";
|
|
10
|
+
import { addToDict } from "../fable-library-js.4.24.0/MapUtil.js";
|
|
11
|
+
import Decimal from "../fable-library-js.4.24.0/Decimal.js";
|
|
12
|
+
|
|
13
|
+
export class DynamicObj {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.properties = (new Map([]));
|
|
16
|
+
}
|
|
17
|
+
get Properties() {
|
|
18
|
+
const this$ = this;
|
|
19
|
+
return this$.properties;
|
|
20
|
+
}
|
|
21
|
+
set Properties(value) {
|
|
22
|
+
const this$ = this;
|
|
23
|
+
this$.properties = value;
|
|
24
|
+
}
|
|
25
|
+
static ofDict(dynamicProperties) {
|
|
26
|
+
const obj = new DynamicObj();
|
|
27
|
+
obj.Properties = dynamicProperties;
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
TryGetStaticPropertyHelper(propertyName) {
|
|
31
|
+
const this$ = this;
|
|
32
|
+
return tryGetStaticPropertyInfo(this$, propertyName);
|
|
33
|
+
}
|
|
34
|
+
TryGetDynamicPropertyHelper(propertyName) {
|
|
35
|
+
const this$ = this;
|
|
36
|
+
return tryGetDynamicPropertyHelper(this$, propertyName);
|
|
37
|
+
}
|
|
38
|
+
TryGetPropertyHelper(propertyName) {
|
|
39
|
+
const this$ = this;
|
|
40
|
+
const matchValue = this$.TryGetStaticPropertyHelper(propertyName);
|
|
41
|
+
return (matchValue == null) ? this$.TryGetDynamicPropertyHelper(propertyName) : matchValue;
|
|
42
|
+
}
|
|
43
|
+
TryGetPropertyValue(propertyName) {
|
|
44
|
+
const this$ = this;
|
|
45
|
+
return map((pi) => pi.GetValue(this$), this$.TryGetPropertyHelper(propertyName));
|
|
46
|
+
}
|
|
47
|
+
GetPropertyValue(propertyName) {
|
|
48
|
+
const this$ = this;
|
|
49
|
+
const matchValue = this$.TryGetPropertyValue(propertyName);
|
|
50
|
+
if (matchValue == null) {
|
|
51
|
+
throw new Error(`No dynamic or static property "${propertyName}" does exist on object.`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return value_4(matchValue);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
SetProperty(propertyName, propertyValue) {
|
|
58
|
+
const this$ = this;
|
|
59
|
+
const matchValue = this$.TryGetStaticPropertyHelper(propertyName);
|
|
60
|
+
if (matchValue == null) {
|
|
61
|
+
this$[propertyName] = propertyValue;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const pi = matchValue;
|
|
65
|
+
if (pi.IsMutable) {
|
|
66
|
+
pi.SetValue(this$, propertyValue);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`Cannot set value for static, immutable property "${propertyName}"`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
RemoveProperty(propertyName) {
|
|
74
|
+
const this$ = this;
|
|
75
|
+
const matchValue = this$.TryGetPropertyHelper(propertyName);
|
|
76
|
+
if (matchValue == null) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
else if (matchValue.IsMutable) {
|
|
80
|
+
const pi_1 = matchValue;
|
|
81
|
+
pi_1.RemoveValue(this$);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new Error(`Cannot remove value for static, immutable property "${propertyName}"`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
GetPropertyHelpers(includeInstanceProperties) {
|
|
89
|
+
const this$ = this;
|
|
90
|
+
return filter((p) => (p.Name.toLocaleLowerCase() !== "properties"), filter((pd) => {
|
|
91
|
+
if (includeInstanceProperties) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return pd.IsDynamic;
|
|
96
|
+
}
|
|
97
|
+
}, getPropertyHelpers(this$)));
|
|
98
|
+
}
|
|
99
|
+
GetProperties(includeInstanceProperties) {
|
|
100
|
+
const this$ = this;
|
|
101
|
+
return choose((kv) => {
|
|
102
|
+
if (kv.Name !== "properties") {
|
|
103
|
+
return [kv.Name, kv.GetValue(this$)];
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
}, this$.GetPropertyHelpers(includeInstanceProperties));
|
|
109
|
+
}
|
|
110
|
+
GetPropertyNames(includeInstanceProperties) {
|
|
111
|
+
const this$ = this;
|
|
112
|
+
return map_1((kv) => kv[0], this$.GetProperties(includeInstanceProperties));
|
|
113
|
+
}
|
|
114
|
+
ShallowCopyDynamicPropertiesTo(target, overWrite) {
|
|
115
|
+
const this$ = this;
|
|
116
|
+
const overWrite_1 = defaultArg(overWrite, false);
|
|
117
|
+
iterate((kv) => {
|
|
118
|
+
let pi;
|
|
119
|
+
const matchValue = target.TryGetPropertyHelper(kv[0]);
|
|
120
|
+
if (matchValue == null) {
|
|
121
|
+
target.SetProperty(kv[0], kv[1]);
|
|
122
|
+
}
|
|
123
|
+
else if ((pi = matchValue, overWrite_1)) {
|
|
124
|
+
const pi_1 = matchValue;
|
|
125
|
+
pi_1.SetValue(target, kv[1]);
|
|
126
|
+
}
|
|
127
|
+
}, this$.GetProperties(false));
|
|
128
|
+
}
|
|
129
|
+
ShallowCopyDynamicProperties() {
|
|
130
|
+
const this$ = this;
|
|
131
|
+
const target = new DynamicObj();
|
|
132
|
+
this$.ShallowCopyDynamicPropertiesTo(target, true);
|
|
133
|
+
return target;
|
|
134
|
+
}
|
|
135
|
+
DeepCopyPropertiesTo(target, overWrite, includeInstanceProperties) {
|
|
136
|
+
const this$ = this;
|
|
137
|
+
const overWrite_1 = defaultArg(overWrite, false);
|
|
138
|
+
const includeInstanceProperties_1 = defaultArg(includeInstanceProperties, true);
|
|
139
|
+
iterate((kv) => {
|
|
140
|
+
let pi;
|
|
141
|
+
const matchValue = target.TryGetPropertyHelper(kv[0]);
|
|
142
|
+
if (matchValue == null) {
|
|
143
|
+
target.SetProperty(kv[0], CopyUtils_tryDeepCopyObj_75B3D832(kv[1]));
|
|
144
|
+
}
|
|
145
|
+
else if ((pi = matchValue, overWrite_1)) {
|
|
146
|
+
const pi_1 = matchValue;
|
|
147
|
+
pi_1.SetValue(target, CopyUtils_tryDeepCopyObj_75B3D832(kv[1]));
|
|
148
|
+
}
|
|
149
|
+
}, this$.GetProperties(includeInstanceProperties_1));
|
|
150
|
+
}
|
|
151
|
+
DeepCopyProperties(includeInstanceProperties) {
|
|
152
|
+
const this$ = this;
|
|
153
|
+
return CopyUtils_tryDeepCopyObj_75B3D832(this$, defaultArg(includeInstanceProperties, true));
|
|
154
|
+
}
|
|
155
|
+
static op_Dynamic(lookup, name) {
|
|
156
|
+
const matchValue = lookup.TryGetPropertyValue(name);
|
|
157
|
+
if (matchValue == null) {
|
|
158
|
+
throw new Error();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return value_4(matchValue);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
static op_DynamicAssignment(lookup, name, value) {
|
|
165
|
+
lookup.SetProperty(name, value);
|
|
166
|
+
}
|
|
167
|
+
ReferenceEquals(other) {
|
|
168
|
+
const this$ = this;
|
|
169
|
+
return this$ === other;
|
|
170
|
+
}
|
|
171
|
+
StructurallyEquals(other) {
|
|
172
|
+
const this$ = this;
|
|
173
|
+
return safeHash(this$) === safeHash(other);
|
|
174
|
+
}
|
|
175
|
+
GetHashCode() {
|
|
176
|
+
const this$ = this;
|
|
177
|
+
return HashUtils_deepHash_4E60E31B(this$) | 0;
|
|
178
|
+
}
|
|
179
|
+
Equals(o) {
|
|
180
|
+
let other;
|
|
181
|
+
const this$ = this;
|
|
182
|
+
return (o instanceof DynamicObj) && ((other = o, this$.StructurallyEquals(other)));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function DynamicObj_$reflection() {
|
|
187
|
+
return class_type("DynamicObj.DynamicObj", undefined, DynamicObj);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function DynamicObj_$ctor() {
|
|
191
|
+
return new DynamicObj();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export class HashUtils {
|
|
195
|
+
constructor() {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function HashUtils_$reflection() {
|
|
200
|
+
return class_type("DynamicObj.HashUtils", undefined, HashUtils);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export class CopyUtils {
|
|
204
|
+
constructor() {
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function CopyUtils_$reflection() {
|
|
209
|
+
return class_type("DynamicObj.CopyUtils", undefined, CopyUtils);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function HashUtils_deepHash_4E60E31B(o) {
|
|
213
|
+
if (o instanceof DynamicObj) {
|
|
214
|
+
return boxHashKeyValSeqBy(HashUtils_deepHash_4E60E31B, sortBy((pair) => pair[0], o.GetProperties(true), {
|
|
215
|
+
Compare: comparePrimitives,
|
|
216
|
+
})) | 0;
|
|
217
|
+
}
|
|
218
|
+
else if (typeof o === "string") {
|
|
219
|
+
return hash_2(o) | 0;
|
|
220
|
+
}
|
|
221
|
+
else if (isIterable(o)) {
|
|
222
|
+
const e = o;
|
|
223
|
+
const en = getEnumerator(e);
|
|
224
|
+
const l = toList(delay(() => enumerateWhile(() => en["System.Collections.IEnumerator.MoveNext"](), delay(() => singleton(HashUtils_deepHash_4E60E31B(en["System.Collections.IEnumerator.get_Current"]()))))));
|
|
225
|
+
if (isEmpty(l)) {
|
|
226
|
+
return 0;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return reduce(mergeHashes, l) | 0;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
return hash_2(o) | 0;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* function to deep copy a boxed object (if possible)
|
|
239
|
+
* The following cases are handled (in this precedence):
|
|
240
|
+
*
|
|
241
|
+
* - Basic F# types (`bool`, `byte`, `sbyte`, `int16`, `uint16`, `int`, `uint`, `int64`, `uint64`, `nativeint`, `unativeint`, `float`, `float32`, `char`, `string`, `unit`, `decimal`)
|
|
242
|
+
*
|
|
243
|
+
* - `ResizeArrays` and `Dictionaries` containing any combination of basic F# types
|
|
244
|
+
*
|
|
245
|
+
* - `Dictionaries` containing `DynamicObj` as keys or values in any combination with `DynamicObj` or basic F# types as keys or values
|
|
246
|
+
*
|
|
247
|
+
* - `array<DynamicObj>`, `list<DynamicObj>`, `ResizeArray<DynamicObj>`: These collections of DynamicObj are copied as a new collection with recursively deep copied elements.
|
|
248
|
+
*
|
|
249
|
+
* - `System.ICloneable`: If the property implements `ICloneable`, the `Clone()` method is called on the property.
|
|
250
|
+
*
|
|
251
|
+
* - `DynamicObj` (and derived classes): properties that are themselves `DynamicObj` instances are deep copied recursively.
|
|
252
|
+
* if a derived class has static properties (e.g. instance properties), these can be copied as dynamic properties on the new instance or ignored.
|
|
253
|
+
*
|
|
254
|
+
* Note on Classes that inherit from `DynamicObj`:
|
|
255
|
+
*
|
|
256
|
+
* Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement `ICloneable`.
|
|
257
|
+
* The deep copied instances will be cast to `DynamicObj` with deep copied dynamic properties. Staic/instance properties can be copied as dynamic properties on the new instance or be ignored.
|
|
258
|
+
* It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties,
|
|
259
|
+
* and then passing them to the class constructor if needed.
|
|
260
|
+
*/
|
|
261
|
+
export function CopyUtils_tryDeepCopyObj_75B3D832(o, includeInstanceProperties) {
|
|
262
|
+
const includeInstanceProperties_1 = defaultArg(includeInstanceProperties, true);
|
|
263
|
+
const tryDeepCopyObj = (o_1) => {
|
|
264
|
+
let matchResult, o_12, o_14, o_16;
|
|
265
|
+
if (typeof o_1 === "boolean") {
|
|
266
|
+
matchResult = 0;
|
|
267
|
+
}
|
|
268
|
+
else if (typeof o_1 === "number") {
|
|
269
|
+
matchResult = 0;
|
|
270
|
+
}
|
|
271
|
+
else if (typeof o_1 === "number") {
|
|
272
|
+
matchResult = 0;
|
|
273
|
+
}
|
|
274
|
+
else if (typeof o_1 === "number") {
|
|
275
|
+
matchResult = 0;
|
|
276
|
+
}
|
|
277
|
+
else if (typeof o_1 === "number") {
|
|
278
|
+
matchResult = 0;
|
|
279
|
+
}
|
|
280
|
+
else if (typeof o_1 === "number") {
|
|
281
|
+
matchResult = 0;
|
|
282
|
+
}
|
|
283
|
+
else if (typeof o_1 === "number") {
|
|
284
|
+
matchResult = 0;
|
|
285
|
+
}
|
|
286
|
+
else if (typeof o_1 === "bigint") {
|
|
287
|
+
matchResult = 0;
|
|
288
|
+
}
|
|
289
|
+
else if (typeof o_1 === "bigint") {
|
|
290
|
+
matchResult = 0;
|
|
291
|
+
}
|
|
292
|
+
else if (typeof o_1 === "number") {
|
|
293
|
+
matchResult = 0;
|
|
294
|
+
}
|
|
295
|
+
else if (typeof o_1 === "number") {
|
|
296
|
+
matchResult = 0;
|
|
297
|
+
}
|
|
298
|
+
else if (typeof o_1 === "string") {
|
|
299
|
+
matchResult = 0;
|
|
300
|
+
}
|
|
301
|
+
else if (typeof o_1 === "string") {
|
|
302
|
+
matchResult = 0;
|
|
303
|
+
}
|
|
304
|
+
else if (o_1 == null) {
|
|
305
|
+
matchResult = 0;
|
|
306
|
+
}
|
|
307
|
+
else if (o_1 instanceof Decimal) {
|
|
308
|
+
matchResult = 1;
|
|
309
|
+
}
|
|
310
|
+
else if (isArrayLike(o_1)) {
|
|
311
|
+
if (o_1 instanceof Map) {
|
|
312
|
+
matchResult = 2;
|
|
313
|
+
o_12 = o_1;
|
|
314
|
+
}
|
|
315
|
+
else if (o_1 instanceof Dictionary) {
|
|
316
|
+
matchResult = 3;
|
|
317
|
+
o_14 = o_1;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
matchResult = 4;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else if (o_1 instanceof FSharpList) {
|
|
324
|
+
if (o_1 instanceof Map) {
|
|
325
|
+
matchResult = 2;
|
|
326
|
+
o_12 = o_1;
|
|
327
|
+
}
|
|
328
|
+
else if (o_1 instanceof Dictionary) {
|
|
329
|
+
matchResult = 3;
|
|
330
|
+
o_14 = o_1;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
matchResult = 5;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else if (o_1 instanceof DynamicObj) {
|
|
337
|
+
if (o_1 instanceof Map) {
|
|
338
|
+
matchResult = 2;
|
|
339
|
+
o_12 = o_1;
|
|
340
|
+
}
|
|
341
|
+
else if (o_1 instanceof Dictionary) {
|
|
342
|
+
matchResult = 3;
|
|
343
|
+
o_14 = o_1;
|
|
344
|
+
}
|
|
345
|
+
else if (o_1["System.ICloneable.Clone"] != undefined && (typeof o_1["System.ICloneable.Clone"]) === 'function') {
|
|
346
|
+
matchResult = 6;
|
|
347
|
+
o_16 = o_1;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
matchResult = 7;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else if (o_1 instanceof Map) {
|
|
354
|
+
matchResult = 2;
|
|
355
|
+
o_12 = o_1;
|
|
356
|
+
}
|
|
357
|
+
else if (o_1 instanceof Dictionary) {
|
|
358
|
+
matchResult = 3;
|
|
359
|
+
o_14 = o_1;
|
|
360
|
+
}
|
|
361
|
+
else if (o_1["System.ICloneable.Clone"] != undefined && (typeof o_1["System.ICloneable.Clone"]) === 'function') {
|
|
362
|
+
matchResult = 6;
|
|
363
|
+
o_16 = o_1;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
matchResult = 8;
|
|
367
|
+
}
|
|
368
|
+
switch (matchResult) {
|
|
369
|
+
case 0:
|
|
370
|
+
return o_1;
|
|
371
|
+
case 1:
|
|
372
|
+
return o_1;
|
|
373
|
+
case 2: {
|
|
374
|
+
const newDict = new Dictionary([], {
|
|
375
|
+
Equals: equals,
|
|
376
|
+
GetHashCode: structuralHash,
|
|
377
|
+
});
|
|
378
|
+
let enumerator = getEnumerator(o_12);
|
|
379
|
+
try {
|
|
380
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
381
|
+
const kv = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
382
|
+
addToDict(newDict, tryDeepCopyObj(kv[0]), tryDeepCopyObj(kv[1]));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
finally {
|
|
386
|
+
disposeSafe(enumerator);
|
|
387
|
+
}
|
|
388
|
+
return newDict;
|
|
389
|
+
}
|
|
390
|
+
case 3: {
|
|
391
|
+
const newDict_1 = new Dictionary([], {
|
|
392
|
+
Equals: equals,
|
|
393
|
+
GetHashCode: structuralHash,
|
|
394
|
+
});
|
|
395
|
+
let enumerator_1 = getEnumerator(o_14);
|
|
396
|
+
try {
|
|
397
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
398
|
+
const kv_1 = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
399
|
+
addToDict(newDict_1, tryDeepCopyObj(kv_1[0]), tryDeepCopyObj(kv_1[1]));
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
finally {
|
|
403
|
+
disposeSafe(enumerator_1);
|
|
404
|
+
}
|
|
405
|
+
return newDict_1;
|
|
406
|
+
}
|
|
407
|
+
case 4:
|
|
408
|
+
return Array.from(toList(delay(() => map_1(tryDeepCopyObj, o_1))));
|
|
409
|
+
case 5:
|
|
410
|
+
return toList(delay(() => map_1(tryDeepCopyObj, o_1)));
|
|
411
|
+
case 6:
|
|
412
|
+
return o_16["System.ICloneable.Clone"]();
|
|
413
|
+
case 7: {
|
|
414
|
+
const newDyn = new DynamicObj();
|
|
415
|
+
const enumerator_2 = getEnumerator(o_1.GetProperties(includeInstanceProperties_1));
|
|
416
|
+
try {
|
|
417
|
+
while (enumerator_2["System.Collections.IEnumerator.MoveNext"]()) {
|
|
418
|
+
const kv_2 = enumerator_2["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
419
|
+
newDyn.SetProperty(kv_2[0], tryDeepCopyObj(kv_2[1]));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
finally {
|
|
423
|
+
disposeSafe(enumerator_2);
|
|
424
|
+
}
|
|
425
|
+
return newDyn;
|
|
426
|
+
}
|
|
427
|
+
default:
|
|
428
|
+
return o_1;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
return tryDeepCopyObj(o);
|
|
432
|
+
}
|
|
433
|
+
|
|
@@ -158,5 +158,21 @@ module FableJS =
|
|
|
158
158
|
getPropertyHelpers o
|
|
159
159
|
|> Array.map (fun h -> h.Name)
|
|
160
160
|
|
|
161
|
+
module Interfaces =
|
|
162
|
+
|
|
163
|
+
[<Emit("""$0["System.ICloneable.Clone"] != undefined && (typeof $0["System.ICloneable.Clone"]) === 'function'""")>]
|
|
164
|
+
let implementsICloneable (o:obj) : bool =
|
|
165
|
+
jsNative
|
|
166
|
+
|
|
167
|
+
[<Emit("""$0["System.ICloneable.Clone"]()""")>]
|
|
168
|
+
let cloneICloneable (o:obj) : obj =
|
|
169
|
+
jsNative
|
|
161
170
|
|
|
171
|
+
module Dictionaries =
|
|
172
|
+
[<Emit("""$0 instanceof Map""")>]
|
|
173
|
+
let isMap (o:obj) : bool =
|
|
174
|
+
jsNative
|
|
175
|
+
[<Emit("""$0 instanceof Dictionary""")>]
|
|
176
|
+
let isDict (o:obj) : bool =
|
|
177
|
+
jsNative
|
|
162
178
|
#endif
|
|
@@ -211,5 +211,19 @@ module FablePy =
|
|
|
211
211
|
getPropertyHelpers o
|
|
212
212
|
|> Array.map (fun h -> h.Name)
|
|
213
213
|
|
|
214
|
+
module Interfaces =
|
|
215
|
+
|
|
216
|
+
[<Emit("""hasattr($0, 'System_ICloneable_Clone') and callable($0.System_ICloneable_Clone)""")>]
|
|
217
|
+
let implementsICloneable (o:obj) : bool =
|
|
218
|
+
nativeOnly
|
|
219
|
+
|
|
220
|
+
[<Emit("""$0.System_ICloneable_Clone()""")>]
|
|
221
|
+
let cloneICloneable (o:obj) : obj =
|
|
222
|
+
nativeOnly
|
|
223
|
+
|
|
224
|
+
module Dictionaries =
|
|
225
|
+
[<Emit("""isinstance($0, dict)""")>]
|
|
226
|
+
let isDict (o:obj) : bool =
|
|
227
|
+
nativeOnly
|
|
214
228
|
|
|
215
229
|
#endif
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
module DynamicObj.HashCodes
|
|
2
2
|
|
|
3
|
+
// Taken from
|
|
4
|
+
//https://softwareengineering.stackexchange.com/a/402543
|
|
5
|
+
// Which points to a no-longer existing source in FSharp Core Compiler
|
|
6
|
+
// But can be found in
|
|
7
|
+
// https://github.com/dotnet/fsharp/blob/2edab1216843f20a00a7d8f171aca52cbc35d7fd/src/Compiler/Checking/AugmentWithHashCompare.fs#L171
|
|
8
|
+
// Or Fables mirror
|
|
9
|
+
// https://github.com/fable-compiler/Fable/blob/b0e640763fd90bd084f72531cb119d49a91ec077/src/fcs-fable/src/Compiler/Checking/AugmentWithHashCompare.fs#L171
|
|
3
10
|
let mergeHashes (hash1 : int) (hash2 : int) : int =
|
|
4
11
|
0x9e3779b9 + hash2 + (hash1 <<< 6) + (hash1 >>> 2)
|
|
5
12
|
|
|
@@ -46,4 +53,12 @@ let boxHashKeyValSeq (a: seq<System.Collections.Generic.KeyValuePair<'a,'b>>) :
|
|
|
46
53
|
|> Seq.fold (fun acc o ->
|
|
47
54
|
mergeHashes (hash o.Key) (hash o.Value)
|
|
48
55
|
|> mergeHashes acc) 0
|
|
56
|
+
|> box
|
|
57
|
+
|
|
58
|
+
let boxHashKeyValSeqBy (f : 'b -> int) (a: seq<System.Collections.Generic.KeyValuePair<'a,'b>>) : obj =
|
|
59
|
+
a
|
|
60
|
+
// from https://stackoverflow.com/a/53507559
|
|
61
|
+
|> Seq.fold (fun acc o ->
|
|
62
|
+
mergeHashes (hash o.Key) (f o.Value)
|
|
63
|
+
|> mergeHashes acc) 0
|
|
49
64
|
|> box
|
|
@@ -46,3 +46,7 @@ export function boxHashKeyValSeq(a) {
|
|
|
46
46
|
return fold_1((acc, o) => mergeHashes(acc, mergeHashes(hash(o[0]), hash(o[1]))), 0, a);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export function boxHashKeyValSeqBy(f, a) {
|
|
50
|
+
return fold_1((acc, o) => mergeHashes(acc, mergeHashes(hash(o[0]), f(o[1]))), 0, a);
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -11,7 +11,7 @@ open System.Reflection
|
|
|
11
11
|
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
|
|
12
12
|
[<assembly: System.Reflection.AssemblyDescriptionAttribute("F# library supporting Dynamic Objects including inheritance in functional style. Compatible with Fable javascript and python transpilation.")>]
|
|
13
13
|
[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
|
|
14
|
-
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0
|
|
14
|
+
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")>]
|
|
15
15
|
[<assembly: System.Reflection.AssemblyProductAttribute("DynamicObj")>]
|
|
16
16
|
[<assembly: System.Reflection.AssemblyTitleAttribute("DynamicObj")>]
|
|
17
17
|
[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
|
|
@@ -10,10 +10,10 @@ open System.Reflection
|
|
|
10
10
|
[<assembly: System.Reflection.AssemblyCompanyAttribute("Timo Mühlhaus, Kevin Schneider, Heinrich Lukas Weil, F# open source contributors")>]
|
|
11
11
|
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Release")>]
|
|
12
12
|
[<assembly: System.Reflection.AssemblyDescriptionAttribute("F# library supporting Dynamic Objects including inheritance in functional style. Compatible with Fable javascript and python transpilation.")>]
|
|
13
|
-
[<assembly: System.Reflection.AssemblyFileVersionAttribute("
|
|
14
|
-
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("
|
|
13
|
+
[<assembly: System.Reflection.AssemblyFileVersionAttribute("7.0.1.0")>]
|
|
14
|
+
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("7.0.1+98fb467c65858b8420433025a50459d8897f9028")>]
|
|
15
15
|
[<assembly: System.Reflection.AssemblyProductAttribute("DynamicObj")>]
|
|
16
16
|
[<assembly: System.Reflection.AssemblyTitleAttribute("DynamicObj")>]
|
|
17
|
-
[<assembly: System.Reflection.AssemblyVersionAttribute("
|
|
17
|
+
[<assembly: System.Reflection.AssemblyVersionAttribute("7.0.1.0")>]
|
|
18
18
|
[<assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/CSBiology/DynamicObj")>]
|
|
19
19
|
do()
|