0.0.2 • Published 12 months ago

magicase v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

cover npm version npm downloads bundle License

🪄 Magicase

🔮 Magical utility for string casing

📥 Install:

# nyxi
nyxi magicase

# pnpm
pnpm add magicase

# npm
npm i magicase

# yarn
yarn add magicase

🔽 Import:

// CommonJS
const { pascalCase } = require('magicase')

// ESM
import { pascalCase } from 'magicase'

Notice: You may need to transpile the package for older environments.

🧰 Utils

🐪 pascalCase(str)

Splits the string and joins it in PascalCase convention (foo-bar ➡️ FooBar)

Remarks:

If an uppercase letter is followed by other uppercase letters (e.g., FooBAR), it is preserved.

🐫 camelCase

Splits the string and joins it in camelCase convention (foo-bar ➡️ fooBar)

🥙 kebabCase(str)

Splits the string and joins it in kebab-case convention (fooBar ➡️ foo-bar)

Remarks:

  • It does not preserve case

🐍 snakeCase

Splits the string and joins it in snake_case convention (foo-bar ➡️ foo_bar)

🔠 upperFirst(str)

Converts the first character to uppercase.

🔡 lowerFirst(str)

Converts the first character to lowercase.

🧩 splitByCase(str, splitters?)

  • 🧩 Splits the string by the provided splitters (default: '-', '_', '/', '.').
  • 🔄 Splits when there is a case change from lowercase to uppercase or uppercase to lowercase.
  • 🔢 Ignores numbers for case changes.
  • 📝 Case is preserved in the returned value.
  • ❌ This is an irreversible function since the splitters are omitted.

Development

  • 🐙 Clone this repository
  • 📥 Install latest LTS version of Node.js
  • 🧩 Enable Corepack using corepack enable
  • 📦 Install dependencies using pnpm install
  • ▶️ Run interactive tests using pnpm dev

📜 License

MIT - Made with 💞

0.0.2

12 months ago

0.0.1

12 months ago