-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(schematics):entity schematics should update the state to plural #1596
Changes from 10 commits
46c246b
dbde8bc
2ceba07
166eabe
ca25fe4
672f603
ed6655d
1510211
757d04e
0b4a3a2
4eb91da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -110,6 +110,25 @@ export function capitalize(str: string): string { | |||||
return str.charAt(0).toUpperCase() + str.substr(1); | ||||||
} | ||||||
|
||||||
/** | ||||||
Returns the Pluralize form of a string | ||||||
|
||||||
```javascript | ||||||
'innerHTML'.pluralize() // 'InnerHTMLs' | ||||||
'action_name'.pluralize() // 'actionNames' | ||||||
'css-class-name'.pluralize() // 'cssClassNames' | ||||||
'regex'.capitalize() // 'regexes' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
'user'.capitalize() // 'users' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
``` | ||||||
*/ | ||||||
export function pluralize(str: string): string { | ||||||
return camelize( | ||||||
[/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map( | ||||||
(c, i) => (str = str.replace(c, `$1${'iv'[i] || ''}e`)) | ||||||
) && str + 's' | ||||||
); | ||||||
} | ||||||
|
||||||
export function group(name: string, group: string | undefined) { | ||||||
return group ? `${group}/${name}` : name; | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -110,6 +110,25 @@ export function capitalize(str: string): string { | |||||
return str.charAt(0).toUpperCase() + str.substr(1); | ||||||
} | ||||||
|
||||||
/** | ||||||
Returns the Pluralize form of a string | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
|
||||||
```javascript | ||||||
'innerHTML'.pluralize() // 'InnerHTMLs' | ||||||
'action_name'.pluralize() // 'actionNames' | ||||||
'css-class-name'.pluralize() // 'cssClassNames' | ||||||
'regex'.capitalize() // 'regexes' | ||||||
'user'.capitalize() // 'users' | ||||||
``` | ||||||
*/ | ||||||
export function pluralize(str: string): string { | ||||||
return camelize( | ||||||
[/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map( | ||||||
(c, i) => (str = str.replace(c, `$1${'iv'[i] || ''}e`)) | ||||||
) && str + 's' | ||||||
); | ||||||
} | ||||||
|
||||||
export function group(name: string, group: string | undefined) { | ||||||
return group ? `${group}/${name}` : name; | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the pluralize method instead of tacking on an
s
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done