What to use instead of `@ember/string`

nullvoxpopuli

NullVoxPopuli

Posted on October 20, 2023

What to use instead of `@ember/string`

@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';
Enter fullscreen mode Exit fullscreen mode

capitalize

If you use capitalize in @ember/string, use this instead:

import { capitalCase } from 'change-case';
Enter fullscreen mode Exit fullscreen mode

classify

If you use classify in @ember/string, use this instead:

import { pascalCase } from 'change-case';
Enter fullscreen mode Exit fullscreen mode

dasherize

If you use dasherize in @ember/string, use this instead:

import { kebabCase } from 'change-case';
Enter fullscreen mode Exit fullscreen mode

decamelize

If you use decamelize in @ember/string, use this instead:

import { snakeCase } from 'change-case';
Enter fullscreen mode Exit fullscreen mode

underscore

If you use underscore in @ember/string, use this instead:

import { snakeCase } from 'change-case';
Enter fullscreen mode Exit fullscreen mode

## w

If you use w in @ember/string, use this instead:

let result = `long string with words`.split(/\s+/);
//  ^ ['long', 'string', 'with', 'words']
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
nullvoxpopuli
NullVoxPopuli

Posted on October 20, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related