-
Notifications
You must be signed in to change notification settings - Fork 4
/
Inspect.MetaOfType.pq
40 lines (38 loc) · 1.45 KB
/
Inspect.MetaOfType.pq
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
let
// Inspect type
FuncDef = (x as any) as record =>
let
t = Value.Type(x),
md = Value.Metadata(x),
mdt = Value.Metadata( Value.Type(x) ),
mdt_invert = Value.Type( Value.Metadata ),
mergedMeta = Record.Combine({
(md ?? []), (mdt ?? [])
})
in
[
TypeName = Type.ToText( t ),
Type = t,
Metadata = md,
TypeMetadata = mdt,
TypeMetadata_Invert = mdt_invert,
MergedMetadata = mergedMeta
],
// Inspect type
FuncType = type function (input as any) as record
meta [
Documentation.Name = "Metadata of Type",
Documentation.LongDescription = "Sugar for the Metadata of an object's type",
Documentation.Examples = {
[
Description = "Type of a function",
Code = "Record.FieldNames( Inspect.MetaOfType( BinaryEncoding.Base64 ) )",
Result = "{ ""Documentation.Name"", ""Documentation.Description"", ""Documentation.LongDescription"", ""Documentation.Category"", ""Documentation.Examples"" }"
]
}
],
// enableTesting = false,
// testResults = Record.FieldNames(Inspect.MetaOfType(BinaryEncoding.Base64)),
Inspect.MetaOfType = Value.ReplaceType(FuncDef, FuncType)
in
Inspect.MetaOfType