Skip to content

Commit

Permalink
chore: pr feedback ht Nick
Browse files Browse the repository at this point in the history
  • Loading branch information
monfera committed Jan 21, 2021
1 parent 3545cd8 commit 17e1356
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/state/actions/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,36 @@ export const SET_TEMPORARY_COLOR = 'SET_TEMPORARY_COLOR';
/** @internal */
export const SET_PERSISTED_COLOR = 'SET_PERSISTED_COLOR';

interface ClearedTemporaryColors {
interface ClearTemporaryColors {
type: typeof CLEAR_TEMPORARY_COLORS;
}

interface TemporaryColor {
interface SetTemporaryColor {
type: typeof SET_TEMPORARY_COLOR;
key: SeriesKey;
color: Color | null;
}

interface PersistedColor {
interface SetPersistedColor {
type: typeof SET_PERSISTED_COLOR;
key: SeriesKey;
color: Color | null;
}

/** @internal */
export function clearTemporaryColors(): ClearedTemporaryColors {
export function clearTemporaryColors(): ClearTemporaryColors {
return { type: CLEAR_TEMPORARY_COLORS };
}

/** @internal */
export function setTemporaryColor(key: SeriesKey, color: Color | null): TemporaryColor {
export function setTemporaryColor(key: SeriesKey, color: Color | null): SetTemporaryColor {
return { type: SET_TEMPORARY_COLOR, key, color };
}

/** @internal */
export function setPersistedColor(key: SeriesKey, color: Color | null): PersistedColor {
export function setPersistedColor(key: SeriesKey, color: Color | null): SetPersistedColor {
return { type: SET_PERSISTED_COLOR, key, color };
}

/** @internal */
export type ColorsActions = ClearedTemporaryColors | TemporaryColor | PersistedColor;
export type ColorsActions = ClearTemporaryColors | SetTemporaryColor | SetPersistedColor;
4 changes: 4 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,8 @@ export const getPercentageValue = <T>(ratio: string | number, relativeValue: num
return num && !isNaN(num) ? num : defaultValue;
};

/**
* Predicate function, eg. to be called with [].filter, to keep distinct values
* @example [1, 2, 4, 2, 4, 0, 3, 2].filter(keepDistinct) ==> [1, 2, 4, 0, 3]
*/
export const keepDistinct = <T>(d: T, i: number, a: T[]): boolean => a.indexOf(d) === i;

0 comments on commit 17e1356

Please sign in to comment.