ekms 9.6.3-beta.2 → 9.6.3-beta.4

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/common/stm.js CHANGED
@@ -41,7 +41,7 @@ class API {
41
41
  return this._objects.mentioned.filter( (context) => this.isA(context.marker, type) )
42
42
  }
43
43
 
44
- mentioned(args) {
44
+ remember(args) {
45
45
  let concept, value, frameOfReference
46
46
  if (!args.context) {
47
47
  concept = args
@@ -76,7 +76,7 @@ class API {
76
76
  helpers.unshiftL(frameOfReference.mentioned, concept, this.maximumMentioned)
77
77
  }
78
78
 
79
- mentions({ context, frameOfReference, useHierarchy=true, all, lastN, condition = (() => true) } = {}) {
79
+ recall({ context, frameOfReference, useHierarchy=true, all, condition = (() => true), filter = ((result) => result) } = {}) {
80
80
  let mentioned = this._objects.mentioned
81
81
  let reversed = false
82
82
  if (frameOfReference) {
@@ -112,9 +112,6 @@ class API {
112
112
  // care about value first
113
113
  let findCounter = 0
114
114
  for (const m of mentioned) {
115
- if (lastN === 0) {
116
- break
117
- }
118
115
  if (context.value && (context.value == m.marker || context.value == m.value)) {
119
116
  findCounter += 1
120
117
  if (findPrevious && findCounter < 2) {
@@ -124,20 +121,17 @@ class API {
124
121
  continue
125
122
  }
126
123
  if (condition(m)) {
127
- if (all || lastN) {
124
+ if (all) {
128
125
  addForAll(m)
129
- if (lastN) {
130
- lastN -= 1
131
- }
132
126
  } else {
133
- return m
127
+ return filter(m)
134
128
  }
135
129
  }
136
130
  }
137
131
  }
138
132
 
139
- if (lastN === 0) {
140
- return forAll
133
+ if (forAll.length > 0) {
134
+ return filter(forAll)
141
135
  }
142
136
 
143
137
  if (!useHierarchy) {
@@ -147,9 +141,6 @@ class API {
147
141
  // care about marker second
148
142
  findCounter = 0
149
143
  for (const m of mentioned) {
150
- if (lastN === 0) {
151
- break
152
- }
153
144
  if (context.marker != 'unknown' && this.isA(m.marker, context.marker)) {
154
145
  findCounter += 1
155
146
  if (findPrevious && findCounter < 2) {
@@ -159,13 +150,10 @@ class API {
159
150
  continue
160
151
  }
161
152
  if (condition(m)) {
162
- if (all || lastN) {
153
+ if (all) {
163
154
  addForAll(m)
164
- if (lastN) {
165
- lastN -= 1
166
- }
167
155
  } else {
168
- return m
156
+ return filter(m)
169
157
  }
170
158
  }
171
159
  }
@@ -181,13 +169,10 @@ class API {
181
169
  continue
182
170
  }
183
171
  if (condition(m)) {
184
- if (all || lastN) {
185
- if (lastN) {
186
- lastN -= 1
187
- }
172
+ if (all) {
188
173
  addForAll(m)
189
174
  } else {
190
- return m
175
+ return filter(m)
191
176
  }
192
177
  }
193
178
  }
@@ -195,37 +180,31 @@ class API {
195
180
  }
196
181
  }
197
182
 
198
- if (lastN === 0) {
199
- return forAll
183
+ if (forAll.length > 0) {
184
+ return filter(forAll)
200
185
  }
201
186
 
202
187
  findCounter = 0
203
188
  if (context.types && context.types.length == 1) {
204
189
  for (const m of mentioned) {
205
- if (lastN === 0) {
206
- break
207
- }
208
190
  if (context.unknown) {
209
191
  findCounter += 1
210
192
  if (findPrevious && findCounter < 2) {
211
193
  continue
212
194
  }
213
195
  if (condition(m)) {
214
- if (all || lastN) {
196
+ if (all) {
215
197
  addForAll(m)
216
- if (lastN) {
217
- lastN -= 1
218
- }
219
198
  } else {
220
- return m
199
+ return filter(m)
221
200
  }
222
201
  }
223
202
  }
224
203
  }
225
204
  }
226
205
 
227
- if (all || lastN) {
228
- return forAll
206
+ if (forAll.length > 0) {
207
+ return filter(forAll)
229
208
  }
230
209
  }
231
210
 
@@ -233,7 +212,7 @@ class API {
233
212
  if (!context || context.marker == 'mentions') {
234
213
  return
235
214
  }
236
- let valueNew = this.mentions({ context, useHierarchy: false, condition: (context) => context.isVariable })
215
+ let valueNew = this.recall({ context, useHierarchy: false, condition: (context) => context.isVariable })
237
216
  if (valueNew && valueNew.value) {
238
217
  valueNew = valueNew.value
239
218
  }
@@ -241,7 +220,7 @@ class API {
241
220
  }
242
221
 
243
222
  setVariable(variableName, value) {
244
- this.mentioned({ context: { marker: variableName, isVariable: true }, value })
223
+ this.remember({ context: { marker: variableName, isVariable: true }, value })
245
224
  }
246
225
  }
247
226
 
@@ -276,7 +255,7 @@ const config = {
276
255
  if (value == context.rememberee.value) {
277
256
  value = context.rememberee
278
257
  }
279
- api.mentioned({ context: value })
258
+ api.remember({ context: value })
280
259
  },
281
260
  },
282
261
  {
@@ -300,7 +279,7 @@ const config = {
300
279
  where: where(),
301
280
  match: ({context}) => context.marker == 'mentions' && context.evaluate,
302
281
  apply: ({context, kms, toList, resolveEvaluate}) => {
303
- resolveEvaluate(context, kms.stm.api.mentions(context.args))
282
+ resolveEvaluate(context, kms.stm.api.recall(context.args))
304
283
  }
305
284
  },
306
285
  {
@@ -308,8 +287,8 @@ const config = {
308
287
  notes: 'pull from context',
309
288
  // match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
310
289
  match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
311
- apply: async ({callId, mentions, toList, context, kms, e, log, retry}) => {
312
- context.value = (await mentions({ context }))
290
+ apply: async ({callId, recall, toList, context, kms, e, log, retry}) => {
291
+ context.value = (await recall({ context }))
313
292
  if (Array.isArray(context.value)) {
314
293
  context.value = toList(context.value)
315
294
  }
@@ -334,8 +313,8 @@ const config = {
334
313
 
335
314
  function initializer({config}) {
336
315
  config.addArgs(({kms, e, toList}) => ({
337
- mentioned: (args) => {
338
- kms.stm.api.mentioned(args)
316
+ remember: (args) => {
317
+ kms.stm.api.remember(args)
339
318
  },
340
319
 
341
320
  frameOfReference: (context, { mentioned, reversed } = {}) => {
@@ -349,7 +328,7 @@ function initializer({config}) {
349
328
  }
350
329
  },
351
330
 
352
- mentions: async (args) => {
331
+ recall: async (args) => {
353
332
  if (args.frameOfReference?.nameable_named) {
354
333
  const result = await e(args.frameOfReference)
355
334
  if (result.evalue) {
package/package.json CHANGED
@@ -386,8 +386,8 @@
386
386
  "scriptjs": "^2.5.9",
387
387
  "table": "^6.7.1",
388
388
  "uuid": "^9.0.0",
389
- "theprogrammablemind": "9.6.3-beta.2"
389
+ "theprogrammablemind": "9.6.3-beta.4"
390
390
  },
391
- "version": "9.6.3-beta.2",
391
+ "version": "9.6.3-beta.4",
392
392
  "license": "UNLICENSED"
393
393
  }