Usage let pad = require("yetanotherpad") function test(){ [ pad.left("hello", 10, '-'); // -----hello pad.right("hello", 10, '-'); // hello----- pad.left('test', 10, '1234'); // 111111test pad.right('test', 10, '1234'); // test111111 ] .forEach((x)=>console.log(x)) }