All Projects â†’ nbubna â†’ Case

nbubna / Case

Licence: mit
String case utitility: convert, identify, flip, extend

Programming Languages

javascript
184084 projects - #8 most used programming language
pascal
1382 projects
type
21 projects

Projects that are alternatives of or similar to Case

Dart Basic Utils
A dart package for many helper methods fitting common situations
Stars: ✭ 153 (-35.44%)
Mutual labels:  string
Libchef
🍀 c++ standalone header-only basic library. || c++åĪī文äŧķåŪžįŽ°æ— įŽŽäļ‰æ–đäūčĩ–埚įĄ€åš“
Stars: ✭ 178 (-24.89%)
Mutual labels:  string
Codejam
Set of handy reusable .NET components that can simplify your daily work and save your time when you copy and paste your favorite helper methods and classes from one project to another
Stars: ✭ 217 (-8.44%)
Mutual labels:  string
String Inflection
underscore -> UPCASE -> CamelCase conversion of names
Stars: ✭ 157 (-33.76%)
Mutual labels:  string
Slither.io Clone
Learn how to make Slither.io with JavaScript and Phaser! This game clones all the core features of Slither.io, including mouse-following controls, snake collisions, food, snake growth, eyes, and more. Progress through each part of the source code with our Slither.io tutorial series.
Stars: ✭ 168 (-29.11%)
Mutual labels:  snake
Str
A fast, solid and strong typed string manipulation library with multibyte support
Stars: ✭ 199 (-16.03%)
Mutual labels:  string
Ssf
📝 Spreadsheet Number Formatter
Stars: ✭ 139 (-41.35%)
Mutual labels:  string
Pupa
Simple micro templating
Stars: ✭ 231 (-2.53%)
Mutual labels:  string
Strman
🏗A Javascript string manipulation library.
Stars: ✭ 2,021 (+752.74%)
Mutual labels:  string
Blitz
Android Library: Set self-updating string with relative time in TextView (e.g. 5 minutes ago)
Stars: ✭ 217 (-8.44%)
Mutual labels:  string
Androidlibrary
Android library to reveal or obfuscate strings and assets at runtime
Stars: ✭ 162 (-31.65%)
Mutual labels:  string
Algo Tree
Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
Stars: ✭ 166 (-29.96%)
Mutual labels:  string
Util
A collection of useful utility functions
Stars: ✭ 201 (-15.19%)
Mutual labels:  string
Dotnet Console Games
Game examples implemented in .NET console applications primarily for educational purposes.
Stars: ✭ 157 (-33.76%)
Mutual labels:  snake
Php To String
Cast any php value into a string
Stars: ✭ 219 (-7.59%)
Mutual labels:  string
Sharedfonttool
3DS SharedFontTool
Stars: ✭ 140 (-40.93%)
Mutual labels:  snake
Printj
📜 sprintf for JS
Stars: ✭ 182 (-23.21%)
Mutual labels:  string
Number To Words
Number to string standalone PHP library with i18n. Drivers for numbers and currency included.
Stars: ✭ 234 (-1.27%)
Mutual labels:  string
Superstring.py
A fast and memory-optimized string library for heavy-text manipulation in Python
Stars: ✭ 231 (-2.53%)
Mutual labels:  string
Snek
🐍 ‎ A terminal-based Snake implementation written in JavaScript.
Stars: ✭ 210 (-11.39%)
Mutual labels:  snake

Case: An extensible utility to convert, identify, and flip string case.

Download: Case.min.js or Case.js
NPM: npm install case (little 'c' due to NPM restrictions)
NuGet: Install-Package Case

Build Status NPM version NPM

Documentation

Each of the following functions will first "undo" previous case manipulations before applying the desired case to the given string.

Foundations

Case.upper('foo_bar')     -> 'FOO BAR'
Case.lower('fooBar')      -> 'foo bar'
Case.capital('foo_v_bar') -> 'Foo V Bar'

Code Helpers

Case.snake('Foo bar!')   -> 'foo_bar'
Case.pascal('foo.bar')   -> 'FooBar'
Case.camel('foo, bar')   -> 'fooBar'
Case.kebab('Foo? Bar.')  -> 'foo-bar'
Case.header('fooBar=')   -> 'Foo-Bar'
Case.constant('Foo-Bar') -> 'FOO_BAR'

UI Helpers

Case.title('foo v. bar')                    -> 'Foo v. Bar'
Case.sentence('"foo!" said bar', ['Bar'])   -> '"Foo!" said Bar'
Case.sentence('the 12 oz. can', null, ['oz'])   -> 'The 12 oz. can'

Case.sentence(str, names, abbreviations) accepts an array of proper names that should be capitalized, regardless of location in the sentence. This function is specialized, but useful when dealing with input generated with capslock on (i.e. everything my grandma types). It can also accept a list of abbreviations (words that may end in a period but aren't meant to end a sentence).

Custom Casing

Case.lower('FOO-BAR', '.')                  -> 'foo.bar'
Case.upper('Foo? Bar.', '__')               -> 'FOO__BAR'
Case.capital('fooBar', ' + ')               -> 'Foo + Bar'

Case.lower("Don't keep 'em!", "/", true)    -> 'dont/keep/em'
Case.capital("'ello, world.", null, true)   -> 'Ello, World.'

Case.upper, Case.lower, and Case.capital accept an optional "fill" value that will replace any characters which are not letters and numbers. All three also accept a third optional boolean argument indicating if apostrophes are to be stripped out or left in. For example, programmatic case changes (snake, kebab, pascal, camel, constant) are best without apostrophes, but user-facing ones (title, sentence) do not want "don't" turned into "Dont".

Extending Case

Case.type('bang', function(s) {
    return Case.upper(s, '!')+'!';
});
Case.bang('bang')       -> 'BANG!'
Case.of('TEST!THIS!')   -> 'bang'

Case.type(name, fn): extends Case, creating a new function on Case and adding Case.of support automatically.

Utilities

Case.of('foo')          -> 'lower'
Case.of('foo_bar')      -> 'snake'
Case.of('Foo v Bar')    -> 'title'
Case.of('foo_ Bar')     -> undefined

Case.of('Hello there, Bob!', ['Bob']) -> 'sentence'

Case.flip('FlipMe')     -> 'fLIPmE'
Case.flip('TEST THIS!') -> 'test this!'

Case.random('Hello!')   -> 'hElLO!'
  • Case.of(str[, names]): identifies the case of a string, returns undefined if it doesn't match a known type
  • Case.flip(str): reverses the case of letters, no other changes
  • Case.random(str): randomizes the case of letters, no other changes

Release History

  • 2013-06-10 v1.0.0 (public, initial)
  • 2013-06-20 v1.0.1 (regex improvements)
  • 2013-08-23 v1.0.3 (better support for Node, Component and AMD)
  • 2014-10-24 v1.1.2 (regexps used are now extensible and support more latin diacritics)
  • 2015-01-27 v1.2.0 (deprecate squish in favor of pascal)
  • 2015-01-28 v1.2.1 (fix UMD regression)
  • 2015-10-27 v1.3.0 (Case.kebab and Case.random)
  • 2015-12-02 v1.3.2 (fix title case when small word is first or last)
  • 2016-02-01 v1.3.3 (Case.of('foo') to return lower, not snake)
  • 2016-02-07 v1.4.0 (fix apostrophe handling)
  • 2016-02-08 v1.4.1 (fix swallowed prefix/suffix on lone words)
  • 2016-11-11 v1.4.2 (add typings for TypeScript support)
  • 2017-03-09 v1.5.2 (add Header-Case and expose noApostrophes option for upper/lower/capital fns)
  • 2017-07-11 v1.5.3 (Case.of and to[Type]Case functions should accept extra arguments, like the rest)
  • 2017-10-23 v1.5.4 (Shift order of Case.of tests to prioritize 'capital' over 'header')
  • 2018-05-04 v1.5.5 (Fix issue #26, corner case of bad "decamelizing" of string w/number after caps)
  • 2018-11-15 v1.6.0 (PR #29, support 'abbreviations' argument for Case.sentence to avoid incorrect sentence ends)
  • 2019-01-11 v1.6.1 (PR #30, update typings to include 'abbreviations' argument for Case.sentence)
  • 2019-07-26 v1.6.2 (PR #31, allow importing as default)
  • 2020-03-24 v1.6.3 (PR #33, update license structure in package.json for automated checkers)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].