小编use*_*092的帖子

Node.js 中的 New Date() 时间错误

考虑:

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?

javascript node.js

6
推荐指数
1
解决办法
7141
查看次数

Ramda地图和过滤器在一个循环

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)

javascript node.js ramda.js

1
推荐指数
1
解决办法
1479
查看次数

标签 统计

javascript ×2

node.js ×2

ramda.js ×1