<!--- custom <introduction> --->
A library for consistently representing identifiers, usually in a code generation setting.
<!--- end <introduction> --->
<!--- custom <purpose> --->
The purpose of the library is to have a standard way of generating an object, an Id, that can be used in any of a variety of casing contexts.
<!--- end <purpose> --->
<!--- custom <examples> --->
For example, suppose you are writing a code generator that has a need for a single id with multiple representations. The following representations are covered:
- snake case: words are all lower case with underscores (_how\_now\_brown\cow)
- emacs: words are all lower with hyphens (how-now-brown-cow)
- shout: words are all upper case with underscores (_HOW\_NOW\_BROWN\COW)
- camel: words are joined with each word capitalized excluding the first (howNowBrownCow)
- capCamel: words are joined with all words capitalized (HowNowBrownCow)
- title: All words capitalized and joined with spaces (How Now Brown Cow)
- squish: Lower case with no hypens or underscores (hownowbrowncow)
- abbrev: The abbreviation in lower case (hnbc)
The default constructor requires the identifier to be snake case:
var id = new Id('how_now_brown_cow'); print(id); // => howNowBrownCow print(id.snake); // => how_now_brown_cow print(id.emacs); // => how-now-brown-cow print(id.shout); // => HOW_NOW_BROWN_COW print(id.camel); // => howNowBrownCow print(id.capCamel); // => HowNowBrownCow print(id.title); // => How Now Brown Cow print(id.squish); // => hownowbrowncow print(id.abbrev); // => hnbc
An library function accepts either snake or any camel and returns a new Id:
var id = idFromString('testName');
<!--- end <examples> --->
<!--- custom <todos> ---> <!--- end <todos> --->
Support for consistent use of identifiers. Identifiers are words used to create things like class names, variable names, function names, etc. Because different outputs will want different case conventions for different contexts, using the Id class allows a simple consistent input format (snake case) to be combined with the appropriate conventions (usually via templates) to produce consistent correct naming. Most ebisu entities are named (Libraries, Parts, Classes, etc).