Skip to content

Commit

Permalink
CamelCast to kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
peroman86 committed Jul 18, 2018
1 parent 8a726b1 commit 36f06f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/inflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,26 @@
},


/**
* This function adds kebabize support to every String object.
* @public
* @function
* @param {String} str The subject string.
* @returns {String} Return camel cased words into kebab-case form.
* @example
*
* var inflection = require( 'inflection' );
*
* inflection.kebabize( 'MessageBusProperty' ); // === 'message-bus-properties'
*/
kebabize : function ( str ){
str = inflector.underscore( str );
str = inflector.dasherize( str );

return str;
},



/**
* This function adds classification support to every String object.
Expand Down
7 changes: 7 additions & 0 deletions test/inflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ describe( 'test .tableize', function (){
});
});

describe( 'test .kebabize', function (){
it( 'should kebabize the given word', function (){
inflection.kebabize( 'people' ).should.equal( 'people' );
inflection.kebabize( 'MessageBusProperty' ).should.equal( 'message-bus-property' );
});
});

describe( 'test .classify', function (){
it( 'should classify the given word', function (){
inflection.classify( 'message_bus_properties' ).should.equal( 'MessageBusProperty' );
Expand Down

0 comments on commit 36f06f2

Please sign in to comment.