mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
61 lines
2 KiB
JavaScript
61 lines
2 KiB
JavaScript
// Generated by CoffeeScript 1.8.0
|
|
(function() {
|
|
var Promise, fs, http, request, streamLength;
|
|
|
|
streamLength = require("./");
|
|
|
|
fs = require("fs");
|
|
|
|
request = require("request");
|
|
|
|
http = require("http");
|
|
|
|
Promise = require("bluebird");
|
|
|
|
Promise["try"](function() {
|
|
console.log("Length of fs:README.md...");
|
|
return streamLength(fs.createReadStream("README.md"));
|
|
}).then(function(length) {
|
|
return console.log("Length", length);
|
|
})["catch"](function(err) {
|
|
return console.log("No-Length", err);
|
|
}).then(function() {
|
|
console.log("Length of Buffer...");
|
|
return streamLength(new Buffer("testing buffer content length retrieval..."));
|
|
}).then(function(length) {
|
|
return console.log("Length", length);
|
|
})["catch"](function(err) {
|
|
return console.log("No-Length", err);
|
|
}).then(function() {
|
|
console.log("Length of http:Google");
|
|
return new Promise(function(resolve, reject) {
|
|
return http.get("http://www.google.com/images/srpr/logo11w.png", function(res) {
|
|
return resolve(res);
|
|
}).on("error", function(err) {
|
|
return reject(err);
|
|
});
|
|
});
|
|
}).then(function(res) {
|
|
res.resume();
|
|
return streamLength(res);
|
|
}).then(function(length) {
|
|
return console.log("Length", length);
|
|
})["catch"](function(err) {
|
|
return console.log("No-Length", err);
|
|
}).then(function() {
|
|
console.log("Length of request:Google...");
|
|
return streamLength(request("http://www.google.com/images/srpr/logo11w.png", function(err, res, body) {}));
|
|
}).then(function(length) {
|
|
return console.log("Length", length);
|
|
})["catch"](function(err) {
|
|
return console.log("No-Length", err);
|
|
}).then(function() {
|
|
console.log("Length of request:Google:fail...");
|
|
return streamLength(request("http://www.google.com/", function(err, res, body) {}));
|
|
}).then(function(length) {
|
|
return console.log("Length", length);
|
|
})["catch"](function(err) {
|
|
return console.log("No-Length", err);
|
|
});
|
|
|
|
}).call(this);
|