Skip to content

Commit

Permalink
fix(🐛): fix string() on Android (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Oct 12, 2019
1 parent b30b764 commit d069b87
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/String.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ const { concat } = Animated;
export type Concatable =
| Animated.Adaptable<string>
| Animated.Adaptable<number>;
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<Concatable[]>(
(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);
};

0 comments on commit d069b87

Please sign in to comment.