草庐IT

member_function

全部标签

javascript - 为什么我需要在 node.js 中写 "function(value) {return my_function(value);}"作为回调?

对JS完全陌生,所以如果这是令人难以置信的明显,请原谅。假设我想使用映射字符串的函数f过滤字符串列表->bool。这有效:filteredList=list.filter(function(x){returnf(x);})这失败了:filteredList=list.filter(f)为什么???代码示例:~/projects/node(master)$node>varitems=["node.js","file.txt"]undefined>varregex=newRegExp('\\.js$')undefined>items.filter(regex.test)TypeError:

javascript - 为什么我需要在 node.js 中写 "function(value) {return my_function(value);}"作为回调?

对JS完全陌生,所以如果这是令人难以置信的明显,请原谅。假设我想使用映射字符串的函数f过滤字符串列表->bool。这有效:filteredList=list.filter(function(x){returnf(x);})这失败了:filteredList=list.filter(f)为什么???代码示例:~/projects/node(master)$node>varitems=["node.js","file.txt"]undefined>varregex=newRegExp('\\.js$')undefined>items.filter(regex.test)TypeError:

node.js - Firebase 函数无法部署 : SyntaxError: Unexpected token function

我正在尝试将功能部署到Firebase,但在部署过程中出现错误错误:函数未正确部署。能不能和异步函数联系起来?实际行为函数部署时出现错误,cli显示以下消息:================控制台日志================>eslint.✔functions:Finishedrunningpredeployscript.ifunctions:ensuringnecessaryAPIsareenabled...✔functions:allnecessaryAPIsareenabledifunctions:preparingfunctionsdirectoryforuploadi

node.js - Firebase 函数无法部署 : SyntaxError: Unexpected token function

我正在尝试将功能部署到Firebase,但在部署过程中出现错误错误:函数未正确部署。能不能和异步函数联系起来?实际行为函数部署时出现错误,cli显示以下消息:================控制台日志================>eslint.✔functions:Finishedrunningpredeployscript.ifunctions:ensuringnecessaryAPIsareenabled...✔functions:allnecessaryAPIsareenabledifunctions:preparingfunctionsdirectoryforuploadi

node.js - 如何使用 Cloud Functions 删除文件?

当我删除Firebase数据库中的帖子时,我需要一个云功能来相应地删除帖子在Firebase存储中的缩略图。我的问题是当我尝试删除缩略图时,我认为我没有正确定位图像文件。这是我尝试过的:constfunctions=require('firebase-functions')constadmin=require('firebase-admin')constgcs=require('@google-cloud/storage')()exports.deletePost=functions.database.ref('Posts/{pushId}').onWrite(event=>{cons

node.js - 如何使用 Cloud Functions 删除文件?

当我删除Firebase数据库中的帖子时,我需要一个云功能来相应地删除帖子在Firebase存储中的缩略图。我的问题是当我尝试删除缩略图时,我认为我没有正确定位图像文件。这是我尝试过的:constfunctions=require('firebase-functions')constadmin=require('firebase-admin')constgcs=require('@google-cloud/storage')()exports.deletePost=functions.database.ref('Posts/{pushId}').onWrite(event=>{cons

javascript - Cloud Functions for Firebase - 序列化返回值 : 时出错

我有一个云函数,用于交叉引用两个列表并在列表中查找相互匹配的值。该函数似乎工作正常,但是在日志中我一直看到这个Errorserializingreturnvalue:TypeError:ConvertingcircularstructuretoJSON。这是函数...exports.crossReferenceContacts=functions.database.ref('/cross-ref-contacts/{userId}').onWrite(event=>{if(event.data.previous.exists()){returnnull;}constuserContac

javascript - Cloud Functions for Firebase - 序列化返回值 : 时出错

我有一个云函数,用于交叉引用两个列表并在列表中查找相互匹配的值。该函数似乎工作正常,但是在日志中我一直看到这个Errorserializingreturnvalue:TypeError:ConvertingcircularstructuretoJSON。这是函数...exports.crossReferenceContacts=functions.database.ref('/cross-ref-contacts/{userId}').onWrite(event=>{if(event.data.previous.exists()){returnnull;}constuserContac

node.js - Firebase 的云函数错误 : "400, Change of function trigger type or event provider is not allowed"

当我运行firebasedeploy时,我收到以下错误消息:functions:HTTPError:400,Changeoffunctiontriggertypeoreventproviderisnotallowed 最佳答案 TL;DRfirebasefunctions:deleteyourFunction//thiscanbedoneviatheFirebaseConsoleaswellfirebasedeploy说明基本上,CloudFunctions期望每个函数始终使用相同的触发器,即一旦创建它就必须坚持其原始触发器,因为每

node.js - Firebase 的云函数错误 : "400, Change of function trigger type or event provider is not allowed"

当我运行firebasedeploy时,我收到以下错误消息:functions:HTTPError:400,Changeoffunctiontriggertypeoreventproviderisnotallowed 最佳答案 TL;DRfirebasefunctions:deleteyourFunction//thiscanbedoneviatheFirebaseConsoleaswellfirebasedeploy说明基本上,CloudFunctions期望每个函数始终使用相同的触发器,即一旦创建它就必须坚持其原始触发器,因为每