@evanp/activitypub-bot 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,15 @@ import assert from 'node:assert'
7
7
  const collections = ['outbox', 'liked', 'followers', 'following']
8
8
  const router = express.Router()
9
9
 
10
+ function toArray (value) {
11
+ return (Array.isArray(value))
12
+ ? value
13
+ : [value]
14
+ }
15
+
10
16
  async function filterAsync (array, asyncPredicate) {
17
+ assert.ok(array)
18
+ assert.ok(Array.isArray(array))
11
19
  // 1. Kick off all predicate calls in parallel:
12
20
  const checks = array.map(item => asyncPredicate(item))
13
21
 
@@ -76,7 +84,7 @@ function collectionPageHandler (collection) {
76
84
  exported = await page.export({ useOriginalContext: true })
77
85
 
78
86
  if (['outbox', 'liked'].includes(collection)) {
79
- exported.items = await filterAsync(exported.items, async (id) => {
87
+ exported.items = await filterAsync(toArray(exported.items), async (id) => {
80
88
  const object = (formatter.isLocal(id))
81
89
  ? await objectStorage.read(id)
82
90
  : await client.get(id)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",