@ember/string
Version:
A set of utilities to transform strings
157 lines (124 loc) • 4.62 kB
TypeScript
/**
Returns the lowerCamelCase form of a string.
```javascript
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'
```
*/
export declare function camelize(str: string): string;
/**
Returns the Capitalized form of a string
```javascript
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'
```
*/
export declare function capitalize(str: string): string;
/**
Returns the UpperCamelCase form of a string.
```javascript
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'
```
*/
export declare function classify(str: string): string;
/**
Replaces underscores, spaces, or camelCase with dashes.
```javascript
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'
```
*/
export declare function dasherize(str: string): string;
/**
Converts a camelized string into all lower case separated by underscores.
```javascript
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'
```
*/
export declare function decamelize(str: string): string;
export declare function getString(name: string): string | undefined;
export declare function getStrings(): {
[key: string]: string;
};
export declare function setStrings(strings: {
[key: string]: string;
}): void;
/**
More general than decamelize. Returns the lower\_case\_and\_underscored
form of a string.
```javascript
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'
```
*/
export declare function underscore(str: string): string;
/**
Splits a string into separate units separated by spaces, eliminating any
empty strings in the process. This is a convenience method for split that
is mostly useful when applied to the `String.prototype`.
```javascript
import { w } from '@ember/string';
w("alpha beta gamma").forEach(function(key) {
console.log(key);
});
// > alpha
// > beta
// > gamma
```
*/
export declare function w(str: string): string[];
export { }