| 140 | } |
| 141 | |
| 142 | export async function touchMany(items: Touch[]): Promise<Array<{ state: State; entry: Entry }>> { |
| 143 | if (!items.length) return [] |
| 144 | const file = storePath() |
| 145 | const rows = await Promise.all(items.map((item) => row(item))) |
| 146 | |
| 147 | return Flock.withLock(lock(file), async () => { |
| 148 | const store = await read(file) |
| 149 | const now = Date.now() |
| 150 | const out: Array<{ state: State; entry: Entry }> = [] |
| 151 | for (const item of rows) { |
| 152 | const hit = next(store[item.id], item.core, now) |
| 153 | store[item.id] = hit.entry |
| 154 | out.push(hit) |
| 155 | } |
| 156 | await Filesystem.writeJson(file, store) |
| 157 | return out |
| 158 | }) |
| 159 | } |
| 160 | |
| 161 | export async function touch(spec: string, target: string, id: string): Promise<{ state: State; entry: Entry }> { |
| 162 | return touchMany([{ spec, target, id }]).then((item) => { |