草庐IT

async_receive_from

全部标签

javascript - async.auto 中的任务结果

我对async.auto中从一项任务到另一项任务的结果逻辑感到困惑。.例如,在下面的代码逻辑中,我在task1中向模型添加了一些数据,它最初是initialtask的输出,在finalTask​​中添加了数据到task1中的模型也反射(reflect)在results.initialTask​​1中。task2中类似添加的数据反射(reflect)在finalTask​​中的results.initialTask​​1中。总结所有results.initialTask​​1,results.task1[0],results.task2[0]、results.task3[0]在final

javascript - D3 : Get nearest value from ordinal axis on mouseover

在我的D3折线图中,我尝试创建一个鼠标悬停效果,如本例所示:http://bl.ocks.org/mbostock/3902569在这个例子中,作者使用了平分线函数,据我所知,它只支持线性比例。问题是,在我的图表中,我有一个带有不同离散rangePoint元组的序号x轴。因此,如果像下面的情况(m=鼠标位置),我想获得最接近的x值的像素位置,在本例中为x2。m|x1----------x2----------x3有什么办法吗? 最佳答案 使用您的链接示例,这里是用于序号比例的mousemove函数的快速实现:vartickPos=x

javascript - 为什么 JavaScript 函数需要关键字 "async"? "await"关键字还不够吗?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭6年前。Improvethisquestion例如,为什么下面的函数需要“异步”?使用await是否不够具体,编译器可以毫无歧义地解析代码?//Whydoweneedasynchere?asyncfunctionfoo(){varuser=awaitgetUser(user_id);console.log(user);}是为了向后兼容的原因吗?(我想不出在标准JavaScript中使用await键盘的任何代码...)?主要是为了清晰起

javascript - axios 并发请求数 : any way to get the results from the successful requests even if some have failed?

我正在尝试了解如何在javascript中处理并发异步请求,您是否知道使用axios获取成功请求结果的方法,即使请求失败了?如果不是,您将如何处理这种情况?varaxios=require('axios')varoptions=[{baseURL:'https://some-base-url',url:'/some-path&key=some-key',method:'post',data:'some-data'},{baseURL:'https://some-base-url',url:'/some-path&key=some-key',method:'post',data:'som

javascript - 重组 "withReducer": justification of async reducer function call

我正在使用withReducerHOC并注意到这种行为:例如,在点击处理程序上调用它:importReactfrom'react'import{withReducer}from'recompose'import{compose}from'ramda'exportdefaultcompose(withReducer('state','dispatch',(state,{value})=>{console.log(value)return{...state,value}},{value:'zero'}))((props)=>{const{dispatch,state}=props,onCl

javascript - WebSocket 连接到 'ws://localhost:3000/' 失败 : Connection closed before receiving a handshake response

我玩了一个friend制作的游戏,并希望通过使用WebRTC和websockets在对等点之间发送按键数据来使其可以跨浏览器玩。但是,我在控制台中收到此错误:WebSocketconnectionto'ws://localhost:3000/'failed:Connectionclosedbeforereceivingahandshakeresponse我的服务器文件有以下几行:'usestrict';constexpress=require('express');constSocketServer=require('ws').Server;constpath=require('pat

javascript - Node : Testing with sinon and async/await

使用sinon和async/await运行此测试时遇到问题。这是我正在做的一个例子://infilefuncsasyncfunctionfuncA(id){leturl=getRoute53()+idreturnawaitfuncB(url);}asyncfunctionfuncB(url){//emptyfunction}和测试:letfuncs=require('./funcs');...//describeletstubRoute53=null;letstubFuncB=null;letroute53='https://sample-route53.com/'letid='123

javascript - 了解类 : Compose a Triangle from extending 3 points?

问题:我怎样才能使用Triangle类扩展Point(supers(?))并组成一个如下所示的对象://"name":"ThomasTheTriangle",//"points":[//{age:"2015-05-28T06:23:26.160Z",x:1,y:1},//{age:"2015-05-28T06:23:26.161Z",x:0,y:3},//{age:"2015-05-28T06:23:26.164Z",x:2,y:3}//]JS:classPoint{constructor(x,y){this.name="Point"this.age=newDate();this.x=

javascript - Jasmine : Timeout - Async callback was not invoked within timeout

我需要测试一个从url加载图像的AngularJs服务。这是我的服务:/*globalangular,Image*/(function(){'usestrict';functionSourceLoader($q,$log){/***Loadanimagefromurlandreturnapromisewhichisresolvedwhenimageisloadingisdone.*Itreturntheimagesobjectasresolvedpromise.*@paramurlsourceoftheimage*@returns{Promise}unresolvedpromiseof

javascript - "export default from"不适用于 Babel React

我使用react来构建我的组件库。我需要一个index.js来将所有组件导入一个地方。像这样:MyComponents/Button.jsLabel.jsindex.js在index.js中,我接下来尝试做的是://thisexportnothingexport{default}from'./Button';//thistellsmeaboutsyntaxerrorexportdefaultfrom'./Button';我发现只有这个解决方案有效importButtonfrom'./Button';exportdefaultButton;但我发现一些React组件库使用我上面提到的语法