@deckdeckgo/utils
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,9 @@ | ||
<a name="1.3.0"></a> | ||
# 1.3.0 (2020-08-15) | ||
- improve `extractRgb` to support decimals value (as for example `rgb(5.5, 4.7, 4)`) | ||
- expose function `extractRgb` | ||
- add and expose function `extractRgba` | ||
<a name="1.2.0"></a> | ||
@@ -2,0 +10,0 @@ |
@@ -152,13 +152,22 @@ 'use strict'; | ||
}; | ||
const extractRgb = (rgb) => { | ||
const match = rgb.match(/(\d+),\s*(\d+),\s*(\d+)/); | ||
if (!match) { | ||
return undefined; | ||
} | ||
return match.splice(1, 3).map((v) => Number(v)); | ||
}; | ||
return toHex(extractRgb(rgb)); | ||
} | ||
function extractRgb(rgb) { | ||
const match = rgb.match(/([.\d]+),\s*([.\d]+),\s*([.\d]+)/); | ||
if (!match) { | ||
return undefined; | ||
} | ||
return match.splice(1, 3).map((v) => Number(v)); | ||
} | ||
function extractRgba(rgb) { | ||
const match = rgb.match(/([.\d]+),\s*([.\d]+),\s*([.\d]+),\s*([.\d]+)/); | ||
if (!match) { | ||
return undefined; | ||
} | ||
return match.splice(1, 4).map((v) => Number(v)); | ||
} | ||
exports.debounce = debounce; | ||
exports.extractRgb = extractRgb; | ||
exports.extractRgba = extractRgba; | ||
exports.hexToRgb = hexToRgb; | ||
@@ -165,0 +174,0 @@ exports.injectCSS = injectCSS; |
export declare function hexToRgb(hex: string): Promise<string | undefined>; | ||
export declare function rgbToHex(rgb: string | undefined): Promise<string | undefined>; | ||
export declare function extractRgb(rgb: string): number[] | undefined; | ||
export declare function extractRgba(rgb: string): number[] | undefined; |
@@ -18,10 +18,17 @@ export async function hexToRgb(hex) { | ||
}; | ||
const extractRgb = (rgb) => { | ||
const match = rgb.match(/(\d+),\s*(\d+),\s*(\d+)/); | ||
if (!match) { | ||
return undefined; | ||
} | ||
return match.splice(1, 3).map((v) => Number(v)); | ||
}; | ||
return toHex(extractRgb(rgb)); | ||
} | ||
export function extractRgb(rgb) { | ||
const match = rgb.match(/([.\d]+),\s*([.\d]+),\s*([.\d]+)/); | ||
if (!match) { | ||
return undefined; | ||
} | ||
return match.splice(1, 3).map((v) => Number(v)); | ||
} | ||
export function extractRgba(rgb) { | ||
const match = rgb.match(/([.\d]+),\s*([.\d]+),\s*([.\d]+),\s*([.\d]+)/); | ||
if (!match) { | ||
return undefined; | ||
} | ||
return match.splice(1, 4).map((v) => Number(v)); | ||
} |
{ | ||
"name": "@deckdeckgo/utils", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "David Dal Busco", | ||
@@ -5,0 +5,0 @@ "description": "A collection of utils methods and functions developed for DeckDeckGo", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20525
376