guess-api

0.3.1 • Public • Published

Guess-api

Guessing api content type. Support text/plain, text/csv, text/xml, application/json. Useful in super large data, cause we use STREAM!

Install

npm install guess-api

Example

var guess = require('./');
 
guess('http://localhost:3000/xml', {encoding: 'utf8'}, cb)
 
function cb(type) {
    console.log(type)
    // result:
    // text/xml
}

Support

Types

  • text/csv
  • text/xml
  • application/json

protocol

  • http
  • https

How it work?

Only read the first chunk (why reading only the first chunk? cause will reduce lot of time of guessing super large data), and guess the encoding by using the first chunk.

License

MIT

Package Sidebar

Install

npm i guess-api

Weekly Downloads

1

Version

0.3.1

License

MIT

Last publish

Collaborators

  • chilijung