1.0.0 • Published 4 years ago

@ehitco/egg-helper v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

egg-helper

NPM version build status Test coverage David deps Known Vulnerabilities npm download

README.zh_CN 中文文档

Utils tools plugin for eggjs

Install

npm i @ehitco/egg-helper --save

开启插件

// config/plugin.js
exports.helper = {
  enable: true,
  package: 'egg-helper',
};

APIs

APIParamDescription
isIntcheck integer
isIPcheck IP
isIPv4check IPv4
isIPv6check IPv6
isMastercluster.isMaster
isArrayarg{mix}return{Boolean}check if a variable is an Array
isBooleanarg{mix}return{Boolean}check if a variable is an Boolean
isNullarg{mix}return{Boolean}check if a variable is an null
isNullOrUndefinedarg{mix}return{Boolean}check if a variable is null or undefined
isNumberarg{mix}return{Boolean}check if a variable is an Number
isStringarg{mix}return{Boolean}check if a variable is an String
isSymbolarg{mix}return{Boolean}check if a variable is an Symbol
isUndefinedarg{mix}return{Boolean}check if a variable is an undefined
isRegExparg{mix}return{Boolean}check if a variable is an RegExp
isObjectarg{mix}return{Boolean}check if a variable is an Object
isDatearg{mix}return{Boolean}check if a variable is an Date
isErrorarg{mix}return{Boolean}check if a variable is an Error
isFunctionarg{mix}return{Boolean}check if a variable is an Function
isPrimitivearg{mix}return{Boolean}check if a variable is an Primitive
isBufferarg{mix}return{Boolean}check if a variable is an Buffer
promisifyfunction{function}receiver{object}return Promisemake callback function to promise
extendtarget{object|array} args{Object|Array}return{Object}extend object
camelCasestr{string}return{String}make indexAction to index_action
isNumberStringstr{string} return{Boolean}check object is number string
isTrueEmptyobj{mixed} return{Boolean}truely
isEmptyobj{object} return{Boolean}check object is mepty
deferreturn deferget deferred object
md5str{string} return{string}get content md5
timeouttime{Number} return Promiseget timeout Promise
escapeHtmlstr{String} return {string}escape html
datetimedate{Date|String}format{String}return{String}get datetime
uuidversion{String} v1 or v4generate uuid
isExistdir{String}check path is exist
isFilefilePath{String}check filepath is file
isDirectoryfilePath{String}check path is directory
chmodpath{String} mode{String}change path mode
mkdirdir{String} mode{String}make dir
getdirFilesdir{String} prefix{String}get files in path
rmdirpath{String} reserve{Boolean}return{Promise}remove dir async
parseAdapterConfigconfig{Object} extConfig{Object|String}parse adapter config
mstime{String}transform humanize time to ms
omitobj{obj} prop {StringArray}omit object props

issues

egg issues

License

MIT