Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
hex-to-rgba
Advanced tools
hex-to-rgba
turns an old-fashioned css hex color value string into an rgba() string.
Optionally pass in an alpha value. The passed alpha value will override any alpha value from 4- or 8-digit hexes. If you don't pass in an alpha value at all, we will default to an alpha value of 1 (completely opaque).
Supports 3-, 4-, 6- and 8-digit hex values with or without a leading hash.
$ npm install --save hex-to-rgba
or
$ yarn add hex-to-rgba
import hexToRgba from 'hex-to-rgba';
// Or if you're so inclined:
// var hexToRgba = require("hex-to-rgba");
hexToRgba('112233'); // "rgba(17, 34, 51, 1)"
hexToRgba('#112233'); // "rgba(17, 34, 51, 1)"
hexToRgba('112233', '0.5'); // "rgba(17, 34, 51, 0.5)"
hexToRgba('#112233', 0.75); // "rgba(17, 34, 51, 0.75)"
hexToRgba('11223344') // "rgba(17, 34, 51, 0.27)"
hexToRgba('#11223344') // "rgba(17, 34, 51, 0.27)"
hexToRgba('11223344', '0.5') // "rgba(17, 34, 51, 0.5)"
hexToRgba('#11223344', 0.75) // "rgba(17, 34, 51, 0.75)"
hexToRgba('123'); // "rgba(17, 34, 51, 1)"
hexToRgba('#123'); // "rgba(17, 34, 51, 1)"
hexToRgba('123', 0.2) // "rgba(17, 34, 51, 0.2)"
hexToRgba('#123', 0.2) // "rgba(17, 34, 51, 0.2)"
hexToRgba('1234'); // "rgba(17, 34, 51, 0.27)"
hexToRgba('#1234'); // "rgba(17, 34, 51, 0.27)"
hexToRgba('1234', 0.5) // "rgba(17, 34, 51, 0.5)"
hexToRgba('#1234', 0.75) // "rgba(17, 34, 51, 0.75)"
hexToRgba(hex, a=1)
Returns an rgba() string. (examples: 'rgba(11, 22, 33, 1)'
, 'rgba(11, 22, 33, 0.5)'
)
hex
: The hex color value to convert to rgba. (examples: '123456'
, '#123456'
, '123'
, '#123'
)a
: An alpha value to apply. (optional, default: 1) (examples: '0.5'
, 0.25
)I appreciate your issues and PRs on Github!
yarn build && yarn test
This project uses np.
yarn release
See the releases page on GitHub.
FAQs
Converts hexadecimal color codes to rgb()/rgba() values.
The npm package hex-to-rgba receives a total of 45,233 weekly downloads. As such, hex-to-rgba popularity was classified as popular.
We found that hex-to-rgba demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.