Skip to content

Commit 4fad168

Browse files
committed
Codemod unnamed default exports to have names
This makes debugging that much easier when functions have names instead of just being <anonymous>. Using facebook/create-react-app#8924 (comment)
1 parent db14c64 commit 4fad168

File tree

116 files changed

+464
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+464
-116
lines changed

src/_prepare.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import parse from './parse';
22

3-
export default (color, mode) =>
3+
const prepare = (color, mode) =>
44
color === undefined
55
? undefined
66
: typeof color !== 'object'
@@ -10,3 +10,5 @@ export default (color, mode) =>
1010
: mode
1111
? { ...color, mode }
1212
: undefined;
13+
14+
export default prepare;

src/a98/convertA98ToXyz65.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
const linearize = v => Math.pow(Math.abs(v), 563 / 256) * Math.sign(v);
1111

12-
export default a98 => {
12+
const convertA98ToXyz65 = a98 => {
1313
let r = linearize(a98.r);
1414
let g = linearize(a98.g);
1515
let b = linearize(a98.b);
@@ -33,3 +33,5 @@ export default a98 => {
3333
}
3434
return res;
3535
};
36+
37+
export default convertA98ToXyz65;

src/a98/convertXyz65ToA98.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
const gamma = v => Math.pow(Math.abs(v), 256 / 563) * Math.sign(v);
1010

11-
export default ({ x, y, z, alpha }) => {
11+
const convertXyz65ToA98 = ({ x, y, z, alpha }) => {
1212
let res = {
1313
mode: 'a98',
1414
r: gamma(
@@ -32,3 +32,5 @@ export default ({ x, y, z, alpha }) => {
3232
}
3333
return res;
3434
};
35+
36+
export default convertXyz65ToA98;

src/a98/definition.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ import convertXyz65ToA98 from './convertXyz65ToA98';
55
import convertRgbToXyz65 from '../xyz65/convertRgbToXyz65';
66
import convertXyz65ToRgb from '../xyz65/convertXyz65ToRgb';
77

8-
export default {
8+
const definition = {
99
...rgb,
1010
mode: 'a98',
1111
alias: ['a98-rgb'],
1212
parsers: [],
13+
1314
input: {
1415
rgb: color => convertXyz65ToA98(convertRgbToXyz65(color)),
1516
xyz65: convertXyz65ToA98
1617
},
18+
1719
output: {
1820
rgb: color => convertXyz65ToRgb(convertA98ToXyz65(color)),
1921
xyz65: convertA98ToXyz65
2022
}
2123
};
24+
25+
export default definition;

src/blend.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const BLENDS = {
3434
exclusion: (b, s) => b + s - 2 * b * s
3535
};
3636

37-
export default (colors, type = 'normal', mode = 'rgb') => {
37+
const blend = (colors, type = 'normal', mode = 'rgb') => {
3838
let fn = typeof type === 'function' ? type : BLENDS[type];
3939

4040
let conv = converter(mode);
@@ -77,3 +77,5 @@ export default (colors, type = 'normal', mode = 'rgb') => {
7777
);
7878
});
7979
};
80+
81+
export default blend;

src/colors/named.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const named = {
22
aliceblue: 0xf0f8ff,
33
antiquewhite: 0xfaebd7,
44
aqua: 0x00ffff,
@@ -118,9 +118,11 @@ export default {
118118
plum: 0xdda0dd,
119119
powderblue: 0xb0e0e6,
120120
purple: 0x800080,
121+
121122
// Added in CSS Colors Level 4:
122123
// https://drafts.csswg.org/css-color/#changes-from-3
123124
rebeccapurple: 0x663399,
125+
124126
red: 0xff0000,
125127
rosybrown: 0xbc8f8f,
126128
royalblue: 0x4169e1,
@@ -150,3 +152,5 @@ export default {
150152
yellow: 0xffff00,
151153
yellowgreen: 0x9acd32
152154
};
155+
156+
export default named;

src/cubehelix/convertCubehelixToRgb.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { degToRad, M } from './constants';
22

3-
export default ({ h, s, l, alpha }) => {
3+
const convertCubehelixToRgb = ({ h, s, l, alpha }) => {
44
let res = { mode: 'rgb' };
55

66
h = (h === undefined ? 0 : h + 120) * degToRad;
@@ -17,3 +17,5 @@ export default ({ h, s, l, alpha }) => {
1717
if (alpha !== undefined) res.alpha = alpha;
1818
return res;
1919
};
20+
21+
export default convertCubehelixToRgb;

src/cubehelix/convertRgbToCubehelix.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let DE = M[3] * M[4];
1717
let BE = M[1] * M[4];
1818
let BCAD = M[1] * M[2] - M[0] * M[3];
1919

20-
export default ({ r, g, b, alpha }) => {
20+
const convertRgbToCubehelix = ({ r, g, b, alpha }) => {
2121
let l = (BCAD * b + r * DE - g * BE) / (BCAD + DE - BE);
2222
let x = b - l;
2323
let y = (M[4] * (g - l) - M[2] * x) / M[3];
@@ -36,3 +36,5 @@ export default ({ r, g, b, alpha }) => {
3636

3737
return res;
3838
};
39+
40+
export default convertRgbToCubehelix;

src/cubehelix/definition.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@ import convertCubehelixToRgb from './convertCubehelixToRgb';
3939
import { differenceHueSaturation } from '../difference';
4040
import { averageAngle } from '../average';
4141

42-
export default {
42+
const definition = {
4343
mode: 'cubehelix',
4444
channels: ['h', 's', 'l', 'alpha'],
45+
4546
ranges: {
4647
h: [0, 360],
4748
s: [0, 4.6143]
4849
},
50+
4951
input: {
5052
rgb: convertRgbToCubehelix
5153
},
54+
5255
output: {
5356
rgb: convertCubehelixToRgb
5457
},
58+
5559
interpolate: {
5660
h: {
5761
use: interpolatorLinear,
@@ -64,10 +68,14 @@ export default {
6468
fixup: fixupAlpha
6569
}
6670
},
71+
6772
difference: {
6873
h: differenceHueSaturation
6974
},
75+
7076
average: {
7177
h: averageAngle
7278
}
7379
};
80+
81+
export default definition;

src/displayable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import converter from './converter';
22

33
let rgb = converter('rgb');
44

5-
export default color => {
5+
const displayable = color => {
66
let c = rgb(color);
77
return (
88
c !== undefined &&
@@ -14,3 +14,5 @@ export default color => {
1414
c.b <= 1
1515
);
1616
};
17+
18+
export default displayable;

src/dlab/convertDlabToLab65.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import convertDlabToDlch from '../dlch/convertDlabToDlch';
22
import convertDlchToLab65 from '../dlch/convertDlchToLab65';
33

4-
export default c => convertDlchToLab65(convertDlabToDlch(c));
4+
const convertDlabToLab65 = c => convertDlchToLab65(convertDlabToDlch(c));
5+
6+
export default convertDlabToLab65;

src/dlab/convertLab65ToDlab.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import convertLab65ToDlch from '../dlch/convertLab65ToDlch';
22
import convertDlchToDlab from '../dlch/convertDlchToDlab';
33

4-
export default c => convertDlchToDlab(convertLab65ToDlch(c));
4+
const convertLab65ToDlab = c => convertDlchToDlab(convertLab65ToDlch(c));
5+
6+
export default convertLab65ToDlab;

src/dlab/definition.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ import convertRgbToLab65 from '../lab65/convertRgbToLab65';
55
import { interpolatorLinear } from '../interpolate/linear';
66
import { fixupAlpha } from '../fixup/alpha';
77

8-
export default {
8+
const definition = {
99
mode: 'dlab',
10+
1011
output: {
1112
lab65: convertDlabToLab65,
1213
rgb: c => convertLab65ToRgb(convertDlabToLab65(c))
1314
},
15+
1416
input: {
1517
lab65: convertLab65ToDlab,
1618
rgb: c => convertLab65ToDlab(convertRgbToLab65(c))
1719
},
20+
1821
channels: ['l', 'a', 'b', 'alpha'],
22+
1923
ranges: {
2024
l: [0, 100],
2125
a: [-40.09, 45.5],
2226
b: [-40.47, 44.344]
2327
},
28+
2429
interpolate: {
2530
l: interpolatorLinear,
2631
a: interpolatorLinear,
@@ -31,3 +36,5 @@ export default {
3136
}
3237
}
3338
};
39+
40+
export default definition;

src/dlch/convertDlabToDlch.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import normalizeHue from '../util/normalizeHue';
22

3-
export default ({ l, a, b, alpha }) => {
3+
const convertDlabToDlch = ({ l, a, b, alpha }) => {
44
let c = Math.sqrt(a * a + b * b);
55
let res = {
66
mode: 'dlch',
@@ -11,3 +11,5 @@ export default ({ l, a, b, alpha }) => {
1111
if (alpha !== undefined) res.alpha = alpha;
1212
return res;
1313
};
14+
15+
export default convertDlabToDlch;

src/dlch/convertDlchToDlab.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default ({ l, c, h, alpha }) => {
1+
const convertDlchToDlab = ({ l, c, h, alpha }) => {
22
let res = {
33
mode: 'dlab',
44
l: l,
@@ -8,3 +8,5 @@ export default ({ l, c, h, alpha }) => {
88
if (alpha !== undefined) res.alpha = alpha;
99
return res;
1010
};
11+
12+
export default convertDlchToDlab;

src/dlch/convertDlchToLab65.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { kCH, kE, sinθ, cosθ, θ, factor } from './constants';
55
--------------------------------
66
*/
77

8-
export default ({ l, c, h, alpha }) => {
8+
const convertDlchToLab65 = ({ l, c, h, alpha }) => {
99
let res = {
1010
mode: 'lab65',
1111
l: (Math.exp((l * kE) / factor) - 1) / 0.0039
@@ -24,3 +24,5 @@ export default ({ l, c, h, alpha }) => {
2424
if (alpha !== undefined) res.alpha = alpha;
2525
return res;
2626
};
27+
28+
export default convertDlchToLab65;

src/dlch/convertLab65ToDlch.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import normalizeHue from '../util/normalizeHue';
66
================================
77
*/
88

9-
export default ({ l, a, b, alpha }) => {
9+
const convertLab65ToDlch = ({ l, a, b, alpha }) => {
1010
let e = a * cosθ + b * sinθ;
1111
let f = 0.83 * (b * cosθ - a * sinθ);
1212
let G = Math.sqrt(e * e + f * f);
@@ -23,3 +23,5 @@ export default ({ l, a, b, alpha }) => {
2323
if (alpha !== undefined) res.alpha = alpha;
2424
return res;
2525
};
26+
27+
export default convertLab65ToDlch;

src/dlch/definition.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,29 @@ import { interpolatorLinear } from '../interpolate/linear';
1111
import { differenceHueChroma } from '../difference';
1212
import { averageAngle } from '../average';
1313

14-
export default {
14+
const definition = {
1515
mode: 'dlch',
16+
1617
output: {
1718
lab65: convertDlchToLab65,
1819
dlab: convertDlchToDlab,
1920
rgb: c => convertLab65ToRgb(convertDlchToLab65(c))
2021
},
22+
2123
input: {
2224
lab65: convertLab65ToDlch,
2325
dlab: convertDlabToDlch,
2426
rgb: c => convertLab65ToDlch(convertRgbToLab65(c))
2527
},
28+
2629
channels: ['l', 'c', 'h', 'alpha'],
30+
2731
ranges: {
2832
l: [0, 100],
2933
c: [0, 51.484],
3034
h: [0, 360]
3135
},
36+
3237
interpolate: {
3338
l: interpolatorLinear,
3439
c: interpolatorLinear,
@@ -41,10 +46,14 @@ export default {
4146
fixup: fixupAlpha
4247
}
4348
},
49+
4450
difference: {
4551
h: differenceHueChroma
4652
},
53+
4754
average: {
4855
h: averageAngle
4956
}
5057
};
58+
59+
export default definition;

src/easing/gamma.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export default (γ = 1) => (γ === 1 ? t => t : t => Math.pow(t, γ));
1+
const gamma = (γ = 1) => (γ === 1 ? t => t : t => Math.pow(t, γ));
2+
3+
export default gamma;

src/easing/inOutSine.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*
22
Sinusoidal (cosine) in-out easing
33
*/
4-
export default t => (1 - Math.cos(t * Math.PI)) / 2;
4+
const inOutSine = t => (1 - Math.cos(t * Math.PI)) / 2;
5+
6+
export default inOutSine;

src/easing/midpoint.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
// Color interpolation hint exponential function
2-
export default (H = 0.5) => t =>
2+
const midpoint = (H = 0.5) => t =>
33
H <= 0 ? 1 : H >= 1 ? 0 : Math.pow(t, Math.log(0.5) / Math.log(H));
4+
5+
export default midpoint;

src/easing/smootherstep.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
Smootherstep easing function proposed by K. Perlin
33
Reference: https://en.wikipedia.org/wiki/Smoothstep
44
*/
5-
export default t => t * t * t * (t * (t * 6 - 15) + 10);
5+
const smootherstep = t => t * t * t * (t * (t * 6 - 15) + 10);
6+
7+
export default smootherstep;

src/easing/smoothstep.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
Smoothstep easing function.
33
Reference: https://en.wikipedia.org/wiki/Smoothstep
44
*/
5-
export default t => t * t * (3 - 2 * t);
5+
const smoothstep = t => t * t * (3 - 2 * t);
6+
7+
export default smoothstep;

src/hsi/convertHsiToRgb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import normalizeHue from '../util/normalizeHue';
22

33
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
44

5-
export default function ({ h, s, i, alpha }) {
5+
export default function convertHsiToRgb({ h, s, i, alpha }) {
66
h = normalizeHue(h);
77
let f = Math.abs(((h / 60) % 2) - 1);
88
let res;

src/hsi/convertRgbToHsi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
22

3-
export default function ({ r, g, b, alpha }) {
3+
export default function convertRgbToHsi({ r, g, b, alpha }) {
44
let M = Math.max(r, g, b),
55
m = Math.min(r, g, b);
66
let res = {

0 commit comments

Comments
 (0)