mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 23:16:59 +00:00
refactor: change returned type to be tuple instead array
This commit is contained in:
parent
b4a2945d10
commit
09ebfaf131
@ -1,6 +1,6 @@
|
|||||||
import random from 'lodash.random'
|
import random from 'lodash.random'
|
||||||
|
|
||||||
export function getRandomPairOfColors() {
|
export function getRandomPairOfColors(): [string, string] {
|
||||||
const colors = ['#37B679', '#DA3C3C', '#3291FF', '#7928CA', '#79FFE1']
|
const colors = ['#37B679', '#DA3C3C', '#3291FF', '#7928CA', '#79FFE1']
|
||||||
const getRandomIdx = () => random(0, colors.length - 1)
|
const getRandomIdx = () => random(0, colors.length - 1)
|
||||||
let idx = getRandomIdx()
|
let idx = getRandomIdx()
|
||||||
@ -15,7 +15,7 @@ export function getRandomPairOfColors() {
|
|||||||
return [colors[idx], colors[idx2]]
|
return [colors[idx], colors[idx2]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function hexToRgb(hex: string = '') {
|
function hexToRgb(hex: string = ''): [number, number, number] {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const match = hex.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i)
|
const match = hex.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user