New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

daily-color

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daily-color - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

dist/daily-color.js

7

CHANGELOG.md
# Changelog
## [1.1.0](https://github.com/aimeerivers/daily-color/compare/v1.0.1...v1.1.0) (2024-11-09)
### Features
* Provide a webpack bundle, for projects that don't use NPM ([#6](https://github.com/aimeerivers/daily-color/issues/6)) ([6d53597](https://github.com/aimeerivers/daily-color/commit/6d535973e9f8f601bf4e908911665eb9fda5ee67))
## [1.0.1](https://github.com/aimeerivers/daily-color/compare/v1.0.0...v1.0.1) (2024-11-09)

@@ -4,0 +11,0 @@

30

index.js

@@ -1,11 +0,29 @@

const crypto = require("crypto");
function getDailyColor() {
const date = new Date().toISOString().split("T")[0];
const hash = crypto.createHash("sha256").update(date).digest("hex");
const color = `#${hash.slice(0, 6)}`;
const date = new Date();
const hash = getSimpleHash(date);
return color;
const r = (hash >> 16) & 0xff; // Red
const g = (hash >> 8) & 0xff; // Green
const b = hash & 0xff; // Blue
return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
}
function getSimpleHash(date) {
const day = date.getDate();
const month = date.getMonth() + 1; // getMonth() is zero-based
const year = date.getFullYear();
const dateString = `${year}-${month}-${day}`;
let hash = 0;
// Simple hash function: Iterate over each character in the date string
for (let i = 0; i < dateString.length; i++) {
hash = (hash << 5) - hash + dateString.charCodeAt(i); // hash * 31 + charCodeAt
hash |= 0; // Convert to 32-bit integer
}
return Math.abs(hash);
}
module.exports = getDailyColor;

9

package.json
{
"name": "daily-color",
"version": "1.0.1",
"version": "1.1.0",
"description": "Provides a unique hex code each day",

@@ -32,8 +32,11 @@ "keywords": [

"package:lint": "npx npm-package-json-lint .",
"test": "node test/index.js"
"test": "node test/index.js",
"webpack": "npx webpack"
},
"devDependencies": {
"eslint-config-plus-prettier": "1.7.1"
"eslint-config-plus-prettier": "1.7.1",
"webpack": "5.96.1",
"webpack-cli": "5.1.4"
},
"prettier": "eslint-config-plus-prettier/.prettierrc.json"
}

@@ -18,3 +18,3 @@ # daily-color

console.log("Today's color is: ", getDailyColor());
console.log("Today's color is:", getDailyColor());
```

@@ -42,2 +42,8 @@

Compile the dist code, for projects without NPM:
```bash
npm run webpack
```
The project uses ESLint and Prettier to ensure consistent coding standards.

@@ -44,0 +50,0 @@

Sorry, the diff of this file is not supported yet

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