1.1.5 • Published 10 years ago

vz.stepper v1.1.5

Weekly downloads
4
License
LGPL-3.0
Repository
github
Last release
10 years ago

vz Stepper

DEPRECATED in favour of vz.walk

NPM

No piece of software is ever completed, feel free to contribute and be humble

Sample usage:

var Stepper = require('vz.stepper'),
    fs = require('fs'),
    fileName = 'foo.bar';

// Lower case file

(new Stepper(function(args,vars){
  
  switch(this.step){
    case 'start':
      vars.name = args[0];
      fs.exists(this.name,this.goTo('checkFile',vars));
      break;
    case 'checkFile':
      if(args[0]) fs.readFile(vars.name,{
        encoding: 'utf8'
      },this.goTo('open',vars));
      else throw 'File doesn\'t exist';
      break;
    case 'open':
      if(args[0]) throw args[0];
      args[1] = args[1].toLowerCase();
      fs.writeFile(vars.name,args[1],this.goTo('end'));
      break;
    case 'end':
      if(args[0]) throw args[0];
      console.log('Success');
      break;
  }
  
})).goTo('start')(fileName);

Reference:

Stepper object

Constructor(callback)

Creates and initializes a stepper with callback as its internal callback.

Stepper.step

The current step of the stepper

Stepper.goTo(step,callback)

Returns a function which executes callback or the internal callback of the stepper, with the stepper as the thisArg, seting the current step to step and passing as the first argument the supplied arguments to the function, and as the second vars or an empty object.

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago