Files: 8397cee5bd7b17b9f2ebf584813ed0c0a035023d / modules / people-names.js
607 bytesRaw
1 | var Value = require('mutant/value') |
2 | var computed = require('mutant/computed') |
3 | |
4 | exports.needs = { |
5 | about: { |
6 | signifier: 'first' |
7 | } |
8 | } |
9 | |
10 | exports.gives = { |
11 | people_names: true |
12 | } |
13 | |
14 | exports.create = function (api) { |
15 | return { |
16 | people_names (ids) { |
17 | return computed(Array.from(ids).map(ObservName), join) || '' |
18 | } |
19 | } |
20 | |
21 | // scoped |
22 | |
23 | function ObservName (id) { |
24 | var obs = Value(id.slice(0, 10)) |
25 | api.about.signifier(id, (_, value) => { |
26 | if (value && value.length) { |
27 | obs.set(value[0].name) |
28 | } |
29 | }) |
30 | return obs |
31 | } |
32 | } |
33 | |
34 | function join (...args) { |
35 | return args.join('\n') |
36 | } |
37 |
Built with git-ssb-web