https://github.com/scalajs-io/filed
Simplified file library.
https://github.com/scalajs-io/filed
node nodejs npm scala scalajs
Last synced: 4 months ago
JSON representation
Simplified file library.
- Host: GitHub
- URL: https://github.com/scalajs-io/filed
- Owner: scalajs-io
- License: apache-2.0
- Created: 2017-02-06T03:18:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-17T23:08:49.000Z (about 6 years ago)
- Last Synced: 2025-01-17T22:42:35.018Z (5 months ago)
- Topics: node, nodejs, npm, scala, scalajs
- Language: Scala
- Size: 15.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Filed API for Scala.js
================================
[filed](https://www.npmjs.com/package/filed) - Simplified file library.### Description
**Super simple to use**
Filed does a lazy stat call so you can actually open a file and begin writing to it and if the
file isn't there it will just be created.### Build Requirements
* [SBT v1.2.x](http://www.scala-sbt.org/download.html)
### Build/publish the SDK locally
```bash
$ sbt clean publish-local
```### Running the tests
Before running the tests the first time, you must ensure the npm packages are installed:
```bash
$ npm install
```Then you can run the tests:
```bash
$ sbt test
```### Examples
If you pipe it to a destination it'll be a read stream.
```scala
import io.scalajs.nodejs.fs.Fs
import io.scalajs.npm.filed._Filed("/myfile").pipe(Fs.createWriteStream("/out"))
```And of course you can pipe a filed object from itself to itself and it'll figure it out.
```scala
import io.scalajs.npm.filed._Filed("/myfile").pipe(Filed("/newfile"))
```Those familiar with request will be familiar seeing object capability detection when doing HTTP.
`Filed` does this as well.```scala
import io.scalajs.nodejs.http.Http
import io.scalajs.npm.filed._Http.createServer((req, resp) => Filed("/data.json").pipe(resp))
```### Artifacts and Resolvers
To add the `Filed` binding to your project, add the following to your build.sbt:
```sbt
libraryDependencies += "io.scalajs.npm" %%% "filed" % "0.5.0"
```Optionally, you may add the Sonatype Repository resolver:
```sbt
resolvers += Resolver.sonatypeRepo("releases")
```