Comparing version 4.3.1 to 4.4.0
13
index.js
@@ -212,8 +212,11 @@ const Strategy = require('@tangle/strategy') | ||
// map rootMsg => record (and filter out the ones which were junk) | ||
pull.asyncMap((msg, cb) => { | ||
this.read(msg.key, (err, record) => { | ||
if (err) cb(null, false) | ||
else cb(null, record) | ||
pull.asyncMap( | ||
opts.read || | ||
((msg, cb) => { | ||
this.read(msg.key, (err, record) => { | ||
if (err) cb(null, false) | ||
else cb(null, record) | ||
}) | ||
}) | ||
}), | ||
), | ||
pull.filter(Boolean), | ||
@@ -220,0 +223,0 @@ |
{ | ||
"name": "ssb-crut", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"description": "easy CRUT methods for secure scuttlebutt", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -317,2 +317,13 @@ # ssb-crut | ||
- only show tombstoned records | ||
- `opts.read` *Function* | ||
- provide a custom 'read' function which allows e.g. decorating, or installing a cache | ||
- default: | ||
```js | ||
(msg, cb) => { | ||
crut.read(msg.key, (err, record) => { | ||
if (err) cb(null, null) // prevents one failed read from causing whole like to fail | ||
else cb(null, record) | ||
}) | ||
} | ||
``` | ||
@@ -319,0 +330,0 @@ --- |
@@ -97,2 +97,22 @@ const test = require('tape') | ||
/* opts.read */ | ||
list = await crut.list({ | ||
read: (msg, cb) => { | ||
crut.read(msg.key, (err, record) => { | ||
if (err) return cb(null, null) | ||
record.fancyName = 'fancy-' + record.name | ||
delete record.states | ||
cb(null, record) | ||
}) | ||
} | ||
// we provide a custom read which adjusts | ||
// but could also check a cache etc | ||
}) | ||
t.deepEqual( | ||
list.map(record => record.fancyName), | ||
['fancy-0', 'fancy-3', 'fancy-2', 'fancy-1'], | ||
'opts.read' | ||
) | ||
// tombstone | ||
@@ -99,0 +119,0 @@ await crut.tombstone(recordId, {}) |
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
115360
3316
351