1.0.3 • Published 2 years ago

io-promise v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

io-promise

I/O primitives using promises

  const io = require("io-promise");

Fetch support

 io.fetch("http://www.example.org").then(function (res) {
   return res.text();
  })
  io.fetch("http://www.example.com/object.json").then(function (res) {
   return res.json();
  })
  io.post("http://www.example.org", {foo: "bar"} ).then(function (res) {
   return res.text();
  })

File API support

  io.readJSON("myfile.json").then(function (data) {
   do something with data;
  })
  io.readJSON("myfile.json").then(function (data) {
   do something with data;
  })
  io.fetch("http://www.example.org", { delay: 2 } ).then(function (res) {
   return res.text();
  })

Response object

status HTTP status code url URL requested headers Object will all of the headers from the HTTP response text() Returns the data as a string json() Returns the data as an object

Monitoring

  io.monitor(); // active the monitoring
  io.returns an array contains all of the url requested

Caching

Caching of fetch requests

  var cache = new io.Cache("/tmp/");
  cache.load("http://www.example.org").then(function (res) {
    return res.text();
  })
1.0.3

2 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago