var request = require('axios')

var WebpackFeatures = function(featuresContext) {
    this.each = function(fn) {
        this.list().then(function(files) {
            files.forEach(fn)
        })
    }

    this.list = function() {
        var pendingRequests = []
        var featureFilenames = featuresContext.keys()

        featureFilenames.forEach(function(f, i) {
            var req = request.get(featuresContext(f))

            pendingRequests.push(req)
        })

        return request.all(pendingRequests).then(request.spread(this.handleResponse))
    }

    this.handleResponse = function() {
        var args = Array.prototype.slice.call(arguments);
        var files = []

        if (typeof args[0] === 'object') {
            files = args.map(function(arg) {
                return arg[0]
            })
        } else {
            files = [args[0]]
        }

        return files
    }
}

module.exports = WebpackFeatures

@@ -144,16 +144,48 @@
 ion(
-files) %7B
+) %7B%0A            var files = arguments%5B0%5D
 %0A   
@@ -509,22 +509,25 @@
         
-return
+var all =
  request
@@ -557,23 +557,8 @@
 hen(
-request.spread(
 this
@@ -573,17 +573,35 @@
 esponse)
-)
+%0A        return all
 %0A    %7D%0A%0A
@@ -699,9 +699,8 @@
 nts)
-;
 %0A   
@@ -712,62 +712,27 @@
 var 
-files = %5B%5D%0A%0A        if (typeof args%5B0%5D === 'object') %7B
+responses = args%5B0%5D
 %0A   
@@ -728,35 +728,35 @@
 args%5B0%5D%0A        
-   
+var
  files = args.ma
@@ -748,19 +748,24 @@
 files = 
-arg
+response
 s.map(fu
@@ -771,19 +771,17 @@
 unction(
-arg
+f
 ) %7B%0A    
@@ -792,87 +792,21 @@
     
-   
- 
 return 
-arg%5B0%5D%0A            %7D)%0A        %7D else %7B%0A            files = %5Bargs%5B0%5D%5D
+f.data
 %0A   
@@ -807,24 +807,25 @@
 ta%0A        %7D
+)
 %0A%0A        re

Fix bug when processing ajax response