npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tinyfe/naming-transform

v0.0.9

Published

Converting to different kind of naming style

Downloads

49

Readme

@tinyfe/naming-transform

转换为不同类型的命名风格

Usage

import {
  style,
  baseCase,
  camel,
  capital,
  constant,
  dot,
  header,
  hyphen,
  kebab,
  param,
  path,
  pascal,
  snake,
  sentence,
  underscore,
  lowerCaseFirst,
  upperCaseFirst,
} from '@tinyfe/naming-transform';

style('userName'); // camel
style('USER_NAME'); // constant
style('user-name'); // kebab
style('UserName'); // pascal
style('user_name'); // snake
style('user_Name'); // snake
style('Username'); // ''
style('My user name is Rain120'); // ''

baseCase('my user name is rain120'); // my user name is rain120
camel('username'); // username
camel('user name'); // userName

capital('username'); // Username
capital('user name'); // User Name

constant('user name'); // USER_NAME

dot('user name'); // user.name

header('user name'); // User-Name
header('userName'); // User-Name

hyphen('user name'); // user-name
hyphen('USER NAME'); // user-name
kebab('user name'); // user-name
kebab('USER NAME'); // user-name

param('user name'); // user-name
param('USER NAME'); // user-name

path('user name'); // user/name

pascal('user Name'); // UserName
pascal('user name'); // UserName

snake('user name'); // user_name

sentence('my User Name is Rain120'); // My user name is rain120

underscore('user name'); // user_name

lowerCaseFirst('UserName'); // userName
upperCaseFirst('username'); // Username

命名风格(naming-style)

camelCased 驼峰式命名

单词用首字母大写分割, 首单词首字母小写

camel('user name'); // userName

PascalCase 帕斯卡/大驼峰命名

单词用首字母大写分割, 首单词首字母大写

pascal('user name'); // UserName

kebab-cased 短横线命名(又称烤串命名) / hyphen-cased 连字号格式命名

单词用 - (中划线) 分割

hyphen('user name'); // user-name
kebab('user name'); // user-name

snake_cased 蛇型命名

单词间使用 _ (下划线) 分割, 全小写 如果所有单词都小写, 称之为 lower snake case (小蛇式), 例如get_user_name。 如果所有单词都大写, 称之为 upper snake case (大蛇式), 例如GET_USER_NAME

snake('user name'); // user_name

UnderScore_cased 下划线命名

单词间使用 _ (下划线) 分割, 不区分大小写

underscore('user name'); // user_name

CONSTANT_CASED 常量命名

单词全大写, 用 _ (下划线) 分割

constant('user name'); // USER_NAME

capital.cased

转换成首字母大写的字符串

capital('user name'); // User Name

dot.cased

转换成用 . 分隔的字母小写的字符串

dot('user name'); // user.name

header.cased

转换为用 - 分隔的首字母大写的字符串

header('user name'); // User.Name

param.cased

转换成用 - 分隔的字母小写的字符串

param('user name'); // user-name

path.cased

转换成用 / 分隔的字母小写的字符串

path('user name'); // user/name

sentence.cased

转换成用 空格 分隔的首大写,其他字母都小写的字符串

sentence('my User Name is Rain120'); // My user name is rain120

base.cased

转换成用 空格 分隔的小写字母

baseCase('my User Name is Rain120'); // my user name is rain120

Utils

lowerCaseFirst

首字母小写

lowerCaseFirst('RAIN120'); // rAIN120

upperCaseFirst

首字母大写

upperCaseFirst('rain120'); // Rain120

参考

Case Styles: Camel, Pascal, Snake, and Kebab Case

Letter Case

change-case