Socket
Socket
Sign inDemoInstall

theprogrammablemind_4wp

Package Overview
Dependencies
Maintainers
1
Versions
459
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

theprogrammablemind_4wp - npm Package Compare versions

Comparing version 7.10.0 to 7.10.1-beta.0

48

demo.js

@@ -11,30 +11,30 @@ const { Config, knowledgeModule, where } = require('theprogrammablemind')

operators: [
'((i) [went] ([to] (<the> store)))',
'((i) [went] ([to] (<the> store)))'
],
bridges: [
{
id: "the",
level: 0,
bridge: "{ ...after, determiner: 'the' }"
{
id: 'the',
level: 0,
bridge: "{ ...after, determiner: 'the' }"
},
{
id: "to",
level: 0,
bridge: "{ ...next(operator), after: after[0] }"
{
id: 'to',
level: 0,
bridge: '{ ...next(operator), after: after[0] }'
},
{
id: "went",
level: 0,
generatorp: ({context, gp}) => `${gp(context.actor)} went to ${gp(context.place)}`,
bridge: "{ action: 'go', marker: 'went', actor: before[0], place: after[0].after }"
},
{
id: 'went',
level: 0,
generatorp: ({ context, gp }) => `${gp(context.actor)} went to ${gp(context.place)}`,
bridge: "{ action: 'go', marker: 'went', actor: before[0], place: after[0].after }"
}
],
generators: [
{
match: ({context}) => context.isResponse,
apply: ({context}) => context.evalue
match: ({ context }) => context.isResponse,
apply: ({ context }) => context.evalue
},
{
match: ({context}) => context.marker == 'unknown',
apply: ({context}) => context.text
match: ({ context }) => context.marker == 'unknown',
apply: ({ context }) => context.text
}

@@ -44,4 +44,4 @@ ],

{
match: ({context}) => context.marker == 'went',
apply: ({context}) => {
match: ({ context }) => context.marker == 'went',
apply: ({ context }) => {
// same way as kms that I wrote. you dont have to do this though

@@ -53,6 +53,6 @@ context.isResponse = true

]
};
}
config = new Config(config, module)
knowledgeModule({
knowledgeModule({
module,

@@ -64,3 +64,3 @@ config,

contents: require('./demo.test.json')
},
}
})

@@ -16,5 +16,5 @@ class Lines {

if (column >= this.widths.length) {
throw new Error("Column out of range.")
throw new Error('Column out of range.')
}
const width = fullWidth ? value.length: this.widths[column]
const width = fullWidth ? value.length : this.widths[column]
let index = 0

@@ -21,0 +21,0 @@ for (value of values) {

@@ -68,4 +68,4 @@ {

},
"version": "7.10.0",
"version": "7.10.1-beta.0",
"license": "ISC"
}
module.exports = {
process: {
env: "Should not be called in the browser",
exit: "Should not be called in the browser",
stdin: "Should not be called in the browser",
stdout: "Should not be called in the browser",
env: 'Should not be called in the browser',
exit: 'Should not be called in the browser',
stdin: 'Should not be called in the browser',
stdout: 'Should not be called in the browser'
},
child_process: "Should not be called in the browser",
child_process: 'Should not be called in the browser',
fs: {
existsSync: () => false,
existsSync: () => false
},
ArgumentParser: "Should not be called in the browser",
readline: "Should not be called in the browser",
jsonDiff: "Should not be called in the browser",
sortJson: "Should not be called in the browser",
util: "Should not be called in the browser",
performance: "Should not be called in the browser",
ArgumentParser: 'Should not be called in the browser',
readline: 'Should not be called in the browser',
jsonDiff: 'Should not be called in the browser',
sortJson: 'Should not be called in the browser',
util: 'Should not be called in the browser',
performance: 'Should not be called in the browser'
}

@@ -16,4 +16,4 @@ const toA = (edge) => {

addEdges(edges) {
for (let edge of edges) {
addEdges (edges) {
for (const edge of edges) {
this.addEdge(edge)

@@ -23,3 +23,3 @@ }

addEdge(edge) {
addEdge (edge) {
edge = toA(edge)

@@ -29,11 +29,11 @@ this._edges.push(edge)

get edges() {
get edges () {
return this._edges
}
set edges(edges) {
set edges (edges) {
this._edges = edges
}
/*
/*
set edges(edges) {

@@ -40,0 +40,0 @@ this._edges = edges.map( toA )

@@ -17,3 +17,3 @@ const toA = (edge) => {

// BFS
path(from, to) {
path (from, to) {
debugger

@@ -33,3 +33,3 @@ const frontier = { [from]: [[]] }

done.add(n)
for (let edge of this._edges) {
for (const edge of this._edges) {
if (edge.child == n) {

@@ -39,3 +39,3 @@ if (!frontier[edge.parent]) {

}
for (let path of ps) {
for (const path of ps) {
if (edge.parent == to) {

@@ -51,4 +51,4 @@ return [...path, edge]

addEdges(edges) {
for (let edge of edges) {
addEdges (edges) {
for (const edge of edges) {
this.addEdge(edge)

@@ -58,3 +58,3 @@ }

addEdge(edge) {
addEdge (edge) {
edge = toA(edge)

@@ -64,11 +64,11 @@ this._edges.push(edge)

get edges() {
get edges () {
return this._edges
}
set edges(edges) {
set edges (edges) {
this._edges = edges
}
/*
/*
set edges(edges) {

@@ -75,0 +75,0 @@ this._edges = edges.map( toA )

@@ -96,3 +96,3 @@ const { isArray, isObject, isCompound } = require('./helpers')

flattenedValues = []
for (let v of properties.value) {
for (const v of properties.value) {
if (v.flatten) {

@@ -99,0 +99,0 @@ flattenedValues = flattenedValues.concat(flatten(markers, v)[0])

@@ -53,20 +53,19 @@ const { args: contextArgs, normalizeGenerator } = require('./helpers')

const callId = baseArgs.calls.current()
const moreArgs = {
uuid: this.uuid,
args: contextArgs(context, hierarchy),
objects,
global: objects,
// hierarchy,
context,
callId,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const moreArgs = {
uuid: this.uuid,
args: contextArgs(context, hierarchy),
objects,
global: objects,
// hierarchy,
context,
callId,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
// return this.match(args)
const matches = this.match(args)
if ((matches && (options.debug || {}).match)
||
if ((matches && (options.debug || {}).match) ||
callId == this.callId) {
debugger; // next line is the matcher
debugger // next line is the matcher
this.match(args)

@@ -87,3 +86,3 @@ }

if (config && config.debugLoops) {
console.log("apply", this.toLabel())
console.log('apply', this.toLabel())
}

@@ -100,22 +99,22 @@ // this.getAPI(config)

const callId = baseArgs.calls.current()
const moreArgs = {
callId,
uuid: this.uuid,
// km,
args: contextArgs(context, hierarchy),
objects,
log,
global:
objects,
// g,
n,
hierarchy,
context,
uuid: this.uuid,
// gs,
config,
response,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const moreArgs = {
callId,
uuid: this.uuid,
// km,
args: contextArgs(context, hierarchy),
objects,
log,
global:
objects,
// g,
n,
hierarchy,
context,
uuid: this.uuid,
// gs,
config,
response,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))

@@ -132,4 +131,3 @@ if (this.property == 'generatorp') {

*/
if ((options.debug || {}).apply
||
if ((options.debug || {}).apply ||
callId == this.callId) {

@@ -176,3 +174,3 @@ debugger

if (Array.isArray(context)) {
throw new Error("Expected a context not an array")
throw new Error('Expected a context not an array')
}

@@ -187,5 +185,5 @@ if (typeof context !== 'object') {

const response = args.response
// args = { ...args, ...args.getAssumedScoped(assumed) }
args.addAssumedScoped(args, assumed)
args.addAssumedScoped(args, assumed)
context = Object.assign({}, context, args.assumed)

@@ -202,4 +200,4 @@ let generated = ''

try {
generated= generator.apply(args, objects, context, hierarchy, config, response, log)
} catch( e ) {
generated = generator.apply(args, objects, context, hierarchy, config, response, log)
} catch (e) {
// the next if handle this

@@ -293,3 +291,3 @@ generated = null

}
return ((config || {}).parenthesized ? "(" + generated + ")" : generated)
return ((config || {}).parenthesized ? '(' + generated + ')' : generated)
}

@@ -296,0 +294,0 @@ }

@@ -72,3 +72,3 @@ const deepEqual = require('deep-equal')

}
for (let key in v1) {
for (const key in v1) {
if (!safeEquals(v1[key], v2[key])) {

@@ -187,4 +187,3 @@ return false

class InitCalls {
constructor(name) {
constructor (name) {
this.nextCallId = 0

@@ -196,7 +195,7 @@ this.nextContextId = 0

start() {
start () {
return this.nextCallId
}
next() {
next () {
// this.nextContextId += 1

@@ -206,3 +205,3 @@ this.nextContextId += 1

push() {
push () {
this.nextCallId += 1

@@ -213,3 +212,3 @@ // this.nextCallId += 1

// TODO put the nextContextId in the context for debugging
const calls = this.stack.map( (call) => `${this.name}#call${call}` )
const calls = this.stack.map((call) => `${this.name}#call${call}`)
// return `Context#${this.nextContextId}: ${calls}`

@@ -219,16 +218,16 @@ return `Context#${this.nextContextId}: ${calls}`

current() {
return `${this.name}#call${this.stack[this.stack.length-1]}`
current () {
return `${this.name}#call${this.stack[this.stack.length - 1]}`
}
touch(context) {
touch (context) {
if (!context.touchedBy) {
context.touchedBy = []
}
if (!context.touchedBy.includes( this.current() )) {
context.touchedBy.push( this.current() )
if (!context.touchedBy.includes(this.current())) {
context.touchedBy.push(this.current())
}
}
pop() {
pop () {
this.stack.pop()

@@ -239,11 +238,11 @@ }

const hashCode = (str) => {
var hash = 0, i, ch;
if (str.length === 0) return hash;
let hash = 0; let i; let ch
if (str.length === 0) return hash
for (i = 0; i < str.length; i++) {
ch = str.charCodeAt(i);
hash = ((hash << 5) - hash) + ch;
hash |= 0; // Convert to 32bit integer
ch = str.charCodeAt(i)
hash = ((hash << 5) - hash) + ch
hash |= 0 // Convert to 32bit integer
}
return hash;
};
return hash
}

@@ -255,6 +254,6 @@ const sortJson = (json) => {

const validProps = (valids, object, type) => {
for (let prop of Object.keys(object)) {
for (const prop of Object.keys(object)) {
let okay = false
for (valid of valids) {
if (typeof valid == 'string') {
if (typeof valid === 'string') {
okay = prop == valid

@@ -276,3 +275,3 @@ } else {

for (let i = 0; i < list.length; ++i) {
list[i] =fn(list[i])
list[i] = fn(list[i])
}

@@ -282,5 +281,5 @@ }

const updateQueries = (queryOrConfig) => {
if (typeof queryOrConfig == 'string' || queryOrConfig.query) {
if (typeof queryOrConfig === 'string' || queryOrConfig.query) {
return queryOrConfig
} else if (typeof queryOrConfig == 'function') {
} else if (typeof queryOrConfig === 'function') {
return { apply: queryOrConfig.toString() }

@@ -294,19 +293,19 @@ } else {

const functionsToStrings = (config) => {
config = {...config}
config = { ...config }
const mapGenerator = (generator) => {
if (generator.apply) {
return { ...generator, match: generator.match.toString(), apply: generator.apply.toString() }
} else {
return [ generator[0].toString(), generator[1].toString() ]
}
if (generator.apply) {
return { ...generator, match: generator.match.toString(), apply: generator.apply.toString() }
} else {
return [generator[0].toString(), generator[1].toString()]
}
}
if (config.generators) {
config.generators = config.generators.map( mapGenerator )
config.generators = config.generators.map(mapGenerator)
}
if (config.semantics) {
config.semantics = config.semantics.map( (semantic) => {
config.semantics = config.semantics.map((semantic) => {
if (semantic.apply) {
return { ...semantic, match: semantic.match.toString(), apply: semantic.apply.toString() }
} else {
return [ semantic[0].toString(), semantic[1].toString() ]
return [semantic[0].toString(), semantic[1].toString()]
}

@@ -316,4 +315,4 @@ })

if (config.bridges) {
config.bridges = config.bridges.map( (bridge) => {
bridge = {...bridge}
config.bridges = config.bridges.map((bridge) => {
bridge = { ...bridge }
if (bridge.generator) {

@@ -323,3 +322,3 @@ bridge.generator = bridge.generator.toString()

if (bridge.generators) {
bridge.generators = bridge.generators.map( mapGenerator )
bridge.generators = bridge.generators.map(mapGenerator)
}

@@ -347,3 +346,3 @@ if (bridge.generatorp) {

return call()
} catch( e ) {
} catch (e) {
throw new Error(`${where} ${e.stack}`)

@@ -363,5 +362,5 @@ }

const subOther = sub[1]
const hasChoosen = sup.choose.find( (index) => equalKey(sup.context[index], subChoosen)) != undefined
const hasOtherChosen = sup.choose.find( (index) => equalKey(sup.context[index], subOther)) != undefined
const hasOther = sup.context.find( (other) => equalKey(other, subOther) ) !== undefined
const hasChoosen = sup.choose.find((index) => equalKey(sup.context[index], subChoosen)) != undefined
const hasOtherChosen = sup.choose.find((index) => equalKey(sup.context[index], subOther)) != undefined
const hasOther = sup.context.find((other) => equalKey(other, subOther)) !== undefined
return !!(hasChoosen && hasOther) && !hasOtherChosen

@@ -385,3 +384,3 @@ }

// same length so only need one way
const missing1 = chosen1.find( (id1) => !chosen2.find( (id2) => sameId(id1, id2)) )
const missing1 = chosen1.find((id1) => !chosen2.find((id2) => sameId(id1, id2)))
if (missing1) {

@@ -394,3 +393,3 @@ return false

module.exports = {
module.exports = {
ecatch,

@@ -400,19 +399,19 @@ functionsToStrings,

mapInPlace,
validProps,
args,
validProps,
args,
safeNoDups,
safeEquals,
appendNoDups,
hashIndexesGet,
hashIndexesSet,
translationMapping,
normalizeGenerator,
normalizeSemantic,
isArray,
isObject,
isCompound,
InitCalls,
hashCode,
safeEquals,
appendNoDups,
hashIndexesGet,
hashIndexesSet,
translationMapping,
normalizeGenerator,
normalizeSemantic,
isArray,
isObject,
isCompound,
InitCalls,
hashCode,
sortJson,
subPriority,
subPriority
}

@@ -7,3 +7,3 @@

let projection = {}
const projection = {}
const set = (property, value) => {

@@ -17,9 +17,9 @@ if (value === null || value === undefined) {

if (Array.isArray(object)) {
return object.map( element => project(element, filter) )
return object.map(element => project(element, filter))
} else {
for (let properties of filter) {
if (typeof properties == 'function') {
if (typeof properties === 'function') {
properties = properties(object)
}
if (typeof properties == 'object') {
if (typeof properties === 'object') {
if (properties.propertyLists) {

@@ -33,3 +33,3 @@ for (const propertyList in properties.propertyLists) {

}
}
}
if (properties.valueLists) {

@@ -76,3 +76,3 @@ for (const listProperty in properties.valueLists) {

}
} else if (typeof filter == 'object') {
} else if (typeof filter === 'object') {
for (const property of Object.keys(filter)) {

@@ -86,3 +86,1 @@ set(property, project(object[property], filter[property]))

module.exports = { project }

@@ -28,3 +28,3 @@ const { args: contextArgs, normalizeGenerator, normalizeSemantic } = require('./helpers')

if (!this.km) {
return where;
return where
}

@@ -59,20 +59,19 @@ return `KM '${this.km}' ordinal: ${this.index} ${where}`

const callId = baseArgs.calls.current()
const moreArgs = {
uuid: this.uuid,
args: contextArgs(context, hierarchy),
objects,
global: objects,
context: context,
// hierarchy: hierarchy,
callId,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const moreArgs = {
uuid: this.uuid,
args: contextArgs(context, hierarchy),
objects,
global: objects,
context: context,
// hierarchy: hierarchy,
callId,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
const matches = this.matcher(args)
if (matches && (options.debug || {}).match
||
if (matches && (options.debug || {}).match ||
callId == this.callId) {
debugger; // next line is the matcher
debugger // next line is the matcher
this.matcher(args)

@@ -87,3 +86,3 @@ }

if (config && config.debugLoops) {
console.log("apply", this.toLabel())
console.log('apply', this.toLabel())
}

@@ -105,22 +104,21 @@ if (baseArgs.calls && config && baseArgs.calls.stack.length > config.maxDepth) {

const callId = baseArgs.calls.current()
const moreArgs = {
uuid: this.uuid,
callId,
args: contextArgs(context, hierarchy),
objects,
log,
global: objects,
n,
context: contextPrime,
uuid: this.uuid,
// config,
response,
api: this.getAPI(config),
apis: this.getAPIs(config)
const moreArgs = {
uuid: this.uuid,
callId,
args: contextArgs(context, hierarchy),
objects,
log,
global: objects,
n,
context: contextPrime,
uuid: this.uuid,
// config,
response,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
if ((options.debug || {}).apply
||
if ((options.debug || {}).apply ||
callId == this.callId) {
debugger;
debugger
}

@@ -168,6 +166,6 @@ if (args.breakOnSemantics) {

getMostCalled() {
getMostCalled () {
let maxOrdinal = 0
let maxCounter = 0
for (let ordinal in this.calls) {
for (const ordinal in this.calls) {
const counter = this.calls[ordinal]

@@ -193,13 +191,13 @@ if (counter > maxCounter) {

const stack = args.calls.push()
let counter = 0;
let counter = 0
for (const isemantic in this.semantics) {
const semantic = this.semantics[isemantic]
if (!semantic) {
debugger;
debugger
}
if (semantic.matches(args, context, options)) {
if (!this.calls[counter]) {
this.calls[counter] = 0;
this.calls[counter] = 0
}
this.calls[counter] += 1;
this.calls[counter] += 1
const log = (message) => { this.logs.push(message) }

@@ -211,3 +209,3 @@ try {

}
} catch( e ) {
} catch (e) {
contextPrime = null

@@ -224,4 +222,4 @@ let errorMessage

} else {
errorMessage = e.toString();
}
errorMessage = e.toString()
}

@@ -228,0 +226,0 @@ const widths = [10, 10, 90]

@@ -39,3 +39,3 @@ const _ = require('lodash')

for (const property of properties) {
if (new Set(contexts.map( (context) => context[property] )).size == 1) {
if (new Set(contexts.map((context) => context[property])).size == 1) {
return property

@@ -81,6 +81,6 @@ }

const canonicalDefault = (value) => {
if (!value || !value.marker) {
return value;
}
return { marker: value.marker, value: value.value, word: value.wordi, types: value.types }
if (!value || !value.marker) {
return value
}
return { marker: value.marker, value: value.value, word: value.wordi, types: value.types }
}

@@ -91,3 +91,3 @@

const grouped = {}
for (let context of contexts) {
for (const context of contexts) {
if (!grouped[context.marker]) {

@@ -99,3 +99,3 @@ grouped[context.marker] = []

let results = []
for (let key in grouped) {
for (const key in grouped) {
results = results.concat(unflattenHelper(grouped[key], properties || grouped[key][0].unflatten, canonical))

@@ -102,0 +102,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc