Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Commit fe66f93

Browse files
committed
Removed redundant parameter call form
1 parent 865bc68 commit fe66f93

File tree

7 files changed

+27
-32
lines changed

7 files changed

+27
-32
lines changed

Documentation/Conversions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@ Hue ranges from  `0 - 360` , all others range from  `0 - 255`
4141
| | HSL | HSLA |
4242
|:-:|:---:|:----:|
4343
| **Array** | ( [ H , S , L ] ) | ( [ H , S , L , A ] )
44-
| **Parameter** | ( H , S , L ) | ( H , S , L , A )
4544

4645
<br>

Documentation/Sources/HSL.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ import { fromHSL } from 'RGB'
99

1010
<br>
1111

12-
## Parameter
13-
14-
*Supply the channels directly.*
15-
16-
```JavaScript
17-
const rgb = fromHSL( H , S , L );
18-
```
19-
20-
<br>
21-
2212
## Array
2313

2414
*Pass the channels as an array.*
@@ -37,8 +27,4 @@ const rgb = fromHSL([ H , S , L ]);
3727
const rgba = fromHSL([ H , S , L , A ]);
3828
```
3929

40-
```JavaScript
41-
const rgba = fromHSL( H , S , L , A );
42-
```
43-
4430
<br>

Source/Sources/HSL.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ function toRGB([ Hue , Saturation , Lightness ]){
5555
* [ H , S , L , (A) ] -> [ R , G , B , (A) ]
5656
*/
5757

58-
export default function fromHSL(colors){
59-
60-
if(colors.length === 1 || (typeof colors[2] !== 'number'))
61-
colors = colors[0];
62-
58+
export default function fromHSL ( colors ){
59+
6360
const rgb = toRGB(colors);
6461

6562
const alpha = colors[3];

Source/Sources/Hex.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11

2-
3-
const { errors } = Deno;
4-
5-
const
6-
channels_single = /^#?([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})?$/i ,
7-
channels_double = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i ;
2+
import { HexSingleChannel , HexDoubleChannel } from './Regex.js'
83

94

105
const toNumber = ( string ) =>
@@ -34,8 +29,8 @@ export default function fromHex ( string ){
3429
*/
3530

3631
function findHex ( string ){
37-
return string.match(channels_double)
38-
?? string.match(channels_single) ;
32+
return string.match(HexDoubleChannel)
33+
?? string.match(HexSingleChannel) ;
3934
}
4035

4136

Source/Sources/Regex.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
/*
4+
* #0000
5+
* #000
6+
*/
7+
8+
export const HexSingleChannel =
9+
/^#?([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})?$/i;
10+
11+
12+
/*
13+
* #00000000
14+
* #000000
15+
*/
16+
17+
export const HexDoubleChannel =
18+
/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;

Source/mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export function fromHex (
2424
*
2525
* Alpha channel can be included and won't be altered.
2626
*
27-
* @param color Either ( H , S , L , (A) ) or ([ H , S , L , (A) ])
27+
* @param color ([ H , S , L , (A) ])
2828
* @return A HSL(A) color array
2929
*/
3030

3131
export function fromHSL (
32-
... color : number [] | number[][]
32+
color : number []
3333
) : number [] {
3434
return HSL( color ) as number [];
3535
}

Tests/AssertColor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { fromHex , fromHSL } from 'RGB'
44
import { assertEquals } from 'Assert'
55

66

7-
export function assertHexIsRGB(input,output){
7+
export function assertHexIsRGB( input , output ){
88
assertEquals(fromHex(input),output);
99
}
1010

1111

12-
export function assertHSLIsRGB(input,output){
12+
export function assertHSLIsRGB( input , output ){
1313
assertEquals(fromHSL(input),output);
1414
}

0 commit comments

Comments
 (0)