mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 13:54:25 +00:00
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:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -13,4 +13,6 @@ Thumbs.db
|
|||||||
.sass-cache
|
.sass-cache
|
||||||
Rakefile
|
Rakefile
|
||||||
rsync-exclude
|
rsync-exclude
|
||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
|
.idea
|
||||||
|
|||||||
4
dist/color-thief.js
vendored
4
dist/color-thief.js
vendored
@@ -34,9 +34,7 @@ function validateOptions(options) {
|
|||||||
colorCount = Math.min(colorCount, 20);
|
colorCount = Math.min(colorCount, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof quality === 'undefined' || Number.isInteger(quality)) {
|
if (typeof quality === 'undefined' || !Number.isInteger(quality) || quality < 1) {
|
||||||
quality = 10;
|
|
||||||
} else if (quality < 1) {
|
|
||||||
quality = 10;
|
quality = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
dist/color-thief.min.js
vendored
2
dist/color-thief.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/color-thief.mjs
vendored
2
dist/color-thief.mjs
vendored
File diff suppressed because one or more lines are too long
2
dist/color-thief.umd.js
vendored
2
dist/color-thief.umd.js
vendored
File diff suppressed because one or more lines are too long
1
dist/color-thief.umd.js.map
vendored
Normal file
1
dist/color-thief.umd.js.map
vendored
Normal 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
4
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "colorthief",
|
"name": "colorthief",
|
||||||
"version": "2.2.1",
|
"version": "2.3.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -5558,7 +5558,7 @@
|
|||||||
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
|
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
|
||||||
},
|
},
|
||||||
"quantize": {
|
"quantize": {
|
||||||
"version": "github:lokesh/quantize#93448210e66b1f0fd318332a1192ea87a9e85079",
|
"version": "github:lokesh/quantize#f572abd2646b5944852535c8a26fdb958a5d7c4b",
|
||||||
"from": "github:lokesh/quantize"
|
"from": "github:lokesh/quantize"
|
||||||
},
|
},
|
||||||
"query-string": {
|
"query-string": {
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "colorthief",
|
"name": "colorthief",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Lokesh Dhakar",
|
"name": "Lokesh Dhakar",
|
||||||
"email": "lokesh.dhakar@gmail.com",
|
"email": "lokesh.dhakar@gmail.com",
|
||||||
@@ -28,11 +28,11 @@
|
|||||||
"umd:main": "dist/color-thief.umd.js",
|
"umd:main": "dist/color-thief.umd.js",
|
||||||
"amdName": "ColorThief",
|
"amdName": "ColorThief",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "microbundle --no-sourcemap; node ./build/build.js",
|
"build": "microbundle --no-sourcemap && node ./build/build.js",
|
||||||
"watch": "microbundle watch --no-sourcemap",
|
"watch": "microbundle watch --no-sourcemap",
|
||||||
"dev": " ./node_modules/http-server/bin/http-server",
|
"dev": "http-server",
|
||||||
"test": "mocha; ./node_modules/.bin/cypress run --config video=false",
|
"test": "mocha && cypress run --config video=false",
|
||||||
"test:browser": "./node_modules/.bin/cypress open",
|
"test:browser": "cypress open",
|
||||||
"test:node": "mocha"
|
"test:node": "mocha"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ function validateOptions(options) {
|
|||||||
colorCount = Math.min(colorCount, 20);
|
colorCount = Math.min(colorCount, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof quality === 'undefined' || Number.isInteger(quality)) {
|
if (typeof quality === 'undefined' || !Number.isInteger(quality) || quality < 1) {
|
||||||
quality = 10;
|
|
||||||
} else if (quality < 1) {
|
|
||||||
quality = 10;
|
quality = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import quantize from '../node_modules/quantize/dist/index.mjs';
|
|||||||
import core from './core.js';
|
import core from './core.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Color Thief v2.3.0
|
* Color Thief v2.3.1
|
||||||
* by Lokesh Dhakar - http://www.lokeshdhakar.com
|
* by Lokesh Dhakar - http://www.lokeshdhakar.com
|
||||||
*
|
*
|
||||||
* Thanks
|
* Thanks
|
||||||
|
|||||||
@@ -31,9 +31,7 @@ function validateOptions(options) {
|
|||||||
colorCount = Math.min(colorCount, 20);
|
colorCount = Math.min(colorCount, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof quality === 'undefined' || Number.isInteger(quality)) {
|
if (typeof quality === 'undefined' || !Number.isInteger(quality) || quality < 1) {
|
||||||
quality = 10;
|
|
||||||
} else if (quality < 1) {
|
|
||||||
quality = 10;
|
quality = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user