🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

read-webfile

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-webfile

let you readFile from web just like fs.readFile

latest
npmnpm
Version
0.2.1
Version published
Weekly downloads
4
-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

read-webfile

read a file from a url just like from a file path!

Installation

npm i read-webfile --save

wf.readFileFromWeb(path[, options], callback)

basicly, this function is design to follow native API of fs.readFile.

  • path <string> | <URL> required

    • can be a string such as https://nodejs.org
    • can be a URL object such as new URL('https://nodejs.org')
    • is required, and only support http or https portocol
  • options <Object> | <string>

    • can be a string which represent encoding such as 'utf8'
    • can be object such as {encoding: 'utf8'}
  • callback <Function>

    • err <Error>
    • data <string> | <Buffer>
const wf = require('read-webfile')
let url = 'https://nodejs.org/en/'

wf.readFileFromWeb(url, 'utf8', (err, data) => {
  if(err) console.error(err)
  console.log(data)
})

wf.createReadStream(path[, options])

basicly, this function is design to follow native API of fs.createReadStream.

  • path <string> | <URL>
  • options <string> | <Object>
    • encoding <string> Default: null
  • Returns: a Readable Stream.
const wf = require('read-webfile')
let url = 'https://nodejs.org/en/'

const rs = wf.createReadStreamFromWeb(url)
rs.on('data', chunk => {
  console.log(chunk.toString('utf8'))
})
rs1.on('end', () => {
  console.log('onend')
})

notice

this function can not handler redirect such a http 304 code.

Keywords

readFile

FAQs

Package last updated on 02 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts