Agrarium Plugin
Base class for plugins implementations. Every plugin is the simple JS class wich needs to provide some public interface for Agrarium.
Public interface
Both methods gather
and seed
have the same signature but they have a diffrent time of execution.
It's async method wich returns simple object any mined data in keys. This method works in parallel in all chunks. Also, order of this method executions in different plugins not garanted.
Example:
const { Plugin } = require('agrarium');
const FormData = require('form-data');
class MyPlugin extends Plugin {
async gather({ key }) {
const form = new FormData();
form.append('component', key);
return {
my: await got.post('myApiWithComponentsInfo.ru', {
body: form
})
};
}
}
It's also async method wich returns simple object any mined data in keys. This method works before main stream of the gather
methods and you can use this information in the any gather method of any plugin. Also, order of this method executions in different plugins not garanted.
Example:
const { Plugin } = require('agrarium');
class MyPlugin extends Plugin {
async seed({ key }, context) {
return {
components: context.components ?
[].concat(context.components, component.key) :
[component.key]
};
}
}
Private interface
It's set of helpers for better plugins writing experience.
Simple helper for reading files from fs with cache.
Iterator for files and thier sources.
License MIT