🐳 chore(eslint): 修正所有文件的eslint 错误❌

This commit is contained in:
xuan
2022-11-28 11:06:15 +08:00
parent 99a920975f
commit cc99111b4f
149 changed files with 3270 additions and 3252 deletions
+29 -29
View File
@@ -1,4 +1,4 @@
module.exports = function(lab1, lab2) {
module.exports = function(lab1, lab2) {
const rgb2labArray1 = lab1
const rgb2labArray2 = lab2
@@ -10,35 +10,35 @@ module.exports = function(lab1, lab2) {
const a2 = rgb2labArray2[1]
const b2 = rgb2labArray2[2]
const avg_lp = (l1 + l2) / 2
const c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2))
const c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2))
const avg_c = (c1 + c2) / 2
const g = (1 - Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2
const avg_lp = (l1 + l2) / 2
const c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2))
const c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2))
const avg_c = (c1 + c2) / 2
const g = (1 - Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2
const a1p = a1 * (1 + g)
const a2p = a2 * (1 + g)
const a1p = a1 * (1 + g)
const a2p = a2 * (1 + g)
const c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2))
const c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2))
const c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2))
const c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2))
const avg_cp = (c1p + c2p) / 2
const avg_cp = (c1p + c2p) / 2
let h1p = rad2deg(Math.atan2(b1, a1p))
if (h1p < 0) {
let h1p = rad2deg(Math.atan2(b1, a1p))
if (h1p < 0) {
h1p = h1p + 360
}
let h2p = rad2deg(Math.atan2(b2, a2p))
if (h2p < 0) {
let h2p = rad2deg(Math.atan2(b2, a2p))
if (h2p < 0) {
h2p = h2p + 360
}
const avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2
const avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2
const t = 1 - 0.17 * Math.cos(deg2rad(avg_hp - 30)) + 0.24 * Math.cos(deg2rad(2 * avg_hp)) + 0.32 * Math.cos(deg2rad(3 * avg_hp + 6)) - 0.2 * Math.cos(deg2rad(4 * avg_hp - 63))
const t = 1 - 0.17 * Math.cos(deg2rad(avg_hp - 30)) + 0.24 * Math.cos(deg2rad(2 * avg_hp)) + 0.32 * Math.cos(deg2rad(3 * avg_hp + 6)) - 0.2 * Math.cos(deg2rad(4 * avg_hp - 63))
let delta_hp = h2p - h1p
let delta_hp = h2p - h1p
if (Math.abs(delta_hp) > 180) {
if (h2p <= h1p) {
delta_hp += 360
@@ -48,18 +48,18 @@ module.exports = function(lab1, lab2) {
}
}
const delta_lp = l2 - l1
const delta_cp = c2p - c1p
const delta_lp = l2 - l1
const delta_cp = c2p - c1p
delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2)
delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2)
const s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2)))
const s_c = 1 + 0.045 * avg_cp
const s_h = 1 + 0.015 * avg_cp * t
const s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2)))
const s_c = 1 + 0.045 * avg_cp
const s_h = 1 + 0.015 * avg_cp * t
const delta_ro = 30 * Math.exp(-(Math.pow((avg_hp - 275) / 25, 2)))
const r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7)))
const r_t = -r_c * Math.sin(2 * deg2rad(delta_ro))
const delta_ro = 30 * Math.exp(-(Math.pow((avg_hp - 275) / 25, 2)))
const r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7)))
const r_t = -r_c * Math.sin(2 * deg2rad(delta_ro))
const kl = 1; const kc = 1; const kh = 1
@@ -67,10 +67,10 @@ module.exports = function(lab1, lab2) {
return delta_e
function rad2deg(rad) {
function rad2deg(rad) {
return 360 * rad / (2 * Math.PI)
}
function deg2rad(deg) {
function deg2rad(deg) {
return (2 * Math.PI * deg) / 360
}
}
+10 -9
View File
@@ -1,4 +1,6 @@
/* eslint-disable import/no-commonjs */
const xyz = require('./xyz')
module.exports = {
@@ -17,7 +19,7 @@ module.exports = {
if (l <= 8) {
y = (l * 100) / 903.3
y2 = (7.787 * (y / 100)) + (16 / 116)
}
}
else {
y = 100 * Math.pow((l + 16) / 116, 3)
y2 = Math.pow(y / 100, 1 / 3)
@@ -32,11 +34,10 @@ module.exports = {
}
// extend xyz
xyz.lab = function(xyz) {
let x = xyz[0]
let y = xyz[1]
let z = xyz[2]
let l; let a; let b
xyz.lab = function(xyz1) {
let x = xyz1[0]
let y = xyz1[1]
let z = xyz1[2]
x /= 95.047
y /= 100
@@ -46,9 +47,9 @@ xyz.lab = function(xyz) {
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116)
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116)
l = (116 * y) - 16
a = 500 * (x - y)
b = 200 * (y - z)
const l = (116 * y) - 16
const a = 500 * (x - y)
const b = 200 * (y - z)
return [l, a, b]
}
+1
View File
@@ -1,3 +1,4 @@
/* eslint-disable import/no-commonjs */
module.exports = {
name: 'rgb',
+9 -7
View File
@@ -1,4 +1,6 @@
/* eslint-disable import/no-commonjs */
const rgb = require('./rgb')
const xyz = {
@@ -86,15 +88,15 @@ xyz.rgb = function(_xyz, white) {
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175)
b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878)
r = r > 0.0031308
r = r > 0.0031308
? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
: r = (r * 12.92)
g = g > 0.0031308
g = g > 0.0031308
? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
: g = (g * 12.92)
b = b > 0.0031308
b = b > 0.0031308
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
: b = (b * 12.92)
@@ -112,10 +114,10 @@ xyz.rgb = function(_xyz, white) {
*
* @return {Array} XYZ channels
*/
rgb.xyz = function(rgb, white) {
let r = rgb[0] / 255
let g = rgb[1] / 255
let b = rgb[2] / 255
rgb.xyz = function(rgb1, white) {
let r = rgb1[0] / 255
let g = rgb1[1] / 255
let b = rgb1[2] / 255
// assume sRGB
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92)
+8 -8
View File
@@ -55,11 +55,11 @@ export function uint8ArrayToHex(raw) {
}
// 二进制转字符串(ascii)
export function bufferToString(buffer) {
let str = ''
for (const code of buffer) {
if (code === 0) { break }
str += utf82string(code)
}
return str
}
// export function bufferToString(buffer) {
// let str = ''
// for (const code of buffer) {
// if (code === 0) { break }
// str += utf82string(code)
// }
// return str
// }