Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@cypsela/browser-source

cypsela112MIT3.0.0TypeScript support: included

W3C's FileList and WICG’s FileSystemEntry and FileSystemHandle as a sources for @helia/unixfs

ipfs, helia, unixfs, browser, webkit, opfs, FileList, FileSystemEntry, FileSystemHandle

readme

browser-source

W3C's FileList and WICG’s FileSystemEntry and FileSystemHandle as a sources for @helia/unixfs

Install

npm i @cypsela/browser-source

Example

live: https://browser-source.cypsela.eth.limo

source: ./example

Usage

Api docs: cypsela.github.io/browser-source

FileList Source

import { fileListSource, BrowserFsItemSourceOptions } from '@cypsela/browser-source'
import { createHelia } from 'helia'
import { unixfs } from '@helia/unixfs'

const helia = await createHelia()
const fs = unixfs(helia)

const list: FileList = /* Get from <input type="file" /> tag or drag-and-drop events */;

for await (const { cid } of fs.addAll(fileListSource(list))) {}

FileSystemEntry Source

import { fsEntrySource, BrowserFsItemSourceOptions } from '@cypsela/browser-source'
import { createHelia } from 'helia'
import { unixfs } from '@helia/unixfs'

const helia = await createHelia()
const fs = unixfs(helia)

const entry: FileSystemEntry = /* Get from drag-and-drop events */;

for await (const _ of fs.addAll(fsEntrySource(entry))) {}

FileSystemHandle Source

import { fsHandleSource, BrowserFsItemSourceOptions } from '@cypsela/browser-source'
import { createHelia } from 'helia'
import { unixfs } from '@helia/unixfs'

const helia = await createHelia()
const fs = unixfs(helia)

const handle: FileSystemHandle = /* Get from drag-and-drop events */;

for await (const _ of fs.addAll(fsHandleSource(handle))) {}