草庐IT

purely-functional

全部标签

javascript - 从回调函数内部使用 "pure"Node.js 重定向

以下是我的server.js代码的MCVE:letfs=require('fs');lethttp=require('http');http.createServer((req,res)=>{//HandlesGETrequestsif(req.method=='GET'){letfile=req.url=='/'?'./index.html':'/login.html';//justanexamplefs.readFile(file,(err,data)=>{res.writeHead(200,{'Content-Type':'text/html'});res.end(data);}

c++ - Node :How to call c++ DLL function through nodejs?

我有一个windowsc++DLL。它提供了一些函数,如add(1,2)。但是我没有这个DLL的源代码,是否可以通过nodejs调用这个DLL中的函数,我的意思是通过web端和http。如果可以,我该怎么办? 最佳答案 你查看了ffinodejs库吗?https://github.com/node-ffi/node-ffivarffi=require('ffi');varlibm=ffi.Library('libm',{'ceil':['double',['double']]});libm.ceil(1.5);//2

c++ - Node :How to call c++ DLL function through nodejs?

我有一个windowsc++DLL。它提供了一些函数,如add(1,2)。但是我没有这个DLL的源代码,是否可以通过nodejs调用这个DLL中的函数,我的意思是通过web端和http。如果可以,我该怎么办? 最佳答案 你查看了ffinodejs库吗?https://github.com/node-ffi/node-ffivarffi=require('ffi');varlibm=ffi.Library('libm',{'ceil':['double',['double']]});libm.ceil(1.5);//2

javascript - GraphQL Args 错误 : argument type must be Input Type but got: function GraphQLObjectType(config) {

在服务器启动时(nodeindex.js)我的GraphQLNodeJS服务器出现以下错误:Error:Query.payment(data:)argumenttypemustbeInputTypebutgot:functionGraphQLObjectType(config){_classCallCheck(this,GraphQLObjectType);当我从字符串更改原始参数时发生此错误args:{data:{type:graphQL.GraphQLString}},到一个对象类型:args:{data:{type:graphQL.GraphQLObjectType}},我需要一

javascript - GraphQL Args 错误 : argument type must be Input Type but got: function GraphQLObjectType(config) {

在服务器启动时(nodeindex.js)我的GraphQLNodeJS服务器出现以下错误:Error:Query.payment(data:)argumenttypemustbeInputTypebutgot:functionGraphQLObjectType(config){_classCallCheck(this,GraphQLObjectType);当我从字符串更改原始参数时发生此错误args:{data:{type:graphQL.GraphQLString}},到一个对象类型:args:{data:{type:graphQL.GraphQLObjectType}},我需要一

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