Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
name-styles
Advanced tools
A utility for converting a string into some styles: camelCase, PascalCase, kebab-case, snake_case, _underscore__case
Author: James Fan (jamesfancy@126.com)
Source: name-styles on gitee.com
A utility to convert a string into some styles: camelCase, PascalCase, kebab-case, snake_case, _underscore_case preserving leading underscores, etc.
TypeScript supported.
npm add name-styles
yarn add name-styles
camel(s)
, camel casepascal(s)
, pascal casekebab(s)
, kebab case, alias hyphen()
snake(s)
, snake caseimport {
camel,
pascal,
kebab,
snake
} from "name-styles";
const s = "Hello Name-Styles";
camel(s);
// helloNameStyles
pascal(s);
// HelloNameStyles
kebab(s);
// hello-name-styles
snake(s);
// hello_name_styles
underscore style is similar to snake style, except that
Note that all spaces or kebabs should be transformed to underscore, and leading ones are kept.
For example:
import { snake, underscore } from "name-styles";
const s = "-hello-world by--james";
snake(s);
// hello_world_by_james
underscore(s);
// _hello_world_by__james
CONSTANT style matches C/C++ constant convention.
It support two style constant which predicate by the second parameter. The first style is like snake except all letters are upper case. Another style is like underscore except all letters are upper case. The first style is default style.
For example:
import { constant } from "name-styles";
const s = "-hello-world by--james";
constant(s);
// HELLO_WORLD_BY_JAMES
constant(s, true);
// _HELLO_WORLD_BY__JAMES
How can I use the second style in the uniform interface with only one parameters? Currying can help.
For example:
import { constant } from "name-styles";
const myConstant = s => constant(s, true);
myConverters.push(myConstant);
The string in kebab or snake style can be easily converted to sentence style
const { kebab } from "name-styles";
const s = "ThisIsASentence";
const sentence = kebab(s)
.replace(/-/g, " ")
.replace(/^./, ch => ch.toUpperCase());
// This is a sentence
FAQs
A utility for converting a string into some styles: camelCase, PascalCase, kebab-case, snake_case, _underscore__case
The npm package name-styles receives a total of 32 weekly downloads. As such, name-styles popularity was classified as not popular.
We found that name-styles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.