diff --git a/README.md b/README.md index 4df1935..5e65f03 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,35 @@ -# stub-repo · [![Test workflow status](https://github.com/ChrisCodesThings/stub-repo/actions/workflows/test.yml/badge.svg)](../../actions/workflows/test.yml) [![NPM Version](https://img.shields.io/npm/v/@chriscodesthings/stub-repo)](https://www.npmjs.com/package/@chriscodesthings/stub-repo) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) +# rgb-color-yiq-value · [![Test workflow status](https://github.com/ChrisCodesThings/rgb-color-yiq-value/actions/workflows/test.yml/badge.svg)](../../actions/workflows/test.yml) [![NPM Version](https://img.shields.io/npm/v/@chriscodesthings/rgb-color-yiq-value)](https://www.npmjs.com/package/@chriscodesthings/rgb-color-yiq-value) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) -> **Function to determine if something is a string type** +> **Calculate the YIQ value of a color in RGB format** ## Install ```sh -npm install --save @chriscodesthings/stub-repo +npm install --save @chriscodesthings/rgb-color-yiq-value ``` ## Use ```js -import stubRepo from '@chriscodesthings/stub-repo'; +import isString from '@chriscodesthings/rgb-color-yiq-value'; -console.log(stubRepo("hello world!")); -// => true +console.log(rgbYIQValue(102,153,255)); +// => 149.379 ``` ## Syntax ```js -stubRepo(var); +rgbYIQValue(r, g, b); ``` ### Parameters -- *var*: any +- *r, g, b*: red green and blue color components ### Return Value -Returns something probably. +Returns calculated YIQ value of the color. ## Description diff --git a/index.js b/index.js index ee83d8c..4e87ad2 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,2 @@ -export { default } from "./src/stubRepo.js"; +export { default } from "./src/rgbColorYIQValue.js"; diff --git a/package-lock.json b/package-lock.json index d5cf92a..5a069a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@chriscodesthings/stub-repo", - "version": "1.0.1", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@chriscodesthings/stub-repo", - "version": "1.0.1", + "version": "0.1.0", "license": "MIT", "devDependencies": { "auto-changelog": "*", diff --git a/package.json b/package.json index 6999e2c..99ddd32 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "@chriscodesthings/stub-repo", + "name": "@chriscodesthings/rgb-color-yiq-value", "version": "0.1.0", - "description": "npm package template", + "description": "Calculate the YIQ value of a color in RGB format", "keywords": [ - "stub", - "package", - "template" + "rgb", + "color", + "yiq" ], "repository": { "type": "git", - "url": "git+https://github.com/ChrisCodesThings/stub-repo.git" + "url": "git+https://github.com/ChrisCodesThings/rgb-color-yiq-value.git" }, "main": "index.js", "type": "module", @@ -23,7 +23,7 @@ "node": ">=18.0.0" }, "bugs": { - "url": "https://github.com/ChrisCodesThings/stub-repo/issues" + "url": "https://github.com/ChrisCodesThings/rgb-color-yiq-value/issues" }, "scripts": { "test": "NODE_OPTIONS='--experimental-vm-modules' jest", diff --git a/src/rgbColorYIQValue.js b/src/rgbColorYIQValue.js new file mode 100644 index 0000000..0164830 --- /dev/null +++ b/src/rgbColorYIQValue.js @@ -0,0 +1,4 @@ + +export default function (r, g, b) { + return ((r * 299) + (g * 587) + (b * 114)) / 1000; +} diff --git a/src/stubRepo.js b/src/stubRepo.js deleted file mode 100644 index dd98697..0000000 --- a/src/stubRepo.js +++ /dev/null @@ -1,5 +0,0 @@ - -export default function () { - console.log("Hello world!"); - return true; -} diff --git a/tests/index.test.js b/tests/index.test.js index bcb22a8..12d3989 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -1,8 +1,9 @@ const { default: testFunc } = await import("../"); -describe("testing my module", () => { - test("expect function to return true", async () => { - expect(testFunc()).toEqual(true); +describe("let's check the value of cornflowerblue", () => { + test("checking YIQ value", async () => { + expect(testFunc(102, 153, 255)).toEqual(149.379); }); }); +