@nxtedition/agent
Advanced tools
Comparing version 1.0.12 to 1.1.0
39
index.js
const objectHash = require('object-hash') | ||
const { Observable } = require('rxjs') | ||
@@ -13,2 +12,3 @@ function hashObject (obj) { | ||
module.exports = { | ||
hash: hashObject, | ||
spawn (query, prop) { | ||
@@ -19,40 +19,3 @@ const ds = this | ||
return ds.record.observe(`${hash}:agent${prop ? `.${prop}` : ``}`) | ||
}, | ||
provide (type, fn) { | ||
const ds = this | ||
return ds.record.provide(`^.+:agent-${type}$`, key => ds.record | ||
.observe(`${key}.query`) | ||
.first(x => Object.keys(x).length > 0) | ||
.switchMap(query => fn(key, query)) | ||
) | ||
}, | ||
init () { | ||
const ds = this | ||
return ds.record.provide(`^(.+):agent(?:\\.(methods|stats|result|description))?$`, key => { | ||
const [ , id, prop ] = key.match(/^(.+):agent(?:\.(methods|stats|result|description))?$/) | ||
return ds.record | ||
.observe(`${id}:agent.query`) | ||
.first(x => Object.keys(x).length > 0) | ||
.switchMap(({ type, parent, description }) => { | ||
if (!prop) { | ||
return Observable.of({ type, parent }) | ||
} | ||
if (prop === 'description') { | ||
return Observable.of(description) | ||
} | ||
const name = `${hashObject(description)}:agent-${type}` | ||
ds.record.set(`${name}.query`, { parent, description }) | ||
return ds.record | ||
.observe(name) | ||
.pluck(prop) | ||
.map(x => x || {}) | ||
}) | ||
.catch(err => Observable.of({ error: err.message || err })) | ||
}) | ||
} | ||
} |
{ | ||
"name": "@nxtedition/agent", | ||
"version": "1.0.12", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
"author": "Robert Nagy <robert.nagy@boffins.se>", | ||
"dependencies": { | ||
"object-hash": "^1.1.8", | ||
"rxjs": "^5.4.2" | ||
"object-hash": "^1.1.8" | ||
} | ||
} |
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
1
2268
17
- Removedrxjs@^5.4.2
- Removedrxjs@5.5.12(transitive)
- Removedsymbol-observable@1.0.1(transitive)