I have the following code in my index.js
const test = require('./js/lerifier/start');
const $ = require("jquery");
$( document ).ready(function() {
console.log( "ready!" );
console.log(test.init());
});
I want to access the this.init()
function from the lerifier function on start.js
const $ = require("jquery");
const SVGInjector = require('svg-injector');
module.exports = function Verifier() {
this.init = function () {
let mySVGsToInject = $('img.inject-me');
let injectorOptions = {
evalScripts: 'once',
pngFallback: 'assets/png',
each: function (svg) {
// Callback after each SVG is injected
console.log('SVG injected: ' + svg.getAttribute('id'));
}
};
// Trigger the injection
SVGInjector(mySVGsToInject, injectorOptions, function (totalSVGsInjected) {
// Callback after all SVGs are injected
console.log('We injected ' + totalSVGsInjected + ' SVG(s)!');
});
}
};
With the code stated in the index.js
the error msg that I get is
test.init is not a function
, I know I'm doing something wrong or misunderstand the use of module.exports.