Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 18, 2024. It is now read-only.
/inflectPublic archive

Commit68d9f50

Browse files
committed
Fixes#15
1 parentbbcadd5 commit68d9f50

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

‎lib/methods.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ var inflect = module.exports;
1313
inflect.inflections=require('./inflections')
1414

1515
// Gives easy access to add inflections to this class
16-
inflect.inflect=function(inflections_function){
17-
inflections_function(inflect.inflections);
16+
inflect.inflect=function(fn){
17+
fn(inflect.inflections);
1818
};
1919

2020
// By default, _camelize_ converts strings to UpperCamelCase. If the argument to _camelize_

‎lib/util.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var u = module.exports = {
88
// [1, 2, 3].del 4 #=> [1, 2, 3]
99
del:function(arr,val){
1010
varindex=arr.indexOf(val);
11+
1112
if(index!=-1){
1213
if(index==0){
1314
returnarr.slice(1)
@@ -94,22 +95,30 @@ var u = module.exports = {
9495
varself=u.string.gsub(str,/_([a-z])/,function($){
9596
return"_"+$[1].toUpperCase();
9697
});
98+
9799
self=u.string.gsub(self,/\/([a-z])/,function($){
98100
return"/"+$[1].toUpperCase();
99101
});
102+
100103
returnself[0].toUpperCase()+self.substr(1);
101104
},
102105

103106
// Returns a copy of capitalized string
104107
//
105108
// "employee salary" #=> "Employee Salary"
106109
capitalize:function(str,spaces){
110+
if(!str.length){
111+
returnstr;
112+
}
113+
107114
varself=str.toLowerCase();
108-
if(!spaces){
115+
116+
if(!spaces){
109117
self=u.string.gsub(self,/\s([a-z])/,function($){
110118
return" "+$[1].toUpperCase();
111119
});
112120
}
121+
113122
returnself[0].toUpperCase()+self.substr(1);
114123
},
115124

@@ -120,9 +129,11 @@ var u = module.exports = {
120129
varself=u.string.gsub(str,/_([A-Z])/,function($){
121130
return"_"+$[1].toLowerCase();
122131
});
132+
123133
self=u.string.gsub(self,/\/([A-Z])/,function($){
124134
return"/"+$[1].toLowerCase();
125135
});
136+
126137
returnself[0].toLowerCase()+self.substr(1);
127138
},
128139

‎test/inflector/methods-test.js‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp