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-converters

v4.1.0

Published

Change case functions for all cases in TypeScript and JavaScript. Combined version of all [`case-converters`](https://github.com/cvchauhan/case-converter) methods, so you do not need to install them separately. ESM and CJS bundles are included, also bac

Downloads

407

Readme

case-converters

Change case functions for all cases in TypeScript and JavaScript. Combined version of all case-converters methods, so you do not need to install them separately. ESM and CJS bundles are included, also backwards compatible with [email protected].

[email protected] which can be used to access all methods. Added Object convertore for camel, constan and capital you can use this 3 methods to convert object key in case: objToCamel(obj or array) objToConstant(obj or array) objToCapital(obj or array)

Usage

npm install --save case-converters

javascript


const { camel, upper } from 'case-converters';
camel('test string'); // testString
upper('test string'); // TEST STRING

Browser / ESM

import { Case } from 'case-converters';
const camel = Case.camel('test string'); // testString
const upper = Case.upper('test string'); // TEST STRING
const input = [
      { 'user_name': 'Alice' },
      { 'user_name': 'Bob' }
    ]
Case.objToCamel(input)
const { 
  objToCamel, 
  objToCapital, 
  objToConstant,
  objToNot,
  objToPascal,
  objToPath,
  objToSentence,
  objToSnake,
  objToTrain,
  objToKebap,
  objToSponge,
  objToSwap,
  objToTitle,
  objToUpper,
  objToLower
} = require('case-converters');
objToCamel(input)
/* 
    [
      { userName: 'Alice' },
      { userName: 'Bob' }
    ]
*/
objToCapital(input)
/* 
    [
      { Username: 'Alice' },
      { Username: 'Bob' }
    ]
*/
objToConstant(input)
/* 
    [
      { USERNAME: 'Alice' },
      { USERNAME: 'Bob' }
    ]
*/

import { camel, upper, ... } from 'case-converters';
const camel = camel('test string'); // testString
const upper = upper('test string'); // TEST STRING

Node.js

const { Case } = require("case-converters");
const camel = Case.camel("foo-bar"); // fooBar
const snake = Case.snake("fooBar"); // foo_bar

const { camel, snake } = require("case-converters");
const camel = camel("foo-bar"); // fooBar
const snake = snake("fooBar"); // foo_bar

Links

  • Original project: https://github.com/cvchauhan/case-converter

Methods

Class based usage

import { Case } from "case-converters";

const str = "test string";

camel = Case.camel(str); // testString
capital = Case.capital(str); // Test String
constant = Case.constant(str); // TEST_STRING
dot = Case.dot(str); // test.string
no = Case.no(str); // test string
pascal = Case.pascal(str); // TestString
path = Case.path(str); // test/string
sentence = Case.sentence(str); // Test string
snake = Case.snake(str); // test_string
train = Case.train(str); // Test-String
kebab = Case.kebab(str); // test-string
sponge = Case.sponge(str); // TeSt StRiNg
swapCase = Case.swap(str); // TEST STRING
title = Case.title(str); // Test String
uppper = Case.upper(str); // TEST STRING
localeUpper = Case.localeUpper(str, "en"); // TEST STRING
lower = Case.lower(str); // test string
localeLower = Case.localeLower(str, "en"); // test string
lowerFirst = Case.lowerFirst(str); // test string
upperFirst = Case.upperFirst(str); // Test string
isUpper = Case.isUpper(str); // false
isLower = Case.isLower(str); // true

Function based usage

import { camel, upper, ... } from 'case-converters';

const str = 'test string';

camel       = camel(str);               // testString
capital     = capital(str);             // Test String
constant    = constant(str);            // TEST_STRING
dot         = dot(str);                 // test.string
no          = no(str);                  // test string
pascal      = pascal(str);              // TestString
path        = path(str);                // test/string
sentence    = sentence(str);            // Test string
snake       = snake(str);               // test_string
train       = train(str);               // Test-String
kebab       = kebab(str);               // test-string
sponge      = sponge(str);              // TeSt StRiNg
swap        = swap(str);                // TEST STRING
title       = title(str);               // Test String
uppper      = upper(str);               // TEST STRING
localeUpper = localeUpper(str, 'en');   // TEST STRING
lower       = lower(str);               // test string
localeLower = localeLower(str, 'en');   // test string
lowerFirst  = lowerFirst(str);          // test string
upperFirst  = upperFirst(str);          // Test string
isUpper     = isUpper(str);             // false
isLower     = isLower(str);             // true

Meta