Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed May 1, 2018
1 parent e27389e commit 144e262
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { rgbaToHex, rgbToHex, rgbToHsl, rgbToHsv } from './conversion';
import names from './css-color-names';
import { inputToRGB } from './format-input';
import { HSL, HSLA, HSV, HSVA, RGB, RGBA } from './interfaces';
import { bound01, boundAlpha, clamp01, convertToPercentage } from './util';
import { bound01, boundAlpha, clamp01 } from './util';

export interface TinyColorOptions {
format: string;
Expand Down
7 changes: 3 additions & 4 deletions src/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// https://github.com/davidmerfield/randomColor/

import { bounds, ColorBound } from './color-bounds';
import { hsvToRgb } from './conversion';
import { TinyColor } from './index';
import { HSV, HSVA } from './interfaces';
import { HSVA } from './interfaces';

export interface RandomOptions {
seed?: number;
Expand All @@ -26,7 +25,7 @@ export interface RandomOptions {

export function fromRandom(options: RandomOptions = {}): TinyColor[] {
// Check if we need to generate multiple colors
if (options.count !== null && options.count !== undefined) {
if (options.count !== undefined) {
const totalColors = options.count;
const colors: TinyColor[] = [];

Expand Down Expand Up @@ -191,7 +190,7 @@ function getColorInfo(hue: number) {
}

function randomWithin(range: [number, number], seed?: number) {
if (seed === null || seed === undefined) {
if (seed === undefined) {
return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0]));
} else {
// Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
Expand Down
9 changes: 6 additions & 3 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ describe('TinyColor', () => {
expect(r).toBeTruthy();
});
it('should clone', () => {
const r = new TinyColor('red').clone();
expect(r.isValid).toBeTruthy();
expect(r.toName()).toBe('red');
const color1 = new TinyColor('red');
const color2 = new TinyColor('red').clone();
color2.setAlpha(0.5);
expect(color2.isValid).toBeTruthy();
expect(color2.toString()).toBe('rgba(255, 0, 0, 0.5)');
expect(color1.toString()).toBe('red');
});
it('should parse options', () => {
expect(new TinyColor('red', { format: 'hex' }).toString()).toEqual('#ff0000');
Expand Down

0 comments on commit 144e262

Please sign in to comment.