Socket
Socket
Sign inDemoInstall

scule

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    scule

String case utils


Version published
Weekly downloads
807K
decreased by-17.02%
Maintainers
1
Install size
22.1 kB
Created
Weekly downloads
 

Changelog

Source

v1.1.0

compare changes

🚀 Enhancements

  • Export type helpers (#58)

🩹 Fixes

  • Move types filed to the top (4fd4a79)
  • pascalCase, camelCase: Lower rest of each segment (#62)

💅 Refactors

  • Simplify string variable name (abb2d2b)

📖 Documentation

  • Add missing quotation mark (#41)
  • Improve readme with code examples (21f19ba)

🏡 Chore

  • Update repo (#42)
  • Update lockfile and typescript (94bfc58)
  • Update release script (a52338f)
  • Update dependencies (3a5f1a6)
  • Add changelogen dev dependency (81365b8)

✅ Tests

  • Convert type tests to vitest syntax (#61)

🎨 Styles

  • Lint and format with prettier v3 (ba39ce6)

🤖 CI

❤️ Contributors

Readme

Source

🧵 Scule

npm version npm downloads bundle Codecov

Install

Install using npm or yarn:

npm i scule

Import:

// CommonJS
const { pascalCase } = require("scule");

// ESM
import { pascalCase } from "scule";

Notice: You may need to transpile package for legacy environments.

Utils

pascalCase(str)

Splits string and joins by PascalCase convention:

pascalCase("foo-bar_baz");
// FooBarBaz

Notice: If an uppercase letter is followed by other uppercase letters (like FooBAR), they are preserved.

camelCase

Splits string and joins by camelCase convention:

camelCase("foo-bar_baz");
// fooBarBaz

kebabCase(str)

Splits string and joins by kebab-case convention:

kebabCase("fooBar_Baz");
// foo-bar-baz

Notice: It does not preserve case.

snakeCase

Splits string and joins by snake_case convention:

snakeCase("foo-barBaz");
// foo_bar_baz

upperFirst(str)

Converts first character to upper case:

upperFirst("hello world!");
// Hello world!

lowerFirst(str)

Converts first character to lower case:

lowerFirst("Hello world!");
// hello world!

splitByCase(str, splitters?)

  • Splits string by the splitters provided (default: ['-', '_', '/', '.'])
  • Splits when case changes from lower to upper or upper to lower
  • Ignores numbers for case changes
  • Case is preserved in returned value
  • Is an irreversible function since 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

FAQs

Last updated on 15 Nov 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc