Skip to content
This repository was archived by the owner on Oct 27, 2024. It is now read-only.

Repository files navigation

fleck is a functional styled library for string inflection that doesn't pollute String.prototype.

Basic Use

All the inflections are stored inside fleck. They are:

// Capitalsfleck.capitalize('acme')=='Acme'// CamelCase and camelCasefleck.camelize('border-radius')=='borderRadius'fleck.camelize('border-radius',true)=='BorderRadius'// alias for upperCamelizefleck.upperCamelize('we-the-people')=='WeThePeople'// Changes underscores and spaces into dashesfleck.dasherize('we_the_people')=='we-the-people'// Underscore// Converts camelCase, CamelCase, dash-es, and Name::Spaced to underscoresfleck.underscore("camelCase")=='camel_case'fleck.underscore("CamelCase")=='camel_case'fleck.underscore("dash-es")=='dash_es'fleck.underscore("Name::Spaced")=='name_spaced'// Plurals and Singular, even strange onesfleck.pluralize('dog')=='dogs'fleck.pluralize('person')=='people'fleck.pluralize('sheep')=='sheep'fleck.singularize('dogs')=='dog'fleck.singularize('people')=='person'// Whitespace strippingfleck.strip(' hello! ')=='hello!'// Ordinalsfleck.ordinalize(4)=="4th"fleck.ordinalize("13")=="13th"fleck.ordinalize("122")=="122nd"

Functional Programing

fleck doesn't contain any unpredictable javascript object orientation. Feel free to combine with other functional libraries at will; no new anonymous functions, no silly binds:

// underscore.js_.each(['dog','cat','mouse'],fleck.pluralize)==["dogs","cats","mice"]// jQuery.js$.ajax({url:'/data/sync_from_server/new/uncountablewords',success: fleck.uncountable})

Chaining

Inflections can be chained using fleck.inflect

fleck.inflect(' posts','strip','singularize','capitalize')=='Post'

About

functional-style string inflections

Resources

Stars

59 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages