Socket
Socket
Sign inDemoInstall

browser-nativefs

Package Overview
Dependencies
0
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.3.0

dist/directory-open-legacy.mjs

2

dist/index.js
// @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',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc