11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Node.jsモジュール】node-multispinnerでいい感じに並列処理の実行をコンソールへ出力する

Posted at

こんな感じのものをコンソールに簡単に出すことができる。

node-multispinner

install

npm install --save multispinner

sample

例えばこんなコードを書ける
別途、superagentも使っているので注意。

main.js
const Multispinner = require('multispinner')
const request      = require('superagent')
const requests = [
  'http://google.com',
  'http://yahoo.co.jp',
  'http://apple.com',
  'http://nobodyrequest.com'
]

const ms = new Multispinner(requests)

ms
  .on('success', () => {
    console.log('done without errors!')
  })
  .on('err', (e) => {
    console.log(`${e} spinner finished with an error`)
  })

requests.map((r) => {
  request
    .get(r)
    .end((err, res) => {
      if(err){ ms.error(r); return ;}
      ms.success(r);
    })
})

 2015-11-15 23.12.27.png

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?