Lightweight implementation of promises

后端 未结 7 1545
独厮守ぢ
独厮守ぢ 2021-02-02 17:09

I am building a simple charting tool. When a user chooses a data source and a chart type, both the data and the script for the specific chart (.js) are loaded and then the code

7条回答
  •  孤独总比滥情好
    2021-02-02 17:40

    If you want it really lightweight, You should try sb-promise, It's under MIT license. It's just a few kbs and is API compatible with native Promises.

    function myFunction(){
       return new Promise(function(resolve,reject){
         resolve({some:"data"});
       }
    }
    myFunction().then(function(result){
       console.log(result); // {some:"data"}
    });
    

提交回复
热议问题