browser-nativefs
Advanced tools
Comparing version 0.2.2 to 0.3.0
// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. | ||
export{fileOpen}from"./file-open.mjs";export{fileSave}from"./file-save.mjs";export{imageToBlob}from"./image-to-blob.mjs"; | ||
export{fileOpen}from"./file-open.mjs";export{directoryOpen}from"./directory-open.mjs";export{fileSave}from"./file-save.mjs";export{imageToBlob}from"./image-to-blob.mjs"; |
{ | ||
"name": "browser-nativefs", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Native File System API with legacy fallback in the browser.", | ||
@@ -5,0 +5,0 @@ "browser": "dist/index.js", |
@@ -20,2 +20,3 @@ # Browser-NativeFS | ||
fileOpen, | ||
directoryOpen, | ||
fileSave, | ||
@@ -36,2 +37,8 @@ } from 'https://unpkg.com/browser-nativefs'; | ||
// Open all files in a directory, | ||
// recursively including subdirectories. | ||
const blobsInDirectory = await directoryOpen({ | ||
recursive: true | ||
}); | ||
// Save a file. | ||
@@ -46,3 +53,3 @@ await fileSave(blob, { | ||
Opening files: | ||
### Opening files: | ||
@@ -65,7 +72,30 @@ ```js | ||
Saving files: | ||
### Opening directories: | ||
Note that there are some differences between the Native File System API | ||
and the fallback approach | ||
[`<input type="file" webkitdirectory multiple>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory). | ||
Namely, the Native File System API currently doesn't provide useful | ||
relative path info as | ||
[`webkitRelativePath`](https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath) | ||
did, so you need to keep track of paths yourself. | ||
```js | ||
// Options are optional. | ||
const options = { | ||
// Set to `true` for allowing multiple directories, defaults to `false`. | ||
multiple: true, | ||
// Set to `true` to recursively open files in all subdirectories, | ||
// defaults to `false`. | ||
recursive: true, | ||
}; | ||
const blobs = await directoryOpen(options); | ||
``` | ||
### Saving files: | ||
```js | ||
// Options are optional. | ||
const options = { | ||
// Suggested file name to use, defaults to `''`. | ||
@@ -72,0 +102,0 @@ fileName: 'Untitled.txt', |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
20058
14
11
128
0