string-process.js
460 Bytes
/**
* 字符串处理
*/
'use strict';
const _ = require('lodash');
/**
* [判断数字]
* @param {[string]} str [验证参数]
* @return {[Boolean]}
*/
const isNumeric = (str) => {
return /^\d+(\.\d+)?$/.test(str);
};
/**
* 参数过滤
* @param {*} param
*/
const paramsFilter = (param) => {
if (param) {
return _.escape(param);
} else {
return param;
}
};
module.exports = {
isNumeric,
paramsFilter
};