DEV Community

Cover image for What to use instead of `@ember/string`
NullVoxPopuli
NullVoxPopuli

Posted on

6 1

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay