
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@bitchcraft/ocake
Advanced tools
Object keys case converter (and collection of case string converters)
,.·——–——·.¸
,° ≡OCAKE≡ °,
| ,––––––––––.\
\¸| (OMNOMNOM)'/
``----------´
Convert the case of keys in an object (e. g. to camelCase), or simply convert the case of a string to another case.
{ camelCased: 'some value' } => { snake_cased: 'some value' }
$ yarn add @bitchcraft/ocake
$ npm install -P @bitchcraft/ocake
convertKeys(haystack: Object, replacer: (key: string) => string): Object
Creates an identical object where the keys have been converted to the desired case.
(key: string) => string. You can use one of the supplied StringConverters.import { convertKeys, StringConverters } from '@bitchcraft/ocake';
const payload = convertKeys({
userName: 'Sam Axe',
userId: 5462,
clientId: 17,
}, StringConverters.toKebabCase);
const requestBody = JSON.stringify(payload);
var convertKeys = require('@bitchcraft/ocake').convertKeys;
var toKebabCase = require('@bitchcraft/ocake').StringConverters.toKebabCase;
var payload = convertKeys({
userName: 'Sam Axe',
userId: 5462,
clientId: 17
}, StringConverters.toKebabCase);
const requestBody = JSON.stringify(payload);
Convert the case in a string to another case, e. g.
'sentence case' => 'sentenceCase'
All string converters provided by OCake currently use no-case, which converts using a common intermediary. There are no source-target-pair specific replacers. Meaning that every conversion in fact first converts to sentence case before converting to the target case, e. g. when converting to snake case: 'unknownCase' -> 'unknown case' -> 'unknown_case'. This has to be kept in mind when designing your app for roundtrip conversion. In that case you either have to be aware of the limitations or provide your own source-target specific replacers.
Known limitations are:
'someTALLMANCASEkey' -> 'some tallmancase ekey' -> 'someTallmancaseEkey' -> 'some tallmancase ekey' -> 'someTALLMANCASekey' -> …)'XMLHttpRequest' -> 'xml http request' -> 'XmlHttpRequest')'snake_case_1' -> 'snakeCase1' -> 'snake_case1')List of provided StringReplacers
| Replacer | Description |
|---|---|
toCamelCase() | alias for toLowerCamelCase |
toLowerCamelCase() | e. g. 'theCakeIsFake' |
toUpperCamelCase() | e. g. 'TheCakeIsFake' |
toKebabCase() | e. g. 'the-cake-is-fake' |
toAngryKebabCase() | e. g. 'THE-CAKE-IS-FAKE' |
toSnakeCase() | e. g. 'the_cake_is_fake' |
toAngrySnakeCase() | e. g. 'THE_CAKE_IS_FAKE' |
toSentenceCase() | e. g. the cake is fake |
toTitleCase() | e. g. 'The Cake Is Fake' |
toShoutCase() | e. g. 'THE CAKE IS FAKE' |
toTallManCase() | e. g. 'theCAKEisFAKE' |
// babel: env, stage-0, flow
import { convertKeys, StringConverters } from '@bitchcraft/ocake/src/Ocake';
import convertKeys from '@bitchcraft/ocake/src/convertKeys';
import StringConverters, { toCamelCase, … } from '@bitchcraft/ocake/src/StringConverters';
Gzipped size (non-minified) is around 19KB, with 47% of that taken up by core-js. You can check out the bundle analytics for the non-minified bundle.
Please file issues in Github
We are open for PRs. Please respect to the linting rules.
Keyconst is free software und the BSD-3-Clause (see LICENSE.md).
FAQs
Object keys case converter (and collection of case string converters)
We found that @bitchcraft/ocake 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.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.