| 349 | const all = Effect.map(values, Array.fromIterable) |
| 350 | |
| 351 | const batchSet = (items: NonEmptyReadonlyArray<PM>) => |
| 352 | Effect |
| 353 | .forEach(items, (i) => Effect.flatMap(s.find(i[idKey]), (current) => updateETag(i, idKey, current))) |
| 354 | .pipe( |
| 355 | Effect |
| 356 | .tap((items) => |
| 357 | Ref |
| 358 | .get(store) |
| 359 | .pipe( |
| 360 | Effect |
| 361 | .map((m) => { |
| 362 | const mut = m as Map<Encoded[IdKey], PM> |
| 363 | items.forEach((e) => mut.set(e[idKey], e)) |
| 364 | return mut |
| 365 | }), |
| 366 | Effect |
| 367 | .flatMap((_) => Ref.set(store, _)) |
| 368 | ) |
| 369 | ), |
| 370 | Effect |
| 371 | .map((_) => _), |
| 372 | withPermit |
| 373 | ) |
| 374 | |
| 375 | const batchRemove = (items: NonEmptyReadonlyArray<Encoded[IdKey]>) => |
| 376 | Ref |