From 0f2eb90b5255f2fc875592e84cefed498210348e Mon Sep 17 00:00:00 2001 From: cibernox Date: Thu, 30 Nov 2017 00:01:42 +0100 Subject: [PATCH] [CLEANUP] Remove Enumerable#includes --- .../ember-runtime/lib/mixins/enumerable.js | 30 ------------------- .../ember-runtime/tests/suites/enumerable.js | 2 -- .../tests/suites/enumerable/contains.js | 23 -------------- 3 files changed, 55 deletions(-) delete mode 100644 packages/ember-runtime/tests/suites/enumerable/contains.js diff --git a/packages/ember-runtime/lib/mixins/enumerable.js b/packages/ember-runtime/lib/mixins/enumerable.js index f3b05f405b3..e4fa617abb6 100644 --- a/packages/ember-runtime/lib/mixins/enumerable.js +++ b/packages/ember-runtime/lib/mixins/enumerable.js @@ -207,36 +207,6 @@ const Enumerable = Mixin.create({ return last; }).readOnly(), - /** - Returns `true` if the passed object can be found in the receiver. The - default version will iterate through the enumerable until the object - is found. You may want to override this with a more efficient version. - - ```javascript - let arr = ['a', 'b', 'c']; - - arr.contains('a'); // true - arr.contains('z'); // false - ``` - - @method contains - @deprecated Use `Enumerable#includes` instead. See https://emberjs.com/deprecations/v2.x#toc_enumerable-contains - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in enumerable. - @public - */ - contains(obj) { - deprecate( - '`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', - false, - { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'https://emberjs.com/deprecations/v2.x#toc_enumerable-contains' } - ); - - let found = this.find(item => item === obj); - - return found !== undefined; - }, - /** Iterates through the enumerable, calling the passed function on each item. This method corresponds to the `forEach()` method defined in diff --git a/packages/ember-runtime/tests/suites/enumerable.js b/packages/ember-runtime/tests/suites/enumerable.js index 0de68904557..017c9565b0b 100644 --- a/packages/ember-runtime/tests/suites/enumerable.js +++ b/packages/ember-runtime/tests/suites/enumerable.js @@ -280,7 +280,6 @@ const EnumerableTests = Suite.extend({ import anyTests from './enumerable/any'; import isAnyTests from './enumerable/is_any'; import compactTests from './enumerable/compact'; -import containsTests from './enumerable/contains'; import includesTests from './enumerable/includes'; import everyTests from './enumerable/every'; import filterTests from './enumerable/filter'; @@ -302,7 +301,6 @@ import withoutTests from './enumerable/without'; EnumerableTests.importModuleTests(anyTests); EnumerableTests.importModuleTests(isAnyTests); EnumerableTests.importModuleTests(compactTests); -EnumerableTests.importModuleTests(containsTests); EnumerableTests.importModuleTests(everyTests); EnumerableTests.importModuleTests(filterTests); EnumerableTests.importModuleTests(findTests); diff --git a/packages/ember-runtime/tests/suites/enumerable/contains.js b/packages/ember-runtime/tests/suites/enumerable/contains.js deleted file mode 100644 index 0d194d22524..00000000000 --- a/packages/ember-runtime/tests/suites/enumerable/contains.js +++ /dev/null @@ -1,23 +0,0 @@ -import { SuiteModuleBuilder } from '../suite'; - -const suite = SuiteModuleBuilder.create(); - -suite.module('contains'); - -suite.test('contains returns true if item is in enumerable', function() { - let data = this.newFixture(3); - let obj = this.newObject(data); - - expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); - equal(obj.contains(data[1]), true, 'should return true if contained'); -}); - -suite.test('contains returns false if item is not in enumerable', function() { - let data = this.newFixture(1); - let obj = this.newObject(this.newFixture(3)); - - expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); - equal(obj.contains(data[0]), false, 'should return false if not contained'); -}); - -export default suite;