tool-helper
Some simple functions that are commonly used in life or office.About fs / http / ffmpeg / message / logger .
Install
npm i tool-helper --save
Usage
common
import {common} from 'tool-helper'
const {
//node-uuid
uuid,
//crypto md5
md5,
//setTimeout in promise
sleep,
//get a datetime string
datetime,
//get a human readable size like 20MB
humanSize,
//get a human readable time like 20 minutes ago
getHumanTime,
//readable stream pipe to write stream
rs2ws
} = common;
download
//node-fetch
import {download} from 'tool-helper'
let ins = new download('https://minioapi.byyui.com:9999/zztemp/test.mp4','./test.mp4');
//download progress
ins.on('progress',info=>{
console.log(info);
});
let rs = await ins.download();
//or json / html / post / m3u8
ffmpeg
import {ffmpeg} from 'tool-helper'
const {getImage,getM3u8,getVideo} = ffmpeg;
//Please install ffmpeg on os before using it
//through 'child_process' call ffmpeg bin
fileutil
import {fileutil} from 'tool-helper'
const {mkdir,existsFile,isFile,deldir,listFiles,getMd5,base64} = image;
//these functions just like these names,but dit not do any safe check
logger
import {getLogger} from 'tool-helper'
//log4js
const logger = getLogger('test');
logger.info('some message');
useragent
import {useragent} from 'tool-helper'
const {
//get a random useragent like 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
getRandom,
//get a device information throuth useragent
devices
} = useragent;
message
//dingtalk and mail
import {message} from 'tool-helper'
const {dingding,mail} = message;
License
The MIT LICENSE.