From d069b87546281415617759f54e4bf738886d88e5 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Sat, 12 Oct 2019 15:23:37 +0200 Subject: [PATCH] =?UTF-8?q?fix(=F0=9F=90=9B):=20fix=20string()=20on=20Andr?= =?UTF-8?q?oid=20(#114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/String.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/String.tsx b/src/String.tsx index edafaaf7..0182e4ac 100644 --- a/src/String.tsx +++ b/src/String.tsx @@ -5,17 +5,18 @@ const { concat } = Animated; export type Concatable = | Animated.Adaptable | Animated.Adaptable; -export const string = (strings: readonly string[], ...values: Concatable[]) => { + +export const string = ( + strings: readonly string[], + ...values: readonly Concatable[] +) => { if (values.length === 0) { return concat(strings[0]); } - const initialValue: Concatable[] = []; - const result: Concatable[] = strings.reduce( - (acc, str, idx) => [...acc, str, values[idx]], - initialValue + const result = values.reduce( + (acc, v, idx) => [...acc, strings[idx], v], + [] ); - if (values.length > strings.length) { - result.push(values[values.length - 1]); - } + result.push(strings[strings.length - 1]); return concat(...result); };