Skip to content

About

In-memory FileSystem for @effect/platform, forked from nounder/effect-memfs.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

54 Commits

Folders and files

Repository files navigation

effect-memfs

An in-memory FileSystem for Effect. Seed it with paths and contents, and any code that asks Effect for the FileSystem service reads and writes that map instead of the disk.

Install

pnpm add @systemfsoftware/effect-memfs effect

effect is a peer dependency. Every release is published to npm from this repository's release workflow, with provenance.

Example

MemoryFileSystem.make takes the initial contents. Its layer provides Effect's FileSystem service:

import { MemoryFileSystem } from '@systemfsoftware/effect-memfs'
import { Effect } from 'effect'
import * as FileSystem from 'effect/FileSystem'

const program = Effect.gen(function*() {
  const fs = yield* FileSystem.FileSystem
  yield* fs.writeFile('/notes/list.txt', new TextEncoder().encode('milk, bread'))
  return new TextDecoder().decode(yield* fs.readFile('/notes/list.txt'))
}).pipe(Effect.provide(MemoryFileSystem.make({ '/notes/hello.txt': 'hello' }).layer))

console.log(await Effect.runPromise(program))
milk, bread

API

  • MemoryFileSystem.make(contents?) builds a blueprint with the root at /. contents maps paths to file contents; a path's parent directories are created from it.
  • .layer provides FileSystem.FileSystem and a Watcher service.
  • .effect provides the FileSystem service as an Effect.
  • .withContents(...) and .withCwd(...) return a revised blueprint.

The API report lists every export, and the module source shows the implementation.

Contributing

Development setup and checks are in CONTRIBUTING.md.

License

Apache-2.0: LICENSE.

About

In-memory FileSystem for @effect/platform, forked from nounder/effect-memfs.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages