From a61f707064ba5df93f58dce45ba41ae97d0278e6 Mon Sep 17 00:00:00 2001 From: Seyi Adebajo Date: Mon, 12 Mar 2018 10:43:52 -0700 Subject: [PATCH] adds type safe data-last array every function --- wherehows-web/app/utils/array.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wherehows-web/app/utils/array.ts b/wherehows-web/app/utils/array.ts index d8a03fa6a8..2d964edd94 100644 --- a/wherehows-web/app/utils/array.ts +++ b/wherehows-web/app/utils/array.ts @@ -14,6 +14,15 @@ const arrayMap = (mappingFunction: (param: T) => U): ((array: Array) => const arrayFilter = (filtrationFunction: (param: T) => boolean): ((array: Array) => Array) => (array = []) => array.filter(filtrationFunction); +/** + * Typesafe utility `data last` function for array every + * @template T + * @param {(param: T) => boolean} filter + * @returns {((array: Array) => boolean)} + */ +const arrayEvery = (filter: (param: T) => boolean): ((array: Array) => boolean) => (array = []) => + array.every(filter); + /** * Composable reducer abstraction, curries a reducing iteratee and returns a reducing function that takes a list * @template U @@ -42,4 +51,4 @@ const isListUnique = (list: Array = []): boolean => new Set(list).size === */ const compact = (list: Array = []): Array => list.filter(item => item); -export { arrayMap, arrayFilter, arrayReduce, isListUnique, compact }; +export { arrayMap, arrayFilter, arrayReduce, isListUnique, compact, arrayEvery };