@nxtedition/agent
Advanced tools
Comparing version 1.0.4 to 1.0.5
47
index.js
@@ -17,7 +17,9 @@ const objectHash = require('object-hash') | ||
return Observable.using( | ||
() => ({ | ||
unsubscribe: ds.record.provide(`${hash}:agent.query`, () => Observable.of(query)) | ||
}), | ||
() => ds.record.observe(`${hash}:agent${prop ? `.${prop}` : ``}`)) | ||
return Observable | ||
.using( | ||
() => ({ | ||
unsubscribe: ds.record.provide(`${hash}:agent.query`, () => Observable.of(query)) | ||
}), | ||
() => ds.record.observe(`${hash}:agent${prop ? `.${prop}` : ``}`) | ||
) | ||
}, | ||
@@ -31,38 +33,3 @@ spawn (query, prop) { | ||
return ds.record.observe(`${hash}:agent${prop ? `.${prop}` : ``}`) | ||
}, | ||
provide (matcher) { | ||
const ds = this | ||
return ds.record.provide(`^.+:agent(\\.methods|\\.stats|\\.result)?$`, key => { | ||
const [ , id, prop ] = key.match(/^(.+):agent(?:\.(stats|result|description))?/) | ||
return ds.record | ||
.observe(`${id}:agent.query`) | ||
.filter(x => Object.keys(x).length > 0) | ||
.switchMap(({ type, parent, description }) => { | ||
if (matcher && !matcher({ type, parent, description })) { | ||
return Observable.of(null) | ||
} | ||
if (!description.scene || Object.keys(description.scene).length === 0) { | ||
return Observable.of({ error: 'invalid_scene' }) | ||
} | ||
if (!prop) { | ||
return Observable.of({ type, parent }) | ||
} | ||
const name = `${objectHash(description)}:agent-${type}` | ||
return Observable | ||
.using( | ||
() => ({ | ||
unsubscribe: ds.record.provide(`${name}.query`, () => Observable.of({ parent, description })) | ||
}), | ||
() => ds.record.observe(name) | ||
) | ||
.pluck(prop) | ||
.map(x => x || {}) | ||
}) | ||
}) | ||
} | ||
} |
{ | ||
"name": "@nxtedition/agent", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "Robert Nagy <robert.nagy@boffins.se>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2637
28