@ctrl/tinycolor
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -1260,3 +1260,3 @@ /** | ||
// Check if we need to generate multiple colors | ||
if (options.count !== undefined) { | ||
if (options.count !== undefined && options.count !== null) { | ||
const totalColors = options.count; | ||
@@ -1269,6 +1269,7 @@ const colors = []; | ||
// generate the same color each time... | ||
options.count = null; | ||
if (options.seed) { | ||
options.seed += 1; | ||
} | ||
colors.push(fromRandom(options)[0]); | ||
colors.push(fromRandom(options)); | ||
} | ||
@@ -1289,3 +1290,3 @@ options.count = totalColors; | ||
// Then we return the HSB color in the desired format | ||
return [new TinyColor(res)]; | ||
return new TinyColor(res); | ||
} | ||
@@ -1292,0 +1293,0 @@ function pickHue(hue, seed) { |
{ | ||
"name": "@ctrl/tinycolor", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Fast, small color manipulation and conversion for JavaScript", | ||
@@ -27,2 +27,6 @@ "author": "Scott Cooper <scttcper@gmail.com>", | ||
"scripts": { | ||
"demo": "npm-run-all --parallel start:demo watch:demo", | ||
"build:demo": "rollup -c rollup.demo.js", | ||
"watch:demo": "rollup -c rollup.demo.js -w", | ||
"start:demo": "serve demo/public", | ||
"lint": "tslint -p tsconfig.json -t stylish 'src/**/*.ts' 'test/**/*.ts'", | ||
@@ -32,3 +36,3 @@ "lint:fix": "tslint -p tsconfig.json -t stylish --fix 'src/**/*.ts' 'test/**/*.ts'", | ||
"build": "tsc -p tsconfig.json && tsc -p tsconfig.esm.json && ts-node ./build.ts", | ||
"build:docs": "typedoc --out docs --target es6 --theme minimal --mode file src && touch docs/.nojekyll", | ||
"build:docs": "typedoc src && touch docs/.nojekyll", | ||
"test": "jest", | ||
@@ -38,3 +42,2 @@ "test:watch": "jest --watch", | ||
"commit": "git-cz", | ||
"commitlint": "commitlint -e $GIT_PARAMS", | ||
"travis-deploy-once": "travis-deploy-once", | ||
@@ -45,12 +48,10 @@ "semantic-release": "cd dist/package-dist && semantic-release" | ||
"devDependencies": { | ||
"@commitlint/cli": "6.2.0", | ||
"@commitlint/config-conventional": "6.1.3", | ||
"@types/fs-extra": "5.0.2", | ||
"@types/jest": "22.2.3", | ||
"@types/node": "10.0.2", | ||
"@types/node": "10.0.4", | ||
"commitizen": "2.9.6", | ||
"cz-conventional-changelog": "2.1.0", | ||
"fs-extra": "6.0.0", | ||
"husky": "1.0.0-rc.2", | ||
"jest": "22.4.3", | ||
"npm-run-all": "4.1.3", | ||
"prettier": "1.12.1", | ||
@@ -60,7 +61,9 @@ "rimraf": "2.6.2", | ||
"rollup-plugin-sourcemaps": "0.4.2", | ||
"semantic-release": "15.2.0", | ||
"rollup-plugin-typescript2": "0.13.0", | ||
"rollup-plugin-uglify": "3.0.0", | ||
"semantic-release": "15.3.1", | ||
"travis-deploy-once": "5.0.0", | ||
"ts-jest": "22.4.4", | ||
"ts-node": "6.0.2", | ||
"tslint": "5.9.1", | ||
"ts-jest": "22.4.5", | ||
"ts-node": "6.0.3", | ||
"tslint": "5.10.0", | ||
"tslint-config-prettier": "1.12.0", | ||
@@ -74,7 +77,2 @@ "tslint-config-standard": "7.0.0", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "npm run commitlint" | ||
} | ||
}, | ||
"commitlint": { | ||
@@ -81,0 +79,0 @@ "extends": [ |
import { TinyColor } from './index'; | ||
export interface RandomOptions { | ||
seed?: number; | ||
count?: number; | ||
hue?: number | string | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'monochrome'; | ||
@@ -9,2 +8,6 @@ luminosity?: 'random' | 'bright' | 'dark' | 'light'; | ||
} | ||
export declare function fromRandom(options?: RandomOptions): TinyColor[]; | ||
export interface RandomCountOptions extends RandomOptions { | ||
count?: number | null; | ||
} | ||
export declare function fromRandom(options?: RandomOptions): TinyColor; | ||
export declare function fromRandom(options?: RandomCountOptions): TinyColor[]; |
@@ -9,3 +9,3 @@ "use strict"; | ||
// Check if we need to generate multiple colors | ||
if (options.count !== undefined) { | ||
if (options.count !== undefined && options.count !== null) { | ||
const totalColors = options.count; | ||
@@ -18,6 +18,7 @@ const colors = []; | ||
// generate the same color each time... | ||
options.count = null; | ||
if (options.seed) { | ||
options.seed += 1; | ||
} | ||
colors.push(fromRandom(options)[0]); | ||
colors.push(fromRandom(options)); | ||
} | ||
@@ -38,3 +39,3 @@ options.count = totalColors; | ||
// Then we return the HSB color in the desired format | ||
return [new index_1.TinyColor(res)]; | ||
return new index_1.TinyColor(res); | ||
} | ||
@@ -41,0 +42,0 @@ exports.fromRandom = fromRandom; |
@@ -528,4 +528,4 @@ # tinycolor [![npm](https://img.shields.io/npm/v/%40ctrl%2Ftinycolor.svg?maxAge=3600)](https://www.npmjs.com/package/%40ctrl%2Ftinycolor) [![build status](https://img.shields.io/travis/TypeCtrl/tinycolor.svg)](https://travis-ci.org/TypeCtrl/tinycolor) [![coverage status](https://codecov.io/gh/typectrl/tinycolor/branch/master/graph/badge.svg)](https://codecov.io/gh/typectrl/tinycolor) | ||
Returns a random TinyColor object. This is an implementation of [randomColor](https://github.com/davidmerfield/fromRandom/) by David Merfield. | ||
The main changes are input parsing and output formatting are handled by TinyColor. | ||
Returns a random TinyColor object. This is an implementation of [randomColor](https://github.com/davidmerfield/randomColor/) by David Merfield. | ||
The difference input parsing and output formatting are handled by TinyColor. | ||
@@ -551,3 +551,3 @@ You can pass an options object to influence the type of color it produces. The options object accepts the following properties: | ||
// Returns a hex code for a light blue | ||
// Returns a TinyColor object in a light blue | ||
fromRandom({ | ||
@@ -558,3 +558,3 @@ luminosity: 'light', | ||
// Returns a hex code for a 'truly random' color | ||
// Returns a TinyColor object in a 'truly random' color | ||
fromRandom({ | ||
@@ -561,0 +561,0 @@ luminosity: 'random', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346668
43
3441