A utility to convert a string to dot.case 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 { caseDot } from '@zerodep/case-dot';
// or
const { caseDot } = require('@zerodep/case-dot');
caseDot('From sentence case'); // "from.sentence.case"
caseDot('fromCamelCase'); // "from.camel.case"
caseDot('from.dot.case'); // "from.dot.case"
caseDot('from_snake_case'); // "from.snake.case"
caseDot('FromPascalCase'); // "from.pascal.case"
caseDot(''); // ""
// with non-alphanumeric characters
caseDot('A string with some !@#$%^& characters'); // "a.string.with.some.characters"
caseDot('A #22 character long string'); // "a.22.character.long.string"
caseDot("I'm a sp3c!al $741ng"); // "i.m.a.sp3c.al.741ng"
// with accented characters
caseDot('àëîóüý Žøñç'); // "aeiouy.zonc"
// with leading special characters and numbers
caseDot('__with many --- spaces'); // "with.many.spaces"
caseDot('12 monkeys see 6 bananas'); // "monkeys.see.6.bananas"
// non-string values
caseDot({ not: 'a string' }); // throws ZeroDepError: Value is not a string