Add inflection

This commit is contained in:
Shogo Iwano
2014-10-09 21:13:39 +09:00
parent 2147e98170
commit 870dcd34d8
3 changed files with 71 additions and 0 deletions
+1
View File
@@ -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))
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="inflection.d.ts" />
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" ]);
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for inflection 1.5.0
// Project: https://github.com/dreamerslab/node.inflection
// Definitions by: Shogo Iwano <https://github.com/shiwano>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Inflection {
indexOf<T, T2>(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;
}