Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
The rgba-regex npm package provides a regular expression for matching RGBA color strings. This can be useful for validating, parsing, or extracting RGBA color values from strings in various applications.
Match RGBA color strings
This feature allows you to match RGBA color strings within a larger string. The code sample demonstrates how to use the rgba-regex package to find an RGBA color string in a CSS declaration.
const rgbaRegex = require('rgba-regex');
const str = 'background-color: rgba(255, 99, 71, 0.5);';
const match = str.match(rgbaRegex());
console.log(match); // ['rgba(255, 99, 71, 0.5)']
Validate RGBA color strings
This feature allows you to validate whether a given string is a valid RGBA color string. The code sample shows how to use the rgba-regex package to check if a string is a valid RGBA color.
const rgbaRegex = require('rgba-regex');
const isValidRgba = rgbaRegex().test('rgba(255, 99, 71, 0.5)');
console.log(isValidRgba); // true
The color-string package provides utilities for parsing and generating color strings, including RGBA. It offers more comprehensive functionality compared to rgba-regex, such as converting between different color formats (e.g., RGB, HSL) and manipulating color values.
The css-color-function package allows you to transform CSS color functions, including RGBA. It provides more advanced features for color manipulation and transformation, making it more versatile than rgba-regex for complex color operations.
The color package is a comprehensive library for color conversion and manipulation. It supports a wide range of color formats, including RGBA, and provides methods for color transformations, blending, and more. It offers a broader set of features compared to rgba-regex.
Regex for matching RGBA color strings.
npm install --save rgba-regex
var rgbaRegex = require('rgba-regex');
rgbaRegex({ exact: true }).test('rgba(12, 34, 56, .8)'); // => true
rgbaRegex({ exact: true }).test('unicorns'); // -> false
rgbaRegex({ exact: true }).test('rgba(,,,)'); // => false
rgbaRegex().exec('rgba(12, 34, 56, .8)');
// => [
// '12',
// '34',
// '56',
// '.8'
// index: 0,
// input: 'rgba(12,34,56, .8)'
// ]
'rgba(12, 34, 56, .8) cats and dogs'.match(rgbaRegex());
// = ['rgba(12, 34, 56, .8)']
MIT
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Crafted with <3 by John Otander (@4lpine).
This package was initially generated with yeoman and the p generator.
FAQs
Regex for matching RGBA color strings.
The npm package rgba-regex receives a total of 1,750,326 weekly downloads. As such, rgba-regex popularity was classified as popular.
We found that rgba-regex 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.