Skip to content

Commit

Permalink
🐛 fix: fixed sortBy() utility (fix #214)
Browse files Browse the repository at this point in the history
fix #214
  • Loading branch information
Dean Tarisai committed Jul 31, 2024
1 parent c2f1afd commit c4be897
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

(c) 2024 Dean Tarisai & xml-wizard contributors
(c) 2023 - present ディーン・タリサイ
huetiful-js
-> Function oriented JavaScript library for color manipulation
-> JavaScript utility library for simple 🧮, fast ⏱️ and accessible ♿ color manipulation.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
28 changes: 14 additions & 14 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ var all300 = [
"#fda4af",
],
hueshiftPalette = [
"#3f0101ff",
"#2b1800ff",
"#002620ff",
"#2f1500ff",
"#321300ff",
"#3f0007ff",
"#3e0000ff",
"#561a17ff",
"#743356ff",
"#915077ff",
"#268fadff",
"#cb8ebeff",
"#fcaca7ff",
"#000080ff",
"#0a0086ff",
"#19008dff",
"#230093ff",
"#2c0099ff",
"#3500a0ff",
"#3e00a6ff",
"#b70029ff",
"#d6003dff",
"#f60053ff",
"#ff1b6aff",
"#ff4b82ff",
"#ff6d9cff",
],
filterBysample = [
"#94a3b8",
Expand Down Expand Up @@ -143,7 +143,7 @@ var specs = {
hueshift: {
params: ["#3e00a6"],
description: "Generates a palette of hue shifted colors",
expect: jasmine.arrayContaining(hueshiftPalette),
expect: hueshiftPalette,
},
interpolator: {
params: [
Expand Down
2 changes: 1 addition & 1 deletion src/generators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function pastel(baseColor, options = undefined) {
// check if it is displayable

// @ts-ignore
return or(and(options, token(q, options)), q);
return token(q, options);
}

/**
Expand Down
38 changes: 15 additions & 23 deletions src/internal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,21 @@ function wtf(
z,
y = ["hue", "chroma", "lightness", "distance", "contrast", "luminance"]
) {
var p = {};
let p = {};

if (isArray(t)) {
for (const k of values(t)) {
p[k] = z(k);
}
} else if (eq(typeof t, "string")) {
p = z(t);
} else {
for (const k of y) {
p[k] = z(k);
}
}
// if factor is an array add each factor as a key to the object
return or(
or(
and(
isArray(t),
(() => {
for (const k of values(t)) {
p[k] = z(k);
}
})()
),
and(t?.toLowerCase(), (p = z(t)))
),
and(
not(t),
(() => {
for (const k of y) {
p[k] = z(k);
}
})()
)
);
return p;
}

let [ci, ef, hf, hi, li] = [
Expand Down Expand Up @@ -405,7 +397,7 @@ function max(x) {
return x.reduce((a, b) => Math.max(a, b), -Infinity);
}

function reNum(s) {
function reNum(s = "") {
s = s.toString();
var re = /[0-9]*\.?[0-9]+/;
// @ts-ignore
Expand Down

0 comments on commit c4be897

Please sign in to comment.