Skip to content

Commit

Permalink
pref: optimize test (#341)
Browse files Browse the repository at this point in the history
* refactor: use tsup

* chore: add license

* refactor: use build file to test

* chore: update

* chore: test adjustment

* test: alias chroma-js

* chore: lint update

* chore: update

* ci: add test ci

* chore: update

* ci: test windows different

* ci: patch windows

* chore: update regex

* chore: abandon tsup

* chore: update

* chore: update

* chore: remove ci

* chore: update

---------

Co-authored-by: Chris <[email protected]>
  • Loading branch information
zyyv and Chris committed Aug 9, 2024
1 parent 8776145 commit 6622770
Show file tree
Hide file tree
Showing 54 changed files with 345 additions and 251 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@

readme (Autosaved).md

m.txt

.DS_Store
license.coffee
node_modules

yarn.lock
27 changes: 19 additions & 8 deletions dist/chroma-light.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
* @preserve
*/

(function (factory) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
factory();
})((function () { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory());
})(this, (function () { 'use strict';

function limit (x, low, high) {
if ( high === void 0 ) high = 1;
Expand Down Expand Up @@ -1062,12 +1063,22 @@
// register interpolator
index.oklab = oklab;

// generators -- > create new colors
chroma.mix = chroma.interpolate = require('./src/generator/mix');
function valid () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

try {
new (Function.prototype.bind.apply( Color, [ null ].concat( args) ));
return true;
// eslint-disable-next-line
} catch (e) {
return false;
}
}

// other utility methods
chroma.valid = require('./src/utils/valid');
chroma.mix = chroma.interpolate = mix;
chroma.valid = valid;

module.exports = chroma;
return chroma;

}));
2 changes: 1 addition & 1 deletion dist/chroma-light.min.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default [...compat.extends("eslint:recommended"), {
globals: {
...globals.browser,
...globals.commonjs,
'__dirname': 'readonly',
},

parser: babelParser,
Expand All @@ -32,4 +33,4 @@ export default [...compat.extends("eslint:recommended"), {
rules: {
"no-sequences": "error",
},
}];
}];
8 changes: 5 additions & 3 deletions index-light.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import './src/interpolator/lrgb.js';
import './src/interpolator/oklab.js';

// generators -- > create new colors
chroma.mix = chroma.interpolate = require('./src/generator/mix');
import mix from './src/generator/mix';
chroma.mix = chroma.interpolate = mix;

// other utility methods
chroma.valid = require('./src/utils/valid');
import valid from './src/utils/valid';
chroma.valid = valid;

module.exports = chroma;
export default chroma;
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "chroma-js",
"description": "JavaScript library for color conversions",
"version": "2.6.0",
"packageManager": "[email protected]",
"author": "Gregor Aisch",
"type": "module",
"homepage": "https://github.com/gka/chroma.js",
Expand Down Expand Up @@ -32,8 +33,8 @@
"build": "rollup -c && cross-env DEV=1 rollup -c ",
"docs": "cd docs && make",
"docs-preview": "cd docs && make && make preview",
"test": "vitest test/*.js",
"test:old": "vows --dot-matrix test/*.cjs",
"test": "vitest",
"test:update": "vitest -u",
"lint": "prettier --check index.js index-light.js src *.config.js test && eslint index.js index-light.js src",
"format": "prettier --write index.js index-light.js src *.config.js test",
"prepare": "husky"
Expand All @@ -45,7 +46,6 @@
"@rollup/plugin-buble": "^1.0.3",
"@rollup/plugin-terser": "^0.4.4",
"cross-env": "^7.0.3",
"es6-shim": "^0.35.8",
"eslint": "^9.8.0",
"globals": "^15.8.0",
"http-server": "^14.1.1",
Expand All @@ -55,8 +55,7 @@
"prettier": "^3.3.3",
"rollup": "^4.19.1",
"rollup-plugin-license": "^3.5.2",
"vitest": "^2.0.4",
"vows": "^0.8.3"
"vitest": "^2.0.4"
},
"license": "(BSD-3-Clause AND Apache-2.0)",
"spm": {
Expand Down
Loading

0 comments on commit 6622770

Please sign in to comment.