Bluebird. Then method

There is sample code in the Bluebird docs for the .call method labeled "Lo-dash chaining or underscore methods".

What is the purpose of chained .then(_)

in the code snippet below?

var Promise = require("bluebird");

...

var _ = require("lodash");
var fs = Promise.promisifyAll(require("fs"));

fs.readdirAsync(".").then(_) <-- ???
    .call("groupBy", function(fileName) {
        return fileName.charAt(0);
    })

...

      

Thank!

+3


source to share


1 answer


In underscore, identifier _ is a function as well as a namespace.

Performance. then returns the result of the passed function.



The function call _

starts the underscore chain, any subsequent actions take place on the passed object. It starts the chain with readdirAsync result.

+3


source







All Articles