Skip to content

Commit

Permalink
[DOC beta] Update (at)ember/string documentation for imported utils i…
Browse files Browse the repository at this point in the history
…nstead of String.prototype extensions
  • Loading branch information
locks committed Jan 25, 2019
1 parent ec85163 commit 37d69f1
Showing 1 changed file with 50 additions and 38 deletions.
88 changes: 50 additions & 38 deletions packages/@ember/string/index.ts
Expand Up @@ -149,10 +149,12 @@ export function w(str: string): string[] {
Converts a camelized string into all lower case separated by underscores.
```javascript
'innerHTML'.decamelize(); // 'inner_html'
'action_name'.decamelize(); // 'action_name'
'css-class-name'.decamelize(); // 'css-class-name'
'my favorite items'.decamelize(); // 'my favorite items'
import { decamelize } from '@ember/string';
decamelize('innerHTML'); // 'inner_html'
decamelize('action_name'); // 'action_name'
decamelize('css-class-name'); // 'css-class-name'
decamelize('my favorite items'); // 'my favorite items'
```
@method decamelize
Expand All @@ -168,11 +170,13 @@ export function decamelize(str: string): string {
Replaces underscores, spaces, or camelCase with dashes.
```javascript
'innerHTML'.dasherize(); // 'inner-html'
'action_name'.dasherize(); // 'action-name'
'css-class-name'.dasherize(); // 'css-class-name'
'my favorite items'.dasherize(); // 'my-favorite-items'
'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice'
import { dasherize } from '@ember/string';
dasherize('innerHTML'); // 'inner-html'
dasherize('action_name'); // 'action-name'
dasherize('css-class-name'); // 'css-class-name'
dasherize('my favorite items'); // 'my-favorite-items'
dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
```
@method dasherize
Expand All @@ -188,12 +192,14 @@ export function dasherize(str: string): string {
Returns the lowerCamelCase form of a string.
```javascript
'innerHTML'.camelize(); // 'innerHTML'
'action_name'.camelize(); // 'actionName'
'css-class-name'.camelize(); // 'cssClassName'
'my favorite items'.camelize(); // 'myFavoriteItems'
'My Favorite Items'.camelize(); // 'myFavoriteItems'
'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice'
import { camelize } from '@ember/string';
camelize('innerHTML'); // 'innerHTML'
camelize('action_name'); // 'actionName'
camelize('css-class-name'); // 'cssClassName'
camelize('my favorite items'); // 'myFavoriteItems'
camelize('My Favorite Items'); // 'myFavoriteItems'
camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
```
@method camelize
Expand All @@ -209,11 +215,13 @@ export function camelize(str: string): string {
Returns the UpperCamelCase form of a string.
```javascript
'innerHTML'.classify(); // 'InnerHTML'
'action_name'.classify(); // 'ActionName'
'css-class-name'.classify(); // 'CssClassName'
'my favorite items'.classify(); // 'MyFavoriteItems'
'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice'
import { classify } from '@ember/string';
classify('innerHTML'); // 'InnerHTML'
classify('action_name'); // 'ActionName'
classify('css-class-name'); // 'CssClassName'
classify('my favorite items'); // 'MyFavoriteItems'
classify('private-docs/owner-invoice'); // 'PrivateDocs/OwnerInvoice'
```
@method classify
Expand All @@ -230,11 +238,13 @@ export function classify(str: string): string {
form of a string.
```javascript
'innerHTML'.underscore(); // 'inner_html'
'action_name'.underscore(); // 'action_name'
'css-class-name'.underscore(); // 'css_class_name'
'my favorite items'.underscore(); // 'my_favorite_items'
'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice'
import { underscore } from '@ember/string';
underscore('innerHTML'); // 'inner_html'
underscore('action_name'); // 'action_name'
underscore('css-class-name'); // 'css_class_name'
underscore('my favorite items'); // 'my_favorite_items'
underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
```
@method underscore
Expand All @@ -250,11 +260,13 @@ export function underscore(str: string): string {
Returns the Capitalized form of a string
```javascript
'innerHTML'.capitalize() // 'InnerHTML'
'action_name'.capitalize() // 'Action_name'
'css-class-name'.capitalize() // 'Css-class-name'
'my favorite items'.capitalize() // 'My favorite items'
'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice'
import { capitalize } from '@ember/string';
capitalize('innerHTML') // 'InnerHTML'
capitalize('action_name') // 'Action_name'
capitalize('css-class-name') // 'Css-class-name'
capitalize('my favorite items') // 'My favorite items'
capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
```
@method capitalize
Expand All @@ -280,7 +292,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return w(this);
},
},
Expand All @@ -297,7 +309,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function(this: string, ...args: any[]) {
value: function (this: string, ...args: any[]) {
return loc(this, args);
},
},
Expand All @@ -314,7 +326,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return camelize(this);
},
},
Expand All @@ -331,7 +343,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return decamelize(this);
},
},
Expand All @@ -348,7 +360,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return dasherize(this);
},
},
Expand All @@ -365,7 +377,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return underscore(this);
},
},
Expand All @@ -382,7 +394,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return classify(this);
},
},
Expand All @@ -399,7 +411,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
value: function() {
value: function () {
return capitalize(this);
},
},
Expand Down

0 comments on commit 37d69f1

Please sign in to comment.