Some thoughts and playing around Async / Await with Javascript.
// Basic function setting name to this object
function _setName(name){
this.name = name
}
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
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);
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 '';
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
window.mobileAndTabletcheck = function() { | |
var check = false; | |
(function(a) { | |
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || | |
if (window.mobileAndTabletcheck == true) |