Merge pull request #191 from aaron-hanson/fix-quality-option-validation

Fix quality option validation, update npm script syntax, package-lock
This commit is contained in:
Lokesh Dhakar
2020-07-05 19:15:58 -07:00
committed by GitHub
11 changed files with 18 additions and 21 deletions

4
.gitignore vendored
View File

@@ -13,4 +13,6 @@ Thumbs.db
.sass-cache
Rakefile
rsync-exclude
node_modules
node_modules
.idea

4
dist/color-thief.js vendored
View File

@@ -34,9 +34,7 @@ function validateOptions(options) {
colorCount = Math.min(colorCount, 20);
}
if (typeof quality === 'undefined' || Number.isInteger(quality)) {
quality = 10;
} else if (quality < 1) {
if (typeof quality === 'undefined' || !Number.isInteger(quality) || quality < 1) {
quality = 10;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/color-thief.umd.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"color-thief.umd.js","sources":["../build/build.js"],"sourcesContent":["var fs = require('fs');\r\nconst { resolve } = require('path');\r\n\r\n/*\r\ncolor-thief.umd.js duplicated as color-thief.min.js for legacy support\r\n\r\nIn Color Thief v2.1 <= there was one distribution file (dist/color-thief.min.js)\r\nand it exposed a global variable ColorThief. Starting from v2.2, the package\r\nincludes multiple dist files for the various module systems. One of these is\r\nthe UMD format which falls back to a global variable if the requirejs AMD format\r\nis not being used. This file is called color-thief.umd.js in the dist folder. We\r\nwant to keep supporting the previous users who were loading\r\ndist/color-thief.min.js and expecting a global var. For this reason we're\r\nduplicating the UMD compatible file and giving it that name.\r\n*/\r\n\r\nconst umdRelPath = 'dist/color-thief.umd.js';\r\nconst legacyRelPath = 'dist/color-thief.min.js';\r\n\r\nconst umdPath = resolve(process.cwd(), umdRelPath);\r\nconst legacyPath = resolve(process.cwd(), legacyRelPath);\r\n\r\nfs.copyFile(umdPath, legacyPath, (err) => {\r\n if (err) throw err;\r\n console.log(`${umdRelPath} copied to ${legacyRelPath}.`);\r\n});\r\n\r\nconst srcNodeRelPath = 'src/color-thief-node.js';\r\nconst distNodeRelPath = 'dist/color-thief.js';\r\nconst srcNodePath = resolve(process.cwd(), srcNodeRelPath);\r\nconst distNodePath = resolve(process.cwd(), distNodeRelPath);\r\n\r\nfs.copyFile(srcNodePath, distNodePath, (err) => {\r\n if (err) throw err;\r\n console.log(`${srcNodeRelPath} copied to ${distNodeRelPath}.`);\r\n});\r\n"],"names":["fs","require","umdPath","resolve","process","cwd","legacyPath","copyFile","err","console","log","const","srcNodePath","distNodePath"],"mappings":"0IAAA,IAAIA,EAAKC,QAAQ,QACGA,QAAQ,gBAkBtBC,EAAUC,EAAQC,QAAQC,MAHb,2BAIbC,EAAaH,EAAQC,QAAQC,MAHb,2BAKtBL,EAAGO,SAASL,EAASI,WAAaE,MAC1BA,EAAK,MAAMA,EACfC,QAAQC,oEAGZC,IAEMC,EAAcT,EAAQC,QAAQC,MAFb,2BAGjBQ,EAAeV,EAAQC,QAAQC,MAFb,uBAIxBL,EAAGO,SAASK,EAAaC,WAAeL,MAChCA,EAAK,MAAMA,EACfC,QAAQC"}

4
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "colorthief",
"version": "2.2.1",
"version": "2.3.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -5558,7 +5558,7 @@
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"quantize": {
"version": "github:lokesh/quantize#93448210e66b1f0fd318332a1192ea87a9e85079",
"version": "github:lokesh/quantize#f572abd2646b5944852535c8a26fdb958a5d7c4b",
"from": "github:lokesh/quantize"
},
"query-string": {

View File

@@ -1,6 +1,6 @@
{
"name": "colorthief",
"version": "2.3.0",
"version": "2.3.1",
"author": {
"name": "Lokesh Dhakar",
"email": "lokesh.dhakar@gmail.com",
@@ -28,11 +28,11 @@
"umd:main": "dist/color-thief.umd.js",
"amdName": "ColorThief",
"scripts": {
"build": "microbundle --no-sourcemap; node ./build/build.js",
"build": "microbundle --no-sourcemap && node ./build/build.js",
"watch": "microbundle watch --no-sourcemap",
"dev": " ./node_modules/http-server/bin/http-server",
"test": "mocha; ./node_modules/.bin/cypress run --config video=false",
"test:browser": "./node_modules/.bin/cypress open",
"dev": "http-server",
"test": "mocha && cypress run --config video=false",
"test:browser": "cypress open",
"test:node": "mocha"
},
"devDependencies": {

View File

@@ -34,9 +34,7 @@ function validateOptions(options) {
colorCount = Math.min(colorCount, 20);
}
if (typeof quality === 'undefined' || Number.isInteger(quality)) {
quality = 10;
} else if (quality < 1) {
if (typeof quality === 'undefined' || !Number.isInteger(quality) || quality < 1) {
quality = 10;
}

View File

@@ -2,7 +2,7 @@ import quantize from '../node_modules/quantize/dist/index.mjs';
import core from './core.js';
/*
* Color Thief v2.3.0
* Color Thief v2.3.1
* by Lokesh Dhakar - http://www.lokeshdhakar.com
*
* Thanks

View File

@@ -31,9 +31,7 @@ function validateOptions(options) {
colorCount = Math.min(colorCount, 20);
}
if (typeof quality === 'undefined' || Number.isInteger(quality)) {
quality = 10;
} else if (quality < 1) {
if (typeof quality === 'undefined' || !Number.isInteger(quality) || quality < 1) {
quality = 10;
}