小编jon*_*ona的帖子

如何链接多个 Promise?

我不太确定,也许我错过了一些明显的东西,但我不知道如何链接两个承诺。

我的基于回调的代码看起来像这样:

async.series([
function (cb) {
  // Create the directory if the nodir switch isn't on
  if (!nodir) {
    fs.mkdir('somedirectory', function (err) {
      if (err) {
        log('error while trying to create the directory:\n\t %s', err)
        process.exit(0)
      }
      log('successfully created directory at %s/somedirectory', process.cwd())
      cb(null)
    })
  }
  cb(null)
},
function (cb) {
  // Get the contents of the sample YML
  fs.readFile(path.dirname(__dirname) + '/util/sample_config.yml', function (err, c) {
    var sampleContent = c
    if (err) {
      log('error while reading the sample file:\n\t %s', …
Run Code Online (Sandbox Code Playgroud)

javascript fs node.js promise bluebird

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

处理磁带测试中的错误?

如果我有一个抛出错误的函数并且我想测试该错误,我会写这样的东西:

test('throws at something that is not a string', t => {
  t.plan(1)
  t.err(loadString(9))
})
Run Code Online (Sandbox Code Playgroud)

但这总是导致执行时来自函数的实际错误:

还有的在not ok 1 no plan foundnot ok 2 no assertions found,这也是奇怪的.我怎样才能确定它实际上没有扔?

testing tap node.js node.js-tape

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

CoffeeScript中的$(document).on和($ document).on之间的区别?

我的朋友正在使用($ document).on他的CoffeeScript代码.这与通常的不同$(document).on,如果是这样,以什么方式?

javascript jquery domdocument coffeescript

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