A utility to convert a string to PascalCase that also strips out non-alphanumeric characters and any leading numeric characters.
Full documentation is available at the zerodep.app page.
All @zerodep packages support both ESM and CJS.
import { casePascal } from '@zerodep/case-pascal';
// or
const { casePascal } = require('@zerodep/case-pascal');
casePascal('From sentence case'); // "FromSentenceCase"
casePascal('from-kebab-case'); // "FromKebabCase"
casePascal('from.dot.case'); // "FromDotCase"
casePascal('from_snake_case'); // "FromSnakeCase"
casePascal('FromPascalCase'); // "FromPascalCase"
casePascal(''); // ""
// with non-alphanumeric characters
casePascal('A string with some !@#$%^& characters'); // "AStringWithSomeCharacters"
casePascal('A #22 character long string'); // "A22CharacterLongString"
casePascal("I'm a sp3c!al $741ng"); // "IMASp3cAl741ng"
// with accented characters
casePascal('àëîóüý Žøñç'); // "AeiouyZonc"
// with leading special characters and numbers
casePascal('__with many --- spaces'); // "WithManySpaces"
casePascal('12 monkeys see 6 bananas'); // "MonkeysSee6Bananas"
// non-string values
casePascal({ not: 'a string' }); // throws ZeroDepError: Value is not a string