
Security News
Node.js Moves Toward Stable TypeScript Support with Amaro 1.0
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Supply Chain Security
Vulnerability
Quality
Maintenance
License
The hsla-regex npm package provides a regular expression for matching HSLA (Hue, Saturation, Lightness, Alpha) color strings. This can be useful for validating, parsing, or extracting HSLA color values from strings.
Match HSLA color strings
This feature allows you to match HSLA color strings within a larger string. The code sample demonstrates how to use the hsla-regex package to find an HSLA color string in a CSS declaration.
const hslaRegex = require('hsla-regex');
const str = 'background-color: hsla(120, 100%, 50%, 0.3);';
const match = str.match(hslaRegex());
console.log(match); // ['hsla(120, 100%, 50%, 0.3)']
Validate HSLA color strings
This feature allows you to validate whether a given string is a valid HSLA color string. The code sample shows how to use the hsla-regex package to check if a string is a valid HSLA color.
const hslaRegex = require('hsla-regex');
const isValidHsla = (str) => hslaRegex().test(str);
console.log(isValidHsla('hsla(120, 100%, 50%, 0.3)')); // true
console.log(isValidHsla('rgb(255, 0, 0)')); // false
The color-string package provides functions for parsing and generating color strings in various formats, including HSLA. It offers more comprehensive functionality compared to hsla-regex, as it supports multiple color formats (RGB, HSL, HEX, etc.) and can convert between them.
The css-color-function package allows you to parse and manipulate CSS color functions, including HSLA. It provides more advanced features for color manipulation and conversion, making it a more powerful tool for working with CSS colors compared to hsla-regex.
The color package is a comprehensive library for color conversion and manipulation. It supports a wide range of color formats, including HSLA, and provides methods for color transformations, making it a more versatile option compared to hsla-regex.
Regex for matching HSLA colors.
npm install --save hsla-regex
var hslaRegex = require('hsla-regex');
hslaRegex({ exact: true }).test('hsla(123, 45%, 67%, .8)'); // => true
hslaRegex({ exact: true }).test('foo bar'); // => false
hslaRegex({ exact: true }).exec('hsla(1, 1.111%, 1.1111%, .8)');
// => [
// 'hsla(1, 1.111%, 1.1111%, .8)',
// '1',
// '1.111%',
// '1.1111%',
// '.8'
// index: 0,
// input: 'hsla(1, 1.111%, 1.1111%, .8)'
// ]
'hsla(123, 45%, 67%, .8) cats and dogs'.match(hslaRegex());
// = ['hsla(123, 45%, 67%, .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 HSLA colors.
The npm package hsla-regex receives a total of 2,754,132 weekly downloads. As such, hsla-regex popularity was classified as popular.
We found that hsla-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.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.