Skip to content
Nick Riley edited this page Sep 12, 2015 · 3 revisions

Class: SimpleQueue

FTP# SimpleQueue

new SimpleQueue(command) → {function}

Provides a factory to create a simple queue procedure. Look

at the example below to see how we override the callback
function to perform additional actions before exiting
the queue and loading the next one.
Functions created with this provide a synchronized queue
that is asynchronous in itself, so items will be processed
in the order they are received, but this will happen
immediately. Meaning, if you make a dozen sequential calls
to FTP#filemtime they will all be read immediately,
queued in order, and then processed one after the other.

Parameters:
Name Type Description
command

string

The command that will be issued ie: CWD foo”
Source:
To Do:
  • - make OO – double check endproc and then callback ? or callback and endproc
Returns:
queueManager – The simple queue manager
Type

function

Example
//the current implementation of FTP.rename is preferred,

//this is merely being used as an example
var myCustomRename = (function () {
var myQueueManager = ftp.SimpleQueue.create(‘RNFR’);
return function (pathArray, callback) {
var from = pathArray0,
to = pathArray1;
//override the callback, SimpleQueue’s expect the
//first parameter to be a string
myQueueManager(from, function (err, data) {
if (err) {
dbg(err);
} else {
//provide custom function and trigger callback when done
ftp.raw(’RNTO ’ + to, callback);
}
});
}
}());

Methods

(inner) queueManager(filepath, callback, runNow)

The queue manager returned when creating a new FTP#SimpleQueue object
Parameters:
Name Type Description
filepath

string

The location of the remote file to process the set command.
callback

function

The callback function to be issued.
runNow

boolean

Run the command immediately. Careful, concurrent connections
will likely end in a socket error. This is meant for fine grained control over certain
scenarios wherein the process is part of a running queue and you need to perform an ftp
action prior to the FTP#endproc event firing and execing the next queue.
Source:

Modules

Classes

Events

  • fileTransferComplete
  • queueEmpty
  • error
  • ready

Namespaces


Documentation generated by JSDoc 3.3.0-beta3 on Sat Sep 12 2015 09:23:08 GMT-0700 (PDT)
Clone this wiki locally