Code Monkey home page Code Monkey logo

meterbox's Introduction

MeterBox

![NPM version][npm-badge] [npm-badge]: https://badge.fury.io/js/meterbox.png

multimeter wrapper

Install

npm install meterbox

Feature

multimeterから拡張した機能として、同時実行数を設定できるようにしてます。
例えば{multijob:3}とすると、3つのジョブを並行で実行して、終わり次第に次のジョブを実行します。

  • Limited concurrent execution (default only single job)
  • Unlimited job (emit.setMaxListeners as you think proper)

Example

var MeterBox = require('meterbox');

var meterBox = new MeterBox({
    name: 'my progress',
    multijob: 3, //同時実行数
    barWidth: 70
});

var uploads = [
    {fromPath:'File A', toPath:'/newDir1', speed:5 },
    {fromPath:'File B', toPath:'/newDir1', speed:10 },
    {fromPath:'File C', toPath:'/newDir1', speed:15 },
    {fromPath:'File D', toPath:'/newDir2', speed:20 },
    {fromPath:'File E', toPath:'/newDir3', speed:10 },
    {fromPath:'File F', toPath:'/newDir3', speed:15 },
    {fromPath:'File G', toPath:'/newDir3', speed:20 },
    {fromPath:'File H', toPath:'/newDir4', speed:25 },
    {fromPath:'File I', toPath:'/newDir4', speed:12 }
];

var count = 0;
uploads.forEach(function(data) {
    data.percent = 0;
    data.label = '[' + count++ + '] ' + data.fromPath;
    data.label = data.label.substring(0, 50);

    meterBox.add(data, function(meter, done) {
        var iv = setInterval(function () {
            data.percent += data.speed;
            if (100 < data.percent) {
                data.percent = 100;
            }
            meter.percent(data.percent, data.percent + '%');
            if (data.percent === 100) {
                clearInterval(iv);
                done();
            }
        }, 100);
    });
});

meterBox.run();

meterbox's People

Watchers

Koki Nakashima avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.