【逐日一包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
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞