Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Forked from joepie91/map.js
Last active August 28, 2015 20:24

Revisions

  1. robotlolita revised this gist Aug 28, 2015. 2 changed files with 15 additions and 16 deletions.
    16 changes: 0 additions & 16 deletions map.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +0,0 @@
    var Promise = require("bluebird");
    var bhttp = require("bhttp");

    Promise.try(function(){
    return bhttp.get("http://somesite.com/all-the-urls.txt");
    }).then(function(response){
    return response.body.toString().split("\n");
    }).map(function(url){
    return bhttp.get(url);
    }).map(function(response){
    return response.body;
    }).then(function(arrayOfResponses){
    /* arrayOfResponses now contains all the HTTP responses for each URL in the all-the-urls.txt file! */
    }).catch(function(err){
    console.log("An error occurred!", err);
    })
    15 changes: 15 additions & 0 deletions map.st
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    (* Assume bhttp-get is available here somehow *)

    let HTTP = {
    def get: url
    (* This would actually need to be imported properly. Yeah, FFI sucks, but oh well... *)
    Task from-promise: (FFI invoke: bhttp-get in-context: unit with-arguments: [FFI export: url])
    }

    do {
    response <- HTTP get: "http://somesite.com/all-the-urls.txt";
    url <- response at: "body" >> as-string >> split: "\n";
    HTTP get: url
    } recover: { error |
    Console log!: error
    }
  2. @joepie91 joepie91 revised this gist Aug 24, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions map.js
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,6 @@ Promise.try(function(){
    return response.body;
    }).then(function(arrayOfResponses){
    /* arrayOfResponses now contains all the HTTP responses for each URL in the all-the-urls.txt file! */
    }).catch(function(err){
    console.log("An error occurred!", err);
    })
  3. @joepie91 joepie91 revised this gist Aug 14, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion map.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ var bhttp = require("bhttp");
    Promise.try(function(){
    return bhttp.get("http://somesite.com/all-the-urls.txt");
    }).then(function(response){
    return response.body.toString.split("\n");
    return response.body.toString().split("\n");
    }).map(function(url){
    return bhttp.get(url);
    }).map(function(response){
  4. @joepie91 joepie91 created this gist Aug 6, 2015.
    14 changes: 14 additions & 0 deletions map.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    var Promise = require("bluebird");
    var bhttp = require("bhttp");

    Promise.try(function(){
    return bhttp.get("http://somesite.com/all-the-urls.txt");
    }).then(function(response){
    return response.body.toString.split("\n");
    }).map(function(url){
    return bhttp.get(url);
    }).map(function(response){
    return response.body;
    }).then(function(arrayOfResponses){
    /* arrayOfResponses now contains all the HTTP responses for each URL in the all-the-urls.txt file! */
    })