@@ -25,34 +25,30 @@ Checkout [Meteor Inflector](https://github.com/katrotz/meteor-inflector) from [V
2525## Installation
2626
2727Install inflection through npm
28-
29- npm install inflection
30-
28+ ``` bash
29+ npm install inflection
30+ ```
3131## API
3232
33- - inflection. pluralize( str, plural );
34- - inflection. singularize( str, singular );
35- - inflection. inflect( str, count, singular, plural );
36- - inflection. camelize( str, low_first_letter );
37- - inflection. underscore( str, all_upper_case );
38- - inflection. humanize( str, low_first_letter );
39- - inflection. capitalize( str );
40- - inflection. dasherize( str );
41- - inflection. titleize( str );
42- - inflection. demodulize( str );
43- - inflection. tableize( str );
44- - inflection. classify( str );
45- - inflection. foreign_key( str, drop_id_ubar );
46- - inflection. ordinalize( str );
47- - inflection. transform( str, arr );
33+ - [ pluralize(str, plural) ] ( #pluralizestr-plural )
34+ - [ singularize(str, singular) ] ( #singularizestr-singular )
35+ - [ inflect(str, count, singular, plural) ] ( #inflectstr-count-singular-plural )
36+ - [ camelize(str, low_first_letter) ] ( #camelizestr-low_first_letter )
37+ - [ underscore(str, all_upper_case) ] ( #underscorestr-all_upper_case )
38+ - [ humanize(str, low_first_letter) ] ( #humanizestr-low_first_letter )
39+ - [ capitalize(str) ] ( #capitalizestr )
40+ - [ dasherize(str) ] ( #dasherizestr )
41+ - [ titleize(str) ] ( #titleizestr )
42+ - [ demodulize(str) ] ( #demodulizestr )
43+ - [ tableize(str) ] ( #tableizestr )
44+ - [ classify(str) ] ( #classifystr )
45+ - [ foreign_key(str, drop_id_ubar) ] ( #foreign_keystr-drop_id_ubar )
46+ - [ ordinalize(str) ] ( #ordinalizestr )
47+ - [ transform(str, arr) ] ( #transformstr-arr )
4848
4949## Usage
5050
51- > Require the module before using
52-
53- const inflection = require( 'inflection' );
54-
55- ### inflection.pluralize( str, plural );
51+ ### pluralize(str, plural)
5652
5753This function adds pluralization support to every String object.
5854
@@ -69,15 +65,16 @@ This function adds pluralization support to every String object.
6965 desc: Overrides normal output with said String.(optional)
7066
7167#### Example code
68+ ``` js
69+ const { pluralize } = require (' inflection' );
7270
73- var inflection = require( 'inflection' );
74-
75- inflection.pluralize( 'person' ); // === 'people'
76- inflection.pluralize( 'octopus' ); // === "octopi"
77- inflection.pluralize( 'Hat' ); // === 'Hats'
78- inflection.pluralize( 'person', 'guys' ); // === 'guys'
71+ pluralize (' person' ); // === 'people'
72+ pluralize (' octopus' ); // === "octopi"
73+ pluralize (' Hat' ); // === 'Hats'
74+ pluralize (' person' , ' guys' ); // === 'guys'
75+ ```
7976
80- ### inflection. singularize( str, singular );
77+ ### singularize(str, singular)
8178
8279This function adds singularization support to every String object.
8380
@@ -94,15 +91,16 @@ This function adds singularization support to every String object.
9491 desc: Overrides normal output with said String.(optional)
9592
9693#### Example code
94+ ``` js
95+ const { singularize } = require (' inflection' );
9796
98- var inflection = require( 'inflection' );
97+ singularize (' people' ); // === 'person'
98+ singularize (' octopi' ); // === "octopus"
99+ singularize (' Hats' ); // === 'Hat'
100+ singularize (' guys' , ' person' ); // === 'person'
101+ ```
99102
100- inflection.singularize( 'people' ); // === 'person'
101- inflection.singularize( 'octopi' ); // === "octopus"
102- inflection.singularize( 'Hats' ); // === 'Hat'
103- inflection.singularize( 'guys', 'person' ); // === 'person'
104-
105- ### inflection.inflect( str, count, singular, plural );
103+ ### inflect(str, count, singular, plural)
106104
107105This function will pluralize or singularlize a String appropriately based on an integer value.
108106
@@ -129,19 +127,20 @@ This function will pluralize or singularlize a String appropriately based on an
129127 desc: Overrides normal output with said String.(optional)
130128
131129#### Example code
130+ ``` js
131+ const { inflect } = require (' inflection' );
132132
133- var inflection = require( 'inflection' );
134-
135- inflection.inflect( 'people', 1 ); // === 'person'
136- inflection.inflect( 'octopi', 1 ); // === 'octopus'
137- inflection.inflect( 'Hats', 1 ); // === 'Hat'
138- inflection.inflect( 'guys', 1 , 'person' ); // === 'person'
139- inflection.inflect( 'person', 2 ); // === 'people'
140- inflection.inflect( 'octopus', 2 ); // === 'octopi'
141- inflection.inflect( 'Hat', 2 ); // === 'Hats'
142- inflection.inflect( 'person', 2, null, 'guys' ); // === 'guys'
133+ inflect (' people' , 1 ); // === 'person'
134+ inflect (' octopi' , 1 ); // === 'octopus'
135+ inflect (' Hats' , 1 ); // === 'Hat'
136+ inflect (' guys' , 1 , ' person' ); // === 'person'
137+ inflect (' person' , 2 ); // === 'people'
138+ inflect (' octopus' , 2 ); // === 'octopi'
139+ inflect (' Hat' , 2 ); // === 'Hats'
140+ inflect (' person' , 2 , null , ' guys' ); // === 'guys'
141+ ```
143142
144- ### inflection. camelize( str, low_first_letter );
143+ ### camelize(str, low_first_letter)
145144
146145This function transforms String object from underscore to camelcase.
147146
@@ -158,13 +157,14 @@ This function transforms String object from underscore to camelcase.
158157 desc: Default is to capitalize the first letter of the results. Passing true will lowercase it. (optional)
159158
160159#### Example code
160+ ``` js
161+ const { camelize } = require (' inflection' );
161162
162- var inflection = require( 'inflection' );
163-
164- inflection.camelize( 'message_properties' ); // === 'MessageProperties'
165- inflection.camelize( 'message_properties', true ); // === 'messageProperties'
163+ camelize (' message_properties' ); // === 'MessageProperties'
164+ camelize (' message_properties' , true ); // === 'messageProperties'
165+ ```
166166
167- ### inflection. underscore( str, all_upper_case );
167+ ### underscore(str, all_upper_case)
168168
169169This function transforms String object from camelcase to underscore.
170170
@@ -181,15 +181,16 @@ This function transforms String object from camelcase to underscore.
181181 desc: Default is to lowercase and add underscore prefix
182182
183183#### Example code
184+ ``` js
185+ const { underscore } = require (' inflection' );
184186
185- var inflection = require( 'inflection' );
187+ underscore (' MessageProperties' ); // === 'message_properties'
188+ underscore (' messageProperties' ); // === 'message_properties'
189+ underscore (' MP' ); // === 'm_p'
190+ underscore (' MP' , true ); // === 'MP'
191+ ```
186192
187- inflection.underscore( 'MessageProperties' ); // === 'message_properties'
188- inflection.underscore( 'messageProperties' ); // === 'message_properties'
189- inflection.underscore( 'MP' ); // === 'm_p'
190- inflection.underscore( 'MP', true ); // === 'MP'
191-
192- ### inflection.humanize( str, low_first_letter );
193+ ### humanize(str, low_first_letter)
193194
194195This function adds humanize support to every String object.
195196
@@ -206,13 +207,14 @@ This function adds humanize support to every String object.
206207 desc: Default is to capitalize the first letter of the results. Passing true will lowercase it. (optional)
207208
208209#### Example code
210+ ``` js
211+ const { humanize } = require (' inflection' );
209212
210- var inflection = require( 'inflection' );
211-
212- inflection.humanize( 'message_properties' ); // === 'Message properties'
213- inflection.humanize( 'message_properties', true ); // === 'message properties'
213+ humanize (' message_properties' ); // === 'Message properties'
214+ humanize (' message_properties' , true ); // === 'message properties'
215+ ```
214216
215- ### inflection. capitalize( str );
217+ ### capitalize(str)
216218
217219This function adds capitalization support to every String object.
218220
@@ -224,13 +226,14 @@ This function adds capitalization support to every String object.
224226 desc: The subject string.
225227
226228#### Example code
229+ ``` js
230+ const { capitalize } = require (' inflection' );
227231
228- var inflection = require( 'inflection' );
232+ capitalize (' message_properties' ); // === 'Message_properties'
233+ capitalize (' message properties' , true ); // === 'Message properties'
234+ ```
229235
230- inflection.capitalize( 'message_properties' ); // === 'Message_properties'
231- inflection.capitalize( 'message properties', true ); // === 'Message properties'
232-
233- ### inflection.dasherize( str );
236+ ### dasherize(str)
234237
235238This function replaces underscores with dashes in the string.
236239
@@ -242,13 +245,14 @@ This function replaces underscores with dashes in the string.
242245 desc: The subject string.
243246
244247#### Example code
248+ ``` js
249+ const { dasherize } = require (' inflection' );
245250
246- var inflection = require( 'inflection' );
247-
248- inflection.dasherize( 'message_properties' ); // === 'message-properties'
249- inflection.dasherize( 'Message Properties' ); // === 'Message-Properties'
251+ dasherize (' message_properties' ); // === 'message-properties'
252+ dasherize (' Message Properties' ); // === 'Message-Properties'
253+ ```
250254
251- ### inflection. titleize( str );
255+ ### titleize(str)
252256
253257This function adds titleize support to every String object.
254258
@@ -260,13 +264,14 @@ This function adds titleize support to every String object.
260264 desc: The subject string.
261265
262266#### Example code
267+ ``` js
268+ const { titleize } = require (' inflection' );
263269
264- var inflection = require( 'inflection' );
265-
266- inflection.titleize( 'message_properties' ); // === 'Message Properties'
267- inflection.titleize( 'message properties to keep' ); // === 'Message Properties to Keep'
270+ titleize (' message_properties' ); // === 'Message Properties'
271+ titleize (' message properties to keep' ); // === 'Message Properties to Keep'
272+ ```
268273
269- ### inflection. demodulize( str );
274+ ### demodulize(str)
270275
271276This function adds demodulize support to every String object.
272277
@@ -278,12 +283,13 @@ This function adds demodulize support to every String object.
278283 desc: The subject string.
279284
280285#### Example code
286+ ``` js
287+ const { demodulize } = require (' inflection' );
281288
282- var inflection = require( 'inflection' );
289+ demodulize (' Message::Bus::Properties' ); // === 'Properties'
290+ ```
283291
284- inflection.demodulize( 'Message::Bus::Properties' ); // === 'Properties'
285-
286- ### inflection.tableize( str );
292+ ### tableize(str)
287293
288294This function adds tableize support to every String object.
289295
@@ -295,12 +301,13 @@ This function adds tableize support to every String object.
295301 desc: The subject string.
296302
297303#### Example code
304+ ``` js
305+ const { tableize } = require (' inflection' );
298306
299- var inflection = require( 'inflection' );
300-
301- inflection.tableize( 'MessageBusProperty' ); // === 'message_bus_properties'
307+ tableize (' MessageBusProperty' ); // === 'message_bus_properties'
308+ ```
302309
303- ### inflection. classify( str );
310+ ### classify(str)
304311
305312This function adds classification support to every String object.
306313
@@ -312,12 +319,13 @@ This function adds classification support to every String object.
312319 desc: The subject string.
313320
314321#### Example code
322+ ``` js
323+ const { classify } = require (' inflection' );
315324
316- var inflection = require( 'inflection' );
325+ classify (' message_bus_properties' ); // === 'MessageBusProperty'
326+ ```
317327
318- inflection.classify( 'message_bus_properties' ); // === 'MessageBusProperty'
319-
320- ### inflection.foreign_key( str, drop_id_ubar );
328+ ### foreign_key(str, drop_id_ubar)
321329
322330This function adds foreign key support to every String object.
323331
@@ -334,13 +342,14 @@ This function adds foreign key support to every String object.
334342 desc: Default is to seperate id with an underbar at the end of the class name, you can pass true to skip it.(optional)
335343
336344#### Example code
345+ ``` js
346+ const { foreign_key } = require (' inflection' );
337347
338- var inflection = require( 'inflection' );
339-
340- inflection.foreign_key( 'MessageBusProperty' ); // === 'message_bus_property_id'
341- inflection.foreign_key( 'MessageBusProperty', true ); // === 'message_bus_propertyid'
348+ foreign_key (' MessageBusProperty' ); // === 'message_bus_property_id'
349+ foreign_key (' MessageBusProperty' , true ); // === 'message_bus_propertyid'
350+ ```
342351
343- ### inflection. ordinalize( str );
352+ ### ordinalize(str)
344353
345354This function adds ordinalize support to every String object.
346355
@@ -352,12 +361,13 @@ This function adds ordinalize support to every String object.
352361 desc: The subject string.
353362
354363#### Example code
364+ ``` js
365+ const { ordinalize } = require (' inflection' );
355366
356- var inflection = require( 'inflection' );
367+ ordinalize (' the 1 pitch' ); // === 'the 1st pitch'
368+ ```
357369
358- inflection.ordinalize( 'the 1 pitch' ); // === 'the 1st pitch'
359-
360- ### inflection.transform( str, arr );
370+ ### transform(str, arr)
361371
362372This function performs multiple inflection methods on a string.
363373
@@ -374,10 +384,11 @@ This function performs multiple inflection methods on a string.
374384 desc: An array of inflection methods.
375385
376386#### Example code
387+ ``` js
388+ const { transform } = require (' inflection' );
377389
378- var inflection = require( 'inflection' );
379-
380- inflection.transform( 'all job', [ 'pluralize', 'capitalize', 'dasherize' ]); // === 'All-jobs'
390+ transform (' all job' , [ ' pluralize' , ' capitalize' , ' dasherize' ]); // === 'All-jobs'
391+ ```
381392
382393## Credit
383394
0 commit comments