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

case-alchemy

v1.1.2

Published

A light-weight, fast, tree-shakable library for effortless text case transformations with a touch of magic.

Downloads

29

Readme

🔮 Case-Alchemy: Transform Text Cases with Magic

npm package Downloads Issues Commitizen Friendly Semantic Release

Case-Alchemy is a light-weight, fast, and tree-shakable JavaScript library that empowers developers to effortlessly convert text between different cases. Whether you need to transform camel case to kebab case, snake case to title case, or any other case transformation, Case-Alchemy's intuitive and powerful api make it a breeze.

🌟 Features

  • 🔮 Effortless Case Transformations: Easily convert between various text cases like camel case, snake case, kebab case, and more.
  • 🔧 Custom Transformations: Create custom case transformations using our flexible API.
  • 🚀 Minimal Integration: Seamlessly integrate into your projects with minimal code.
  • Magical Alchemy: Empower your string manipulation tasks with a touch of magical alchemy.

Installation

You can install 'case-alchemy' using npm:

npm install case-alchemy
# or
yarn add case-alchemy
# or (best option 😁)
pnpm add case-alchemy

Usage

Here's a simple example of how you can use 'case-alchemy' to transform text cases:

const { TransformCase, fromCamel, toKebab } = require('case-alchemy');
// Or
//import { TransformCase, fromCamel, toKebab } from "case-alchemy";

const inputText = 'exampleText';
const camelToKebab = TransformCase(fromCamel, toKebab);
const kebabCaseText = camelToKebab(inputText);
console.log(kebabCaseText); // Output: 'example-text'

Custom transform function

import { TransformCase, fromKebab } from 'case-alchemy';
const inputText = 'example-text';
const kebabToPath = TransformCase(fromKebab, words => words.join('/'));
const pathCaseText = kebabToPath(inputText);
console.log(pathCaseText); // Output: 'example/text'

Documentation

TransformCase Function

The TransformCase function is a versatile utility provided by the case-alchemy library that enables you to seamlessly transform text between different cases. It takes two arguments: the fromFunc function that converts a string in a specific case to a string array in lower case, and the toFunc function that converts a lower case string array to a string in the desired case.

Signature

TransformCase(fromFunc: FromCaseFunction, toFunc: ToCaseFunction): (text: string) => string;

Parameters

| Param | Type | Details | | -------- | ----------------------------- | ----------------------------------- | | fromFunc | (str: string) => string[] | Conversion function for source case | | toFunc | (words: string[]) => string | Conversion function for target case |

Returns

A new function that takes a single parameter text, representing the input string in the initial case, and returns the transformed string in the desired case.

Transformation functions

| Case | From Function | To Function | Details | | -------- | -------------- | ------------ | ------------- | | camel | fromCamel | toCamel | camelCase | | kebab | fromKebab | toKebab | kebab-case | | snake | fromSnake | toSnake | snake_case | | title | fromTitle | toTitle | Title Case | | sentence | fromSentence | toSentence | Sentence case | | constant | fromConstant | toConstant | CONSTANT_CASE | | lower | fromLower | toLower | lowercase | | upper | fromUpper | toUpper | UPPERCASE |

Get Started

Get started with Case-Alchemy and unlock the art of transforming text cases like never before. Simplify your string manipulations and let the magic flow!

License

This project is licensed under the MIT License - see the LICENSE file for details.