theprogrammablemind_4wp 7.5.8-beta.7 → 7.5.8-beta.71
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +299 -243
- package/index.js +1 -0
- package/lines.js +2 -2
- package/package.json +2 -1
- package/runtime.js +3 -1
- package/src/config.js +543 -251
- package/src/flatten.js +9 -1
- package/src/helpers.js +3 -1
- package/src/project.js +42 -0
- package/src/semantics.js +6 -1
package/src/flatten.js
CHANGED
@@ -89,7 +89,15 @@ const flatten = (markers, value) => {
|
|
89
89
|
const split = markers.includes(marker)
|
90
90
|
if (split) {
|
91
91
|
if ('value' in properties) {
|
92
|
-
|
92
|
+
flattenedValues = []
|
93
|
+
for (let v of properties.value) {
|
94
|
+
if (v.flatten) {
|
95
|
+
flattenedValues = flattenedValues.concat(flatten(markers, v)[0])
|
96
|
+
} else {
|
97
|
+
flattenedValues.push(v)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return [flattenedValues, true]
|
93
101
|
} else {
|
94
102
|
return [[value], false]
|
95
103
|
}
|
package/src/helpers.js
CHANGED
@@ -53,6 +53,8 @@ const safeEquals = (v1, v2) => {
|
|
53
53
|
return v1 == v2
|
54
54
|
} else if (type == 'function') {
|
55
55
|
return v1.toString() == v2.toString()
|
56
|
+
} else if (v1 == undefined || v2 == undefined) {
|
57
|
+
return v1 == v2
|
56
58
|
} else {
|
57
59
|
if (v1.length != v2.length) {
|
58
60
|
return false
|
@@ -320,7 +322,7 @@ const ecatch = (where, call) => {
|
|
320
322
|
try {
|
321
323
|
return call()
|
322
324
|
} catch( e ) {
|
323
|
-
throw new Error(`${where} ${e}`)
|
325
|
+
throw new Error(`${where} ${e.stack}`)
|
324
326
|
}
|
325
327
|
}
|
326
328
|
|
package/src/project.js
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
const project = (object, filter) => {
|
3
|
+
if (!object) {
|
4
|
+
return
|
5
|
+
}
|
6
|
+
|
7
|
+
let projection = {}
|
8
|
+
if (Array.isArray(filter)) {
|
9
|
+
if (Array.isArray(object)) {
|
10
|
+
return object.map( element => project(element, filter) )
|
11
|
+
} else {
|
12
|
+
for (let properties of filter) {
|
13
|
+
if (typeof properties == 'object') {
|
14
|
+
debugger
|
15
|
+
const subfilterProperty = Object.keys(properties)[0]
|
16
|
+
oldValue = object[subfilterProperty]
|
17
|
+
if (Array.isArray(oldValue)) {
|
18
|
+
projection[subfilterProperty] = oldValue.map((v) => project(v, properties[subfilterProperty]))
|
19
|
+
} else {
|
20
|
+
projection[subfilterProperty] = project(oldValue, properties[subfilterProperty])
|
21
|
+
}
|
22
|
+
} else {
|
23
|
+
if (!Array.isArray(properties)) {
|
24
|
+
properties = [properties]
|
25
|
+
}
|
26
|
+
for (const property of properties) {
|
27
|
+
projection[property] = object[property]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
} else if (typeof filter == 'object') {
|
33
|
+
for (const property of Object.keys(filter)) {
|
34
|
+
projection[property] = project(object[property], filter[property])
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return projection
|
38
|
+
}
|
39
|
+
|
40
|
+
module.exports = { project }
|
41
|
+
|
42
|
+
|
package/src/semantics.js
CHANGED
@@ -6,7 +6,7 @@ class Semantic {
|
|
6
6
|
// constructor ({match, apply, uuid, index, km, notes}) {
|
7
7
|
constructor (semantic) {
|
8
8
|
semantic = normalizeSemantic(semantic)
|
9
|
-
const { match, apply, uuid, index, km, notes, priority, debug, where, applyWrapped, property } = semantic
|
9
|
+
const { match, apply, uuid, index, km, notes, priority, debug, where, applyWrapped, property, oneShot, id } = semantic
|
10
10
|
this.matcher = match
|
11
11
|
this._apply = apply
|
12
12
|
this._applyWrapped = applyWrapped
|
@@ -18,6 +18,8 @@ class Semantic {
|
|
18
18
|
this.notes = notes
|
19
19
|
this.callId = debug
|
20
20
|
this.where = where
|
21
|
+
this.oneShot = oneShot
|
22
|
+
this.id = id
|
21
23
|
}
|
22
24
|
|
23
25
|
toLabel () {
|
@@ -197,6 +199,9 @@ class Semantics {
|
|
197
199
|
const log = (message) => { this.logs.push(message) }
|
198
200
|
try {
|
199
201
|
contextPrime = semantic.apply(args, context, s, log, options)
|
202
|
+
if (!contextPrime.controlKeepMotivation && semantic.oneShot) {
|
203
|
+
args.config.removeSemantic(semantic)
|
204
|
+
}
|
200
205
|
} catch( e ) {
|
201
206
|
contextPrime = null
|
202
207
|
let errorMessage
|