js camelCase formatter

驼峰命名 转换器


'A'.charCodeAt();
// 65
'Z'.charCodeAt();
// 90 'a'.charCodeAt();
// 97
'z'.charCodeAt();
// 122

Number.isNaN(+`x`)
// true Number.isNaN(+`2`)
// false

'tools_finance_costInV2' => '/tool/finance/cost-in-v2'

'costInV2' => 'cost-in-v2'

solution



const log = console.log;

const camelCaseFormatter = (str = ``, debug = false) => {
let result = '';
for(let item of [...str]) {
if(item.charCodeAt() > 'a'.charCodeAt() || !Number.isNaN(+item)) {
result += item;
} else {
result += `-${item.toLocaleLowerCase()}`;
}
}
if(debug) {
log(`result = `, result);
}
return result;
} const str = 'costInV2';
// "costInV2" camelCaseFormatter(str, true); /* // node ./camelCase.js
// result = cost-in-v2 */

demo

id to URL

'tools_finance_costInV2' => '/tool/finance/cost-in-v2'

const url = window.location.origin;
// https://app.xgqfrms.xyz const config = {
key: 'costInV2',
level: 3,
id: 'tools_finance_costInV2',
name: '工具库-财务-消耗录入',
url: '/tool/finance/cost-in-v2',
// url: 'https://app.xgqfrms.xyz/tool/finance/cost-in-v2',
};

regex

refs

https://app.xgqfrms.xyz/index.html



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有️xgqfrms, 禁止转载 ️,侵权必究️!


最新文章

  1. (原) 2.2 ZkClient使用
  2. Jquery——简单的视差滚动效果,兼容PC移动端
  3. spark学习笔记总结-spark入门资料精化
  4. 在eclipse中使用maven创建springMVC项目
  5. 踩的python列表及for循环一个坑儿
  6. hdu 3006 枚举集合能够产生的全部并集的集合
  7. python发送各类邮件的主要方法
  8. 在线API大全
  9. java静态方法之线程安全问题
  10. Android开源库loopj的android-async-http的 JsonHttpResponseHandler 存在死循环GC_CONCURRENT
  11. seajs简记
  12. 拍照、本地图片工具类(兼容至Android7.0)
  13. 怎样在Spark、Flink应用中使用Protobuf 3的包
  14. css实现椭圆、半椭圆
  15. Java求最大公约数和最小公倍数
  16. react-native导航器 react navigation 介绍
  17. 我用 tensorflow 实现的“一个神经聊天模型”:一个基于深度学习的聊天机器人
  18. Matlab imshow, image, imagesc 三者详细分析
  19. NAT(Network Address Translation)
  20. OSG 改变窗口大小

热门文章

  1. 基于Redo Log和Undo Log的MySQL崩溃恢复流程
  2. : cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs
  3. LOJ10077
  4. eclipse项目放到github
  5. SANGFOR AC配置AD域单点登录(一)----AC侧配置
  6. PHP-数组相关知识总结
  7. DolphinScheduler源码分析之EntityTestUtils类
  8. TypeScript中 typeof ArrayInstance[number] 剖析
  9. 2017-2018 ACM-ICPC Latin American Regional Programming Contest PART (11/13)
  10. int和longlong的范围