(options: MakeOptions)
| 222 | * @since 4.0.0 |
| 223 | */ |
| 224 | export const make = (options: MakeOptions): KeyValueStore => |
| 225 | KeyValueStore.of({ |
| 226 | [TypeId]: TypeId, |
| 227 | has: (key) => Effect.map(options.get(key), Predicate.isNotUndefined), |
| 228 | isEmpty: Effect.map(options.size, (size) => size === 0), |
| 229 | modify: (key, f) => |
| 230 | Effect.flatMap( |
| 231 | options.get(key), |
| 232 | (o) => { |
| 233 | if (o === undefined) { |
| 234 | return Effect.undefined |
| 235 | } |
| 236 | const newValue = f(o) |
| 237 | return Effect.as( |
| 238 | options.set(key, newValue), |
| 239 | newValue |
| 240 | ) |
| 241 | } |
| 242 | ), |
| 243 | modifyUint8Array: (key, f) => |
| 244 | Effect.flatMap( |
| 245 | options.getUint8Array(key), |
| 246 | (o) => { |
| 247 | if (o === undefined) { |
| 248 | return Effect.undefined |
| 249 | } |
| 250 | const newValue = f(o) |
| 251 | return Effect.as(options.set(key, newValue), newValue) |
| 252 | } |
| 253 | ), |
| 254 | ...options |
| 255 | }) |
| 256 | |
| 257 | /** |
| 258 | * Adapts a string-only backing store into a `KeyValueStore`. |
no test coverage detected