Skip to content

mostjs-community/most-file-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

most-file-reader

FileReader for most

Install

npm install most-file-reader

API

readAsDataURL :: Stream File → Stream Event

import {readAsDataURL} from 'most-file-reader'
import {change} from '@most/dom-event'
import {from} from 'most'

const filesStream = change(document.body)
    .chain(event => from(event.target.files).filter(file => file.type.match('image')))

readAsDataURL(filesStream)
    .observe(console.info.bind(console))

or fluently with thru

import {readAsDataURL} from 'most-file-reader'
import {change} from '@most/dom-event'
import {from} from 'most'

change(document.body)
    .chain(event => from(event.target.files).filter(file => file.type.match('image')))
    .thru(readAsDataURL)
    .observe(console.info.bind(console))

readAsDataURL will output a ProgressEvent which contains a base64 encoded url.

readAsArrayBuffer :: Stream File → Stream Event

readAsArrayBuffer will output a ProgressEvent which contains a ArrayBuffer of file data.

readAsText :: Stream File → Stream Event

readAsText will output a ProgressEvent which contains a text string of the file contents.

fileReader :: String → Stream File → Stream Event

fileReader is the underlying method for the above functions.

import {fileReader} from 'most-file-reader'
import {change} from '@most/dom-event'
import {from} from 'most'

const fileStream = change(document.body)
    .chain(event => from(event.target.files))

fileReader('readAsDataURL', fileStream)
    .observe(console.info.bind(console))

Todo

  • Add tests
  • Publish to npm

Made with

@most/package-starter

About

FileReader combinator for most

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy