考虑:
root@ubuntu:/firma/Exotech/heart-beat/heart-beat-service# date
Mon Apr 24 17:07:52 CEST 2017
root@ubuntu:/firma/Exotech/heart-beat/heart-beat-service# node test.js
2017-04-24T15:07:56.271Z
root@ubuntu:/firma/Exotech/heart-beat/heart-beat-service# cat test.js
console.log(new Date())
root@ubuntu:/firma/Exotech/heart-beat/heart-beat-service#
Run Code Online (Sandbox Code Playgroud)
如您所见,服务器日期为 17:07,但 new Date() 返回的是 15:07。如何使用服务器的日期设置更正我的 Node.js?
const R = require('rambda')
export const test = () => {
const data = [1, 2, 3, 4, 5, 6, 7, 8]
const filter = no => no > 5
const map = no => no * 100
// looping 2 times
return data
.filter(filter)
.map(map)
// wird 1 loop
return data.reduce((data, no) => {
if (!filter(no)) return data
data.push(map(no))
return data
}, [])
// I want to do something like this.
return data.map(R.pipe(map, filter))
}
Run Code Online (Sandbox Code Playgroud)
您好,是否可以使用ramda或rambda在一个循环中进行映射和过滤?
我的例子:
return data.map(R.pipe(map, …Run Code Online (Sandbox Code Playgroud)