Socket
Socket
Sign inDemoInstall

@deckdeckgo/utils

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deckdeckgo/utils - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

8

CHANGELOG.md

@@ -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 @@

23

lib/index.cjs.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc