i-qamar-eon-simple-color-converter 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -0
- package/dist/index.js +21 -0
- package/package.json +21 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a Hex color string to an RGB object.
|
|
3
|
+
* @param hex - The hex color string (e.g., "#ff0000" or "ff0000")
|
|
4
|
+
* @returns An object with r, g, b values or null if invalid.
|
|
5
|
+
*/
|
|
6
|
+
export declare const hexToRgb: (hex: string) => {
|
|
7
|
+
r: number;
|
|
8
|
+
g: number;
|
|
9
|
+
b: number;
|
|
10
|
+
} | null;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hexToRgb = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Converts a Hex color string to an RGB object.
|
|
6
|
+
* @param hex - The hex color string (e.g., "#ff0000" or "ff0000")
|
|
7
|
+
* @returns An object with r, g, b values or null if invalid.
|
|
8
|
+
*/
|
|
9
|
+
const hexToRgb = (hex) => {
|
|
10
|
+
// Remove the hash if present
|
|
11
|
+
hex = hex.replace(/^#/, "");
|
|
12
|
+
// Parse the values
|
|
13
|
+
if (hex.length === 6) {
|
|
14
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
15
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
16
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
17
|
+
return { r, g, b };
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
exports.hexToRgb = hexToRgb;
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "i-qamar-eon-simple-color-converter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"type": "commonjs",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.9.3"
|
|
20
|
+
}
|
|
21
|
+
}
|