mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-12 19:30:00 +01:00
Add sequencer.getSteps() (#777)
* create getSteps() and test it * Adds test with new sequencer instance and updated Readme
This commit is contained in:
committed by
Jeffrey Warren
parent
761142d9d3
commit
c3abdaf3aa
10
README.md
10
README.md
@@ -493,6 +493,16 @@ sequencer.insertSteps({
|
||||
```
|
||||
return value: **`sequencer`** (To allow method chaining)
|
||||
|
||||
## Fetching current steps
|
||||
|
||||
The `getSteps` method can be used to get the array of current steps in `this` instance of sequencer.For example
|
||||
|
||||
```js
|
||||
sequencer.getSteps()
|
||||
```
|
||||
|
||||
returns an array of steps associated with the current sequencer.
|
||||
|
||||
## Saving Sequences
|
||||
|
||||
IMAGE SEQUENCER supports saving a sequence of modules and their associated settings in a simple string syntax. These sequences can be saved in the local storage inside the browser and inside a JSON file in node.js. sequences can be saved in node context using the CLI option
|
||||
|
||||
@@ -203,6 +203,16 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
return require('./ReplaceImage')(this, selector, steps, options);
|
||||
}
|
||||
|
||||
//returns the steps added
|
||||
function getSteps(){
|
||||
var steps;
|
||||
if(arguments[0])
|
||||
steps= this.images.test.steps;
|
||||
else
|
||||
steps = this.images.image1.steps;
|
||||
return [...steps];
|
||||
}
|
||||
|
||||
function setUI(UI) {
|
||||
this.events = require('./ui/UserInterface')(UI);
|
||||
}
|
||||
@@ -442,6 +452,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
createMetaModule: require('./util/createMetaModule'),
|
||||
saveSequence: saveSequence,
|
||||
loadModules: loadModules,
|
||||
getSteps:getSteps,
|
||||
|
||||
//other functions
|
||||
log: log,
|
||||
|
||||
@@ -165,6 +165,24 @@ test('insertSteps({image: {index: index, name: "module", o: options} }) inserts
|
||||
});
|
||||
|
||||
|
||||
test('getSteps() returns correct array of steps', function(t){
|
||||
var sequencer = ImageSequencer({ ui: false });
|
||||
sequencer.loadImages('test', red);
|
||||
sequencer.addSteps(['blur','invert']);
|
||||
var stepsArray = sequencer.getSteps('test');
|
||||
t.equal(stepsArray.length, sequencer.images.test.steps.length, "getSteps() returns correct length of steps");
|
||||
var flag=0;
|
||||
for (var i = 0; i<sequencer.images.test.steps.length; i++){
|
||||
if(stepsArray[i].options.name==(sequencer.images.test.steps[i].options.name))
|
||||
continue
|
||||
else
|
||||
flag=1;
|
||||
}
|
||||
t.equal(flag, 0, "getSteps() returns correct array of steps");
|
||||
t.end();
|
||||
})
|
||||
|
||||
|
||||
test('run() runs the sequencer and returns output to callback', function(t) {
|
||||
sequencer.run({ mode: 'test' }, function(out) {
|
||||
t.equal(typeof (sequencer.images.test.steps[sequencer.images.test.steps.length - 1].output), "object", "Output is Generated");
|
||||
|
||||
Reference in New Issue
Block a user