(function () {
console.log('bonjour')
}) ();
(showName = function (name) {
If you haven't already set your NPM author info, now you should:
npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"
npm adduser
For more api, see here
const fs = require('fs');
const gm = require('gm');
gm('id.jpg')
.toBuffer('JPG', function (err, buffer) {
if (err) return console.error(err);
Moar informations here at the Lodash documentation
Create a file index.js
and copy paste it.
Do not forget to
npm init -y &&
npm i lodash fs nodemon -D
Paste this into the index.js
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
Full credits to this thread
const getFileExtension = (filename) => {
const splitedName = filename.split('.');
console.log(splitedName) // [ 'fileblabla', 'pdf' ]
if (splitedName.length === 1 || (splitedName[0] === '' && splitedName.length === 2)) {
return '';