Socket
Socket
Sign inDemoInstall

@ant-design/fast-color

Package Overview
Dependencies
Maintainers
7
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ant-design/fast-color - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

11

es/FastColor.js

@@ -13,3 +13,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

function splitColorStr(str, parseNum) {
const match = str.match(/\d*\.?\d+%?/g) || [];
const match = str
// Remove str before `(`
.replace(/^[^(]*\((.*)/, '$1')
// Remove str after `)`
.replace(/\).*/, '').match(/\d*\.?\d+%?/g) || [];
const numList = match.map(item => parseFloat(item));

@@ -29,2 +33,5 @@ for (let i = 0; i < 3; i += 1) {

}
function inRange(val, max = 255, min = 0) {
return typeof val === 'number' && val >= min && val <= max;
}
const parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100;

@@ -111,3 +118,3 @@ export class FastColor {

get isValid() {
return typeof this.r === 'number' && this.r >= 0 && this.r <= 255 && typeof this.g === 'number' && this.g >= 0 && this.g <= 255 && typeof this.b === 'number' && this.b >= 0 && this.b <= 255 && typeof this.a === 'number' && this.a >= 0 && this.a <= 1;
return inRange(this.r) && inRange(this.g) && inRange(this.b) && inRange(this.a, 1);
}

@@ -114,0 +121,0 @@ clone() {

@@ -20,3 +20,7 @@ "use strict";

function splitColorStr(str, parseNum) {
const match = str.match(/\d*\.?\d+%?/g) || [];
const match = str
// Remove str before `(`
.replace(/^[^(]*\((.*)/, '$1')
// Remove str after `)`
.replace(/\).*/, '').match(/\d*\.?\d+%?/g) || [];
const numList = match.map(item => parseFloat(item));

@@ -36,2 +40,5 @@ for (let i = 0; i < 3; i += 1) {

}
function inRange(val, max = 255, min = 0) {
return typeof val === 'number' && val >= min && val <= max;
}
const parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100;

@@ -118,3 +125,3 @@ class FastColor {

get isValid() {
return typeof this.r === 'number' && this.r >= 0 && this.r <= 255 && typeof this.g === 'number' && this.g >= 0 && this.g <= 255 && typeof this.b === 'number' && this.b >= 0 && this.b <= 255 && typeof this.a === 'number' && this.a >= 0 && this.a <= 1;
return inRange(this.r) && inRange(this.g) && inRange(this.b) && inRange(this.a, 1);
}

@@ -121,0 +128,0 @@ clone() {

2

package.json
{
"name": "@ant-design/fast-color",
"version": "1.2.3",
"version": "1.2.4",
"description": "fast and small color class",

@@ -5,0 +5,0 @@ "engines": {

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