Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Ember.String.fmt #15882

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions packages/ember-runtime/lib/ext/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import { ENV } from 'ember-environment';
import {
fmt,
w,
loc,
camelize,
Expand All @@ -18,19 +17,6 @@ import {
const StringPrototype = String.prototype;

if (ENV.EXTEND_PROTOTYPES.String) {
/**
See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt).

@method fmt
@for @ember/string
@static
@private
@deprecated
*/
StringPrototype.fmt = function (...args) {
return fmt(this, args);
};

/**
See [Ember.String.w](/api/classes/Ember.String.html#method_w).

Expand Down
42 changes: 3 additions & 39 deletions packages/ember-runtime/lib/system/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@module @ember/string
*/
import { Cache } from 'ember-metal';
import { deprecate } from 'ember-debug';
import { inspect } from 'ember-utils';
import { isArray } from '../utils';
import {
Expand Down Expand Up @@ -32,7 +31,7 @@ const CLASSIFY_CACHE = new Cache(1000, str => {
.replace(STRING_CLASSIFY_REGEXP_2, replace2);
}
return parts.join('/')
.replace(STRING_CLASSIFY_REGEXP_3, (match /*, separator, chr */) => match.toUpperCase());
.replace(STRING_CLASSIFY_REGEXP_3, (match /*, separator, chr */) => match.toUpperCase());
});

const STRING_UNDERSCORE_REGEXP_1 = (/([a-z\d])([A-Z]+)/g);
Expand Down Expand Up @@ -61,23 +60,14 @@ function _fmt(str, formats) {
}

// first, replace any ORDERED replacements.
let idx = 0; // the current index for non-numerical replacements
let idx = 0; // the current index for non-numerical replacements
return str.replace(/%@([0-9]+)?/g, (s, argIndex) => {
argIndex = (argIndex) ? parseInt(argIndex, 10) - 1 : idx++;
s = cachedFormats[argIndex];
return (s === null) ? '(null)' : (s === undefined) ? '' : inspect(s);
});
}

function fmt(/* str, formats */) {
deprecate(
'Ember.String.fmt is deprecated, use ES6 template strings instead.',
false,
{ id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' }
);
return _fmt(...arguments);
}

function loc(str, formats) {
if (!isArray(formats) || arguments.length > 2) {
formats = Array.prototype.slice.call(arguments, 1);
Expand Down Expand Up @@ -124,34 +114,9 @@ function capitalize(str) {
@public
*/
export default {
/**
Apply formatting options to the string. This will look for occurrences
of "%@" in your string and substitute them with the arguments you pass into
this method. If you want to control the specific order of replacement,
you can add a number after the key as well to indicate which argument
you want to insert.

Ordered insertions are most useful when building loc strings where values
you need to insert may appear in different orders.

```javascript
"Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe"
"Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John"
```

@method fmt
@param {String} str The string to format
@param {Array} formats An array of parameters to interpolate into string.
@return {String} formatted string
@public
@deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings
*/
fmt,

/**
Formats the passed string, but first looks up the string in the localized
strings hash. This is a convenient way to localize text. See
`Ember.String.fmt()` for more information on formatting.
strings hash. This is a convenient way to localize text.

Note that it is traditional but not required to prefix localized string
keys with an underscore or other character so you can easily identify
Expand Down Expand Up @@ -308,7 +273,6 @@ export default {
};

export {
fmt,
loc,
w,
decamelize,
Expand Down
36 changes: 0 additions & 36 deletions packages/ember-runtime/tests/system/string/fmt_string_test.js

This file was deleted.