From cce1a041d2fb482e825f2281cc5d206df5c5759c Mon Sep 17 00:00:00 2001 From: Jack Beegan Date: Tue, 1 Oct 2019 22:45:54 +0100 Subject: [PATCH] Add a code example to documentation for EmberArray rejectBy --- .../-internals/runtime/lib/mixins/array.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/@ember/-internals/runtime/lib/mixins/array.js b/packages/@ember/-internals/runtime/lib/mixins/array.js index 4486455237d..a6fcbf6e404 100644 --- a/packages/@ember/-internals/runtime/lib/mixins/array.js +++ b/packages/@ember/-internals/runtime/lib/mixins/array.js @@ -863,9 +863,21 @@ const ArrayMixin = Mixin.create(Enumerable, { }, /** - Returns an array with the items that do not have truthy values for - key. You can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to false. + Returns an array with the items that do not have truthy values for the provided key. + You can pass an optional second argument with a target value to reject for the key. + Otherwise this will reject objects where the provided property evaluates to false. + + Example Usage: + + ```javascript + let food = [ + { name: "apple", isFruit: true }, + { name: "carrot", isFruit: false }, + { name: "bread", isFruit: false }, + ]; + food.rejectBy('isFruit'); // [{ name: "carrot", isFruit: false }, { name: "bread", isFruit: false }] + food.rejectBy('name', 'carrot'); // [{ name: "apple", isFruit: true }}, { name: "bread", isFruit: false }] + ``` @method rejectBy @param {String} key the property to test