const getMaxUtteranceCharLimit = function() { let fc = ` # testIntent - `; for (var i = 0; i <= retCode.boundaryLimits.MAX_CHAR_IN_UTTERANCE + 100; i++) { fc += POSSIBLE_CHARS.charAt(Math.floor(Math.random() * POSSIBLE_CHARS.length)); } return fc; }
// 所有接口30s超时 // 请求统一处理 instance.interceptors.request.use(async config => { if (config.url && config.url.charAt(0) === '/') { config.url = `${baseURL}${config.url}`; } config.headers.authorization = `Bearer ${getItem('token')}`; return config; }, error => Promise.reject(error));
/** * @param {string} prefix vendor-specific prefix, eg: Webkit * @param {string} key style name, eg: transitionDuration * @return {string} style name prefixed with `prefix`, properly camelCased, eg: * WebkitTransitionDuration */ function prefixKey(prefix, key) { return prefix + key.charAt(0).toUpperCase() + key.substring(1); }
getStat(req: MyRequest) { const pathname = url.parse(req.originalUrl).pathname; if (pathname === '/') { return req.method.toLocaleLowerCase() + '_' + '/'; } let partArr = pathname.split('/'); partArr = partArr.map(p => p.replace(/^[0-9]+$/, 'id')); let pathStr: string = req.method.toLocaleLowerCase() + '_' + partArr.join('/'); if (pathStr.charAt(pathStr.length - 1) === '/') { pathStr = pathStr.substring(0, pathStr.length - 1); } return pathStr; }
/** * Fix Uppercase drive letter issue on Windows. It causes problem on custom modules detection (XY instanceof Base) * Unused currently, because it causes problem: https://github.com/moleculerjs/moleculer/issues/788 * * More info: https://github.com/nodejs/node/issues/6978 * @param {String} s * @returns {String} */ fixDriveLetterCase(s) { if (s && process.platform === "win32" && s.match(/^[A-Z]:/g)) { return s.charAt(0).toLowerCase() + s.slice(1); } return s; }
const getMaxRegeExEntityDefinition = function(entityNum = retCode.boundaryLimits.MAX_NUM_REGEX_ENTITIES, charLimit = retCode.boundaryLimits.MAX_NUM_REGEX_ENTITIES) { let fc = ''; for (var i = 0; i <= entityNum; i++) { fc += ` @ regex entity${i} = /`; for (var j = 0; j <= charLimit; j++) { fc += POSSIBLE_CHARS.charAt(Math.floor(Math.random() * POSSIBLE_CHARS.length)); } fc += '/' } return fc; }
getImageURL(path: string) { if (path.indexOf('https://') === 0) { return path; } if (path.charAt(0) !== '/') { path = '/' + path; } return this.configService.static.uploadImgURL + path; }
function slugify(str) { let newString = str; newString = newString.replace(/^\s+|\s+$/g, ''); // trim newString = newString.toLowerCase(); // remove accents, swap ñ for n, etc const from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;'; const to = 'aaaaeeeeiiiioooouuuunc------'; for (let i = 0, l = from.length; i < l; i += 1) { newString = newString.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); } newString = newString .replace(/[^a-z0-9 -]/g, '') // remove invalid chars .replace(/\s+/g, '-') // collapse whitespace and replace by - .replace(/-+/g, '-'); // collapse dashes return newString; }
this.replace( /\w\S*/g, function ( txt ) { return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 ).toLowerCase(); } )
Object.keys(Y).forEach(function(a){Na.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);Y[b]=Y[a]})});
function normalizeKeyReplacer(match, prefix, key, suffix, offset, string) { if (typeof key !== 'string') { return string; } const normalizedKey = key.charAt(0).toUpperCase() + key.substr(1).toLowerCase(); let position = ''; if (typeof prefix === 'string') { position = prefix; } else if (typeof suffix === 'string') { position = suffix; } return normalizedKey + position.charAt(0).toUpperCase() + position.substr(1).toLowerCase(); }
const getMaxPatternCharLimit = function() { let fc = ` # testIntent - this {pattern} is invalid`; for (var i = 0; i <= retCode.boundaryLimits.MAX_CHAR_IN_PATTERNS + 100; i++) { fc += POSSIBLE_CHARS.charAt(Math.floor(Math.random() * POSSIBLE_CHARS.length)); } return fc; }
// 所有接口30s超时 // 请求统一处理 instance.interceptors.request.use(async config => { if (config.url && config.url.charAt(0) === '/') { config.url = `${baseURL}${config.url}`; } config.headers.authorization = `Bearer ${getItem('token')}`; return config; }, error => Promise.reject(error));
/** * @param {string} prefix vendor-specific prefix, eg: Webkit * @param {string} key style name, eg: transitionDuration * @return {string} style name prefixed with `prefix`, properly camelCased, eg: * WebkitTransitionDuration */ function prefixKey(prefix, key) { return prefix + key.charAt(0).toUpperCase() + key.substring(1); }
function slugify(str) { let newString = str; newString = newString.replace(/^\s+|\s+$/g, ''); // trim newString = newString.toLowerCase(); // remove accents, swap ñ for n, etc const from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;'; const to = 'aaaaeeeeiiiioooouuuunc------'; for (let i = 0, l = from.length; i < l; i += 1) { newString = newString.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); } newString = newString .replace(/[^a-z0-9 -]/g, '') // remove invalid chars .replace(/\s+/g, '-') // collapse whitespace and replace by - .replace(/-+/g, '-'); // collapse dashes return newString; }