What to use instead of `@ember/string`
NullVoxPopuli
Posted on October 20, 2023
@ember/string
is trying to be phased out -- I've found that change-case
is a better alternative to @ember/string
, because it supports more transformations, is true native ESM, and can be anywhere, even outside of ember, or in plain html files!
Here is how you migrate:
camelize
If you use camelize
in @ember/string
, use this instead:
import { camelCase } from 'change-case';
capitalize
If you use capitalize
in @ember/string
, use this instead:
import { capitalCase } from 'change-case';
classify
If you use classify
in @ember/string
, use this instead:
import { pascalCase } from 'change-case';
dasherize
If you use dasherize
in @ember/string
, use this instead:
import { kebabCase } from 'change-case';
decamelize
If you use decamelize
in @ember/string
, use this instead:
import { snakeCase } from 'change-case';
underscore
If you use underscore
in @ember/string
, use this instead:
import { snakeCase } from 'change-case';
## w
If you use w
in @ember/string
, use this instead:
let result = `long string with words`.split(/\s+/);
// ^ ['long', 'string', 'with', 'words']
Posted on October 20, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.