dep_counter

Just a way to track that a set of dependencies is completely fulfilled

Usage no npm install needed!

<script type="module">
  import depCounter from 'https://cdn.skypack.dev/dep_counter';
</script>

README

DepCounter ( dep_counter)

Version 0.9.42 BETA

DepCounter is a simple tool to provide a countdown of fulfilled dependencies.

It is useful for tracking things like number of files to load or parameters remaining to be set.

DepCounter only counts the dependencies marked as fulfilled and those remaining.

If you want something to track dependencies by name, please try...
NamedDepCounter

If you want to see coding docs, look into...
docs

Install:

    npm install dep_counter;

QuickStart:

    import DepCounter from 'dep_counter';
    const depCounter = new DepCounter('depCounterName');
    
    depCounter.count(3);
    console.log(depCounter.ready()); // false;
    console.log(depCounter.current()); // 3
        
    depCounter.mark(); 
    console.log(depCounter.ready()); // false;
    console.log(depCounter.current()); // 2

    depCounter.mark(); 
    console.log(depCounter.ready()); // false;
    console.log(depCounter.current()); // 1

    depCounter.mark(); 
    console.log(depCounter.ready()); // true;
    console.log(depCounter.current()); // 0

    depCounter.reset();
    console.log(depCounter.ready()); // false;
    console.log(depCounter.current()); // 3   

Add some callbacks

    import DepCounter from 'dep-counter';
    const depCounter = new DepCounter('depCounterName');
    depCounter.count(3);
    depCounter.onComplete((depCounter)=>console.log('DONE', depCounter.ready()));
    depCounter.onMark((depCounter)=>console.log(`Mark! ${depCounter.current()}))

    depCounter.mark();  // Mark! 2
    depCounter.mark();  // Mark! 1
    depCounter.mark();  // Mark! 0 // DONE