【每日一包0014】to-pascal-case,to-sentence-case,to-snake-case

[github地址:https://github.com/ABCDdouyae…]

to-pascal-case

将用其他符号分开的字符串转换为驼峰形式

用法:toPascalCase(str)

返回:string

var toPascalCase = require('to-pascal-case');

toPascalCase('space case');  // "SpaceCase"
toPascalCase('snake_case');  // "SnakeCase"
toPascalCase('dot.case');    // "DotCase"
toPascalCase('weird[case');  // "WeirdCase"

to-sentence-case

字符串转换为首字母大写的语句

用法:toSentenceCase(str)

返回:string

var sentence = require('to-sentence-case'); 

sentence('the catcher in the rye'); 
// "The catcher in the rye"

to-snake-case

其他符号分割的字符串以_分割

用法:toSnakeCase(str)

返回:string

var snake = require('to-snake-case');

snake('camelCase');  // "camel_case"
snake('space case'); // "snake_case"
snake('dot.case');   // "dot_case"
snake('weird[case'); // "weird_case"
    原文作者:王炜
    原文地址: https://segmentfault.com/a/1190000017052492
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞