From 1cd2a41141e29f353a64f31db3ed64d871e02786 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 22 Feb 2016 04:45:20 +0300 Subject: [PATCH] + choise common util --- src/utils/common.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/utils/common.js b/src/utils/common.js index 798d0e43..dbc8b546 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -41,4 +41,14 @@ export function indexEquals(withNumber) { */ export function select(byCondition, map = i => i) { return (result, item) => byCondition(item) ? map(item): map(result) +} + +/** + * Select an item in Array by specified selector function + * @param scope + * @param selector + * @returns {*} + */ +export function choise(scope, selector){ + return scope.reduce(selector, null); } \ No newline at end of file