Q.js - Using deferred

后端 未结 5 1018
南笙
南笙 2021-02-07 11:36

How do I get the value of the text from the example below?

Q.js has an example on using Deferred:

var deferred = Q.defer();
FS.readFile(\"foo.txt\", \"ut         


        
5条回答
  •  情深已故
    2021-02-07 12:26

    See https://github.com/kriskowal/q#adapting-node

    Can be rewritten in a nodejs-like:

    var read = Q.nfcall(FS.readFile, FS, "foo.txt", "utf-8");
    read().then( function (text) { console.log(text) } );
    

提交回复
热议问题