diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4ddfab6e4..99f53330b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -144,6 +144,7 @@ All definitions files include a header with the author and editors, so at some p * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) * [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Imagemagick](http://github.com/rsms/node-imagemagick) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) +* [inflection](https://github.com/dreamerslab/node.inflection) (by [Shogo Iwano](https://github.com/shiwano)) * [insight](https://github.com/yeoman/insight) (by [vvakame](https://github.com/vvakame)) * [interact.js](http://github.com/taye/interact.js) (by [Douglas Eichelberger](https://github.com/dduugg)) * [Ion.RangeSlider](https://github.com/IonDen/ion.rangeSlider) (by [Douglas Eichelberger](https://github.com/dduugg)) diff --git a/inflection/inflection-tests.ts b/inflection/inflection-tests.ts new file mode 100644 index 000000000..b4f758ef3 --- /dev/null +++ b/inflection/inflection-tests.ts @@ -0,0 +1,42 @@ +/// + +import inflection = require("inflection"); + +inflection.indexOf(["hi", "there"], "guys"); + +inflection.pluralize("person"); +inflection.pluralize("person", "guys"); + +inflection.singularize("Hats"); +inflection.singularize("guys", "person"); + +inflection.inflect("Hats", 1); +inflection.inflect("guys", 1, "person"); + +inflection.camelize("message_properties"); +inflection.camelize("message_properties", true); + +inflection.underscore("MP"); +inflection.underscore("MP", true); + +inflection.humanize("message_properties"); +inflection.humanize("message_properties", true); + +inflection.capitalize("message_properties"); + +inflection.dasherize("message_properties"); + +inflection.titleize("message_properties"); + +inflection.demodulize("Message::Bus::Properties"); + +inflection.tableize("MessageBusProperty"); + +inflection.classify("message_bus_properties"); + +inflection.foreign_key("MessageBusProperty"); +inflection.foreign_key("MessageBusProperty", true); + +inflection.ordinalize("the 1 pitch"); + +inflection.transform("all job", [ "pluralize", "capitalize", "dasherize" ]); diff --git a/inflection/inflection.d.ts b/inflection/inflection.d.ts new file mode 100644 index 000000000..528f48f8f --- /dev/null +++ b/inflection/inflection.d.ts @@ -0,0 +1,28 @@ +// Type definitions for inflection 1.5.0 +// Project: https://github.com/dreamerslab/node.inflection +// Definitions by: Shogo Iwano +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Inflection { + indexOf(arr: T[], item: T2, from_index?: number, compare_func?: (arr_item: T, item: T2) => boolean): number; + pluralize(str: string, plural?: string): string; + singularize(str: string, singular?: string): string; + inflect(str: string, count: number, singular?: string, plural?: string): string; + camelize(str: string, low_first_letter?: boolean): string; + underscore(str: string, all_upper_case?: boolean): string; + humanize(str: string, low_first_letter?: boolean): string; + capitalize(str: string): string; + dasherize(str: string): string; + titleize(str: string): string; + demodulize(str: string): string; + tableize(str: string): string; + classify(str: string): string; + foreign_key(str: string, drop_id_ubar?: boolean): string; + ordinalize(str: string): string; + transform(str: string, arr: string[]): string; +} + +declare module "inflection" { + var inflection: Inflection; + export = inflection; +}