tpmkms_4wp 8.9.0-beta.11 → 8.9.0-beta.12
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.
@@ -0,0 +1,75 @@
|
|
1
|
+
const { propertyToArray } = require('../helpers.js')
|
2
|
+
|
3
|
+
const asList = (context) => {
|
4
|
+
if (context.marker === 'list') {
|
5
|
+
return context
|
6
|
+
}
|
7
|
+
return {
|
8
|
+
marker: 'list',
|
9
|
+
types: [context.marker],
|
10
|
+
value: [context]
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
const listable = (hierarchy) => (c, type) => {
|
15
|
+
if (!c) {
|
16
|
+
return false
|
17
|
+
}
|
18
|
+
if (hierarchy.isA(c.marker, type)) {
|
19
|
+
return true
|
20
|
+
}
|
21
|
+
if (c.marker === 'list') {
|
22
|
+
for (const t of c.types) {
|
23
|
+
if (hierarchy.isA(t, type)) {
|
24
|
+
return true
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
return false
|
29
|
+
}
|
30
|
+
|
31
|
+
const isA = (hierarchy) => (child, parent, { strict=false } = {}) => {
|
32
|
+
if (!child || !parent) {
|
33
|
+
return false
|
34
|
+
}
|
35
|
+
|
36
|
+
if (strict) {
|
37
|
+
if (child.marker) {
|
38
|
+
child = child.marker
|
39
|
+
}
|
40
|
+
if (parent.marker) {
|
41
|
+
parent = parent.marker
|
42
|
+
}
|
43
|
+
return hierarchy.isA(child, parent)
|
44
|
+
} else {
|
45
|
+
const children = propertyToArray(child)
|
46
|
+
for (let child of children) {
|
47
|
+
let okay = false
|
48
|
+
if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
|
49
|
+
okay = true
|
50
|
+
} else {
|
51
|
+
for (const childT of child.types || [child]) {
|
52
|
+
if (okay) {
|
53
|
+
break
|
54
|
+
}
|
55
|
+
for (const parentT of parent.types || [parent]) {
|
56
|
+
if (hierarchy.isA(childT, parentT)) {
|
57
|
+
okay = true
|
58
|
+
break
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
if (!okay) {
|
64
|
+
return false
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return true
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
module.exports = {
|
72
|
+
asList,
|
73
|
+
isA,
|
74
|
+
listable,
|
75
|
+
}
|
package/package.json
CHANGED
@@ -196,6 +196,7 @@
|
|
196
196
|
"common/help.test.json",
|
197
197
|
"common/helpers.js",
|
198
198
|
"common/helpers/concept.js",
|
199
|
+
"common/helpers/conjunction.js",
|
199
200
|
"common/helpers/dialogues.js",
|
200
201
|
"common/helpers/formulas.js",
|
201
202
|
"common/helpers/frankenhash.js",
|
@@ -314,8 +315,8 @@
|
|
314
315
|
"table": "^6.7.1",
|
315
316
|
"base-64": "^1.0.0",
|
316
317
|
"argparse": "^2.0.1",
|
317
|
-
"theprogrammablemind_4wp": "8.9.0-beta.
|
318
|
+
"theprogrammablemind_4wp": "8.9.0-beta.12"
|
318
319
|
},
|
319
|
-
"version": "8.9.0-beta.
|
320
|
+
"version": "8.9.0-beta.12",
|
320
321
|
"license": "UNLICENSED"
|
321
322
|
}
|