草庐IT

some_other_func

全部标签

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 - lodash - _.some() 带条件/计数器

考虑以下任务:我们列出了欧洲不同城镇的日平均气温。{Hamburg:[14,15,16,14,18,17,20,11,21,18,19,11],Munich:[16,17,19,20,21,23,22,21,20,19,24,23],Madrid:[24,23,20,24,24,23,21,22,24,20,24,22],Stockholm:[16,14,12,15,13,14,14,12,11,14,15,14],Warsaw:[17,15,16,18,20,20,21,18,19,18,17,20]}我们想将这些城镇分为两组:“温暖”和“炎热”。“温暖”应该是至少有3天温度高于19

javascript - 如何使用 _.every 解决 _.some?

致力于在标准javascript中重新实现underscore.js的功能的编程挑战。具体来说,我正在努力实现_.some功能。(http://underscorejs.org/#some)我正在努力解决的部分是它要求我找到一种在内部使用_.every来解决它的方法。(http://underscorejs.org/#every)我之前已经完成了_.every函数,它可以正常工作。从逻辑上讲,这是我想在草图代码中做的事情:_.some=function(collection,truthStatementFunction){return!(_every(collection,!truth

javascript - 不能将 String.prototype.match 用作 Array.some 的函数吗?

这行不通:vars='^foo';console.log(['boot','foot'].some(s.match));UncaughtTypeError:String.prototype.matchcalledonnullorundefined但是这样做:vars='^foo';console.log(['boot','foot'].some(function(i){returni.match(s)}));这是为什么?我以某种方式想象String.prototype.match函数太“原始”之类的,但究竟是为什么呢?因为我没有使用ES2015,所以第二个版本看起来很冗长。有替代方案吗

javascript - Node.js Express - app.all ("*", func) 在访问根域时不会被调用

我正在尝试设置一个在每次页面加载时调用的全局函数,无论它在我的网站中的位置如何。根据Express的API,我使用了app.all("*",doSomething);在每次加载页面时调用函数doSomething,但它并不完全有效。该函数在每次页面加载时触发,除了基本域的页面加载(例如http://domain.com/pageA将调用该函数,但http://domain.com不会)。有谁知道我做错了什么?谢谢! 最佳答案 我打赌你放了app.get('/',fn)以上app.all("*",doSomething);请记住,Ex

javascript - UnderscoreJS——_.some() 与 _.find()

根据我在文档中阅读的内容,_.find()的功能与_.some()非常相似有谁知道两者之间是否有(性能)优势? 最佳答案 它们的性能特征可能相同,假设您想知道是否使用find或some在特定情况下。他们都以同样的方式懒惰。区别在于输出。find将返回值,some将返回一个boolean。我检查了源代码(1.4.4)。some和find都在内部使用了some(===any)。因此,即使使用了some的native实现,它对find和some都有好处。 关于javascript-Unders

javascript - 为什么在使用 fetch API 时请求显示在 chrome 工具的 "Other"选项卡(而不是 XHR)

所以我想使用fetchAPI没关系,但是用它发出的所有请求都属于GoogleChrome中的“其他”部分。我希望将它们放在XHR部分。这是我用于这些请求的http.js服务。import'whatwg-fetch'importAuthfrom'./Auth';importUrlfrom'url-parse';constAPI_URL=process.env.API_URLconsthttp={get:get,getAuthed:getAuthed,post:post,postAuthed:postAuthed,getDefaultHeaders:getDefaultHeaders,ge

javascript - 如何让 javascript 在调用 QWebElement.appendInside ('some html code' 时工作)?

我正在为im客户端开发插件,它将在QWebView中显示聊天记录。插件必须支持html模板。现在我正在尝试通过调用QWebElement.appendInside(‘newmessage’)来附加新消息,如果模板中有javascript源,则它不起作用。例如模板可能是这样的类型: %time%%name%getitall('%text%','%name%','%cid%','%base%',meldungsart[0]);animation1();函数getitall()和animation1()不会被执行。我不能使用QWebElement.evaluatejavascrip

javascript - 为什么在 Firefox 中 Function.prototype.func=... 不影响 console.log?

我已经使用Function.prototype.func=...添加了一个函数到Function但在Firefox中它没有被添加console.log:Function.prototype.func=function(){returnthis.toString();};alert(typeofconsole.log.func);//inFF:undefined,inChrome:function这是错误还是有任何原因? 最佳答案 在Firefox中很明显:varfoo=function(){}foo.__proto__==Funct

javascript - JS : Call certain function before calling each of other functions in file

我有一个关于在JS中更好地重用代码的问题。例如,我有文件functions.js和下一个函数:exportconsta=()=>{...}exportconstb=()=>{...}exportconstc=()=>{...}....constfoo=()=>{...}我想在调用此类中的每个函数之前调用foo()函数。简单的解决方案是:exportconsta=()=>{foo()...}exportconstb=()=>{foo()...}exportconstc=()=>{foo()...}但是如果我有超过3个函数怎么办?如何优化foo()函数调用,每次在调用每个文件函数之前调用?