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

@vexip-ui/utils

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vexip-ui/utils - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

71

dist/index.d.ts

@@ -21,2 +21,11 @@ export declare function addDays(date: Dateable, amount: number): Date;

export declare function adjustAlpha(color: Color, alpha: number | string): RGBAColor;
export declare interface BITree {
add(index: number, num: number): void;
sum(index?: number): number;
get(index: number): number;
boundIndex(limit: number): number;
}
/**

@@ -65,2 +74,4 @@ * 将一个数字限定在指定的范围内

export declare function createBITree(length: number, min?: number): BITree;
export declare function createEvent(type: string): void;

@@ -90,2 +101,10 @@

/**
* 针对每一帧,将一个函数或方法进行防抖
* @param method - 需要防抖的方法,需自行绑定 this
*
* @returns 防抖后的函数
*/
export declare function debounceFrame<T extends (...args: any[]) => any>(method: T): (...args: Parameters<T>) => void;
/**
* 针对每个微任务,将一个函数或方法进行防抖

@@ -154,2 +173,6 @@ * @param method - 需要防抖的方法,需自行绑定 this

/**
* 讲小于 10 整数 N 变成 `0N` 的字符串,方法不会对入参校验
* @param number - 需要处理的整数
*/
export declare function doubleDigits(number: number): string;

@@ -259,2 +282,3 @@

l: number;
a?: number;
}

@@ -284,2 +308,3 @@

v: number;
a?: number;
}

@@ -309,2 +334,4 @@

export declare function isBigInt(value: unknown): value is bigint;
export declare function isBoolean(value: unknown): value is boolean;

@@ -362,2 +389,4 @@

export declare function mixColor(color1: Color, color2: Color, weight?: number): RGBAColor;
/**

@@ -373,2 +402,16 @@ * 将一个实数扩大一定的倍数并保留一定的小数

/**
* 在下一渲染帧,仅执行一次传入的方法
* @param method - 需要执行的方法
* @param args - 方法的额外参数,在方法调用前多次传入将会覆盖之前的参数
*/
export declare function nextFrameOnce<T extends (...args: any[]) => any>(method: T, ...args: any[]): undefined;
/**
* 在下一微任务,仅执行一次传入的方法
* @param method - 需要执行的方法
* @param args - 方法的额外参数,在方法调用前多次传入将会覆盖之前的参数
*/
export declare function nextTickOnce<T extends (...args: any[]) => any>(method: T, ...args: any[]): undefined;
export declare function noop(...args: any[]): any;

@@ -378,19 +421,7 @@

export declare function normalizeHsl(h: number | string, s: number | string, l: number | string): {
h: number;
s: number;
l: number;
};
export declare function normalizeHsl(h: number | string, s: number | string, l: number | string): HSLColor;
export declare function normalizeHsv(h: number | string, s: number | string, v: number | string): {
h: number;
s: number;
v: number;
};
export declare function normalizeHsv(h: number | string, s: number | string, v: number | string): HSVColor;
export declare function normalizeRgb(r: number | string, g: number | string, b: number | string): {
r: number;
g: number;
b: number;
};
export declare function normalizeRgb(r: number | string, g: number | string, b: number | string): RGBColor;

@@ -451,2 +482,3 @@ export declare function observe(el: TransferNode, types: string | string[]): void;

b: number;
a?: number;
}

@@ -552,2 +584,7 @@

/**
* 讲一个实数保留一定的小数
* @param number - 需要处理的实数
* @param decimal - 需要保留的小数
*/
export declare function toFixed(number: number, decimal: number): number;

@@ -557,2 +594,6 @@

/**
* 将任意值转成数字,NaN 的情况将会处理成 0
* @param value - 需要转化的值
*/
export declare function toNumber(value: unknown): number;

@@ -559,0 +600,0 @@

@@ -208,3 +208,3 @@ var __defProp = Object.defineProperty;

if (color === "transparent") {
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
return { r: 0, g: 0, b: 0, a: 0, format: "name", toString: toRgbString };
}

@@ -219,3 +219,3 @@ let named = false;

const { r, g, b } = normalizeRgb(match[1], match[2], match[3]);
return { r: r * 255, g: g * 255, b: b * 255, format: "rgb" };
return { r: r * 255, g: g * 255, b: b * 255, format: "rgb", toString: toRgbString };
}

@@ -229,3 +229,4 @@ if (match = RGBA_REG.exec(color)) {

a: normalizeAlpha(match[4]),
format: "rgba"
format: "rgba",
toString: toRgbString
};

@@ -235,3 +236,3 @@ }

const { h, s, l } = normalizeHsl(match[0], match[1], match[3]);
return { h: h * 360, s, l, format: "hsl" };
return { h: h * 360, s, l, format: "hsl", toString: toHslString };
}

@@ -245,3 +246,4 @@ if (match = HSLA_REG.exec(color)) {

a: normalizeAlpha(match[4]),
format: "hsla"
format: "hsla",
toString: toHslString
};

@@ -251,3 +253,3 @@ }

const { h, s, v } = normalizeHsv(match[0], match[1], match[3]);
return { h: h * 360, s, v, format: "hsv" };
return { h: h * 360, s, v, format: "hsv", toString: toHsvString };
}

@@ -261,3 +263,4 @@ if (match = HSVA_REG.exec(color)) {

a: normalizeAlpha(match[4]),
format: "hsva"
format: "hsva",
toString: toHsvString
};

@@ -270,3 +273,4 @@ }

b: parseInt(`${match[3]}${match[3]}`, 16),
format: named ? "name" : "hex3"
format: named ? "name" : "hex3",
toString: toRgbString
};

@@ -280,3 +284,4 @@ }

a: convertHexToDecimal(`${match[4]}${match[4]}`),
format: named ? "name" : "hex4"
format: named ? "name" : "hex4",
toString: toRgbString
};

@@ -289,3 +294,4 @@ }

b: parseInt(match[3], 16),
format: named ? "name" : "hex6"
format: named ? "name" : "hex6",
toString: toRgbString
};

@@ -299,3 +305,4 @@ }

a: convertHexToDecimal(match[4]),
format: named ? "name" : "hex8"
format: named ? "name" : "hex8",
toString: toRgbString
};

@@ -318,5 +325,5 @@ }

alpha: a,
rgba: __spreadProps(__spreadValues({}, rgb), { a, format: void 0 }),
hsla: __spreadProps(__spreadValues({}, hsl), { a, format: void 0 }),
hsva: __spreadProps(__spreadValues({}, hsv), { a, format: void 0 }),
rgba: __spreadProps(__spreadValues({}, rgb), { a, format: "rgba" }),
hsla: __spreadProps(__spreadValues({}, hsl), { a, format: "hsla" }),
hsva: __spreadProps(__spreadValues({}, hsv), { a, format: "hsva" }),
hex8,

@@ -335,3 +342,2 @@ origin: color

}
debugger;
if (color !== null && typeof color === "object") {

@@ -351,3 +357,3 @@ if ("l" in color) {

}
return __spreadProps(__spreadValues({}, rgb), { a, format: "rgba" });
return __spreadProps(__spreadValues({}, rgb), { a, format: "rgba", toString: toRgbString });
}

@@ -358,3 +364,4 @@ function normalizeHsl(h, s, l) {

s: boundRange$1(isPercentage(s) ? parsePercentage(s) : s, 0, 1),
l: boundRange$1(isPercentage(l) ? parsePercentage(l) : l, 0, 1)
l: boundRange$1(isPercentage(l) ? parsePercentage(l) : l, 0, 1),
toString: toHslString
};

@@ -366,3 +373,4 @@ }

g: boundRange$1(g, 0, 255) / 255,
b: boundRange$1(b, 0, 255) / 255
b: boundRange$1(b, 0, 255) / 255,
toString: toRgbString
};

@@ -374,3 +382,4 @@ }

s: boundRange$1(isPercentage(s) ? parsePercentage(s) : s, 0, 1),
v: boundRange$1(isPercentage(v) ? parsePercentage(v) : v, 0, 1)
v: boundRange$1(isPercentage(v) ? parsePercentage(v) : v, 0, 1),
toString: toHsvString
};

@@ -396,3 +405,3 @@ }

b *= 255;
return { r, g, b };
return { r, g, b, toString: toRgbString };
}

@@ -429,3 +438,3 @@ function rgbToHsl(r, g, b) {

}
return { h, s, l };
return { h, s, l, toString: toHslString };
}

@@ -436,3 +445,3 @@ function hslToHsv(h, s, l) {

s = 2 * (v - l) / v;
return { h: h * 360, s, v };
return { h: h * 360, s, v, toString: toHsvString };
}

@@ -443,3 +452,3 @@ function hsvToHsl(h, s, v) {

s = v * s / (1 - Math.abs(2 * l - 1));
return { h: h * 360, s, l };
return { h: h * 360, s, l, toString: toHslString };
}

@@ -461,3 +470,3 @@ function hsvToRgb(h, s, v) {

b *= 255;
return { r, g, b };
return { r, g, b, toString: toRgbString };
}

@@ -494,3 +503,3 @@ function rgbToHsv(r, g, b) {

}
return { h, s, v };
return { h, s, v, toString: toHsvString };
}

@@ -522,2 +531,31 @@ function rgbToHex(r, g, b, allow3Char = false) {

}
function mixColor(color1, color2, weight = 0.5) {
if (!color1 && !color2)
return { r: 0, g: 0, b: 0, a: 1 };
if (!color1)
return parseColorToRgba(color2);
if (!color2)
return parseColorToRgba(color1);
const rgba1 = parseColorToRgba(color1);
const rgba2 = parseColorToRgba(color2);
const originalWeight = boundRange$1(weight, 0, 1);
const normalizedWeight = originalWeight * 2 - 1;
const alphaDistance = rgba1.a - rgba2.a;
const mixWeight = normalizedWeight * alphaDistance === -1 ? normalizedWeight : (normalizedWeight + alphaDistance) / (1 + normalizedWeight * alphaDistance);
const weight1 = (mixWeight + 1) / 2;
const weight2 = 1 - weight1;
return {
r: Math.round(rgba1.r * weight1 + rgba2.r * weight2),
g: Math.round(rgba1.g * weight1 + rgba2.g * weight2),
b: Math.round(rgba1.b * weight1 + rgba2.b * weight2),
a: Math.round(rgba1.a * originalWeight + rgba2.a * (1 - originalWeight)),
format: "rgba",
toString: toRgbString
};
}
function adjustAlpha(color, alpha) {
const rgba = parseColorToRgba(color);
rgba.a = normalizeAlpha(isPercentage(alpha) ? parsePercentage(alpha) : alpha);
return rgba;
}
function repairDigits(str) {

@@ -558,2 +596,20 @@ return str.length === 1 ? `0${str}` : str.toString();

}
function toRgbString() {
if (this.a && this.a >= 0 && this.a < 1) {
return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;
}
return `rgb(${this.r}, ${this.g}, ${this.b})`;
}
function toHslString() {
if (this.a && this.a >= 0 && this.a < 1) {
return `hsla(${this.h}, ${this.s}, ${this.l}, ${this.a})`;
}
return `hsl(${this.h}, ${this.s}, ${this.l})`;
}
function toHsvString() {
if (this.a && this.a >= 0 && this.a < 1) {
return `hsva(${this.h}, ${this.s}, ${this.v}, ${this.a})`;
}
return `hsv(${this.h}, ${this.s}, ${this.v})`;
}
const toString = Object.prototype.toString;

@@ -594,2 +650,5 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;

}
function isBigInt(value) {
return typeof value === "bigint";
}
function isArray(value) {

@@ -652,2 +711,53 @@ return Array.isArray(value);

}
function lowBit(num) {
return num & -num;
}
function createBITree(length, min = 0) {
const tree = new Array(length + 1).fill(0);
function add(index, delta) {
if (!delta || index >= length)
return;
index += 1;
while (index <= length) {
tree[index] += delta;
index += lowBit(index);
}
}
function sum(index = length) {
if (index <= 0)
return 0;
if (index > length)
index = length;
let sum2 = index * min;
while (index > 0) {
sum2 += tree[index];
index -= lowBit(index);
}
return sum2;
}
function get(index) {
return sum(index + 1) - sum(index);
}
function boundIndex(limit) {
let left = 0;
let right = length;
while (right > left) {
const middle = Math.floor((left + right) / 2);
const total = sum(middle);
if (total > limit) {
right = middle;
continue;
} else if (total < limit) {
if (left === middle) {
return sum(left + 1) <= limit ? left + 1 : left;
}
left = middle;
} else {
return middle;
}
}
return left;
}
return { add, sum, get, boundIndex };
}
function toNumber(value) {

@@ -674,9 +784,22 @@ const number = parseFloat(value);

}
function toFixed(number, decimal) {
if (decimal === 0)
return Math.round(number);
let snum = String(number);
const pointPos = snum.indexOf(".");
if (pointPos === -1)
return number;
const nums = snum.replace(".", "").split("");
const datum = nums[pointPos + decimal];
if (!datum)
return number;
const length = snum.length;
if (snum.charAt(length - 1) === "5") {
snum = snum.substring(0, length - 1) + "6";
}
return parseFloat(Number(snum).toFixed(decimal));
}
function multipleFixed(number, multiple, decimal) {
const fixed = 10 ** decimal;
return Math.round(number * multiple * fixed) / fixed;
return toFixed(number * multiple, decimal);
}
function toFixed(number, decimal) {
return multipleFixed(number, 1, decimal);
}
function round(number, criticalValue) {

@@ -1255,2 +1378,61 @@ if (criticalValue < 0 || criticalValue > 1) {

}
function debounceFrame(method) {
if (typeof method !== "function") {
return method;
}
let called = false;
let lastArgs;
return function(...args) {
lastArgs = args;
if (!called) {
called = true;
requestAnimationFrame(() => {
method(...lastArgs);
called = false;
});
}
};
}
const tickCallbacks = /* @__PURE__ */ new Set();
const tickArgsMap = /* @__PURE__ */ new WeakMap();
function flushTickCallbacks() {
tickCallbacks.forEach((fn) => {
fn(...tickArgsMap.get(fn));
});
tickCallbacks.clear();
}
function nextTickOnce(method, ...args) {
if (typeof method !== "function") {
return method;
}
tickArgsMap.set(method, args);
if (tickCallbacks.has(method)) {
return;
}
tickCallbacks.add(method);
if (tickCallbacks.size === 1) {
Promise.resolve().then(flushTickCallbacks);
}
}
const frameCallbacks = /* @__PURE__ */ new Set();
const frameArgsMap = /* @__PURE__ */ new WeakMap();
function flushFrameCallbacks() {
frameCallbacks.forEach((fn) => {
fn(...frameArgsMap.get(fn));
});
frameCallbacks.clear();
}
function nextFrameOnce(method, ...args) {
if (typeof method !== "function") {
return method;
}
frameArgsMap.set(method, args);
if (frameCallbacks.has(method)) {
return;
}
frameCallbacks.add(method);
if (frameCallbacks.size === 1) {
requestAnimationFrame(flushFrameCallbacks);
}
}
function transformListToMap(list, prop, accessor = (v) => v) {

@@ -1465,2 +1647,2 @@ const map = {};

}
export { CLICK_TYPE, CompareAscResult, CompareDescResult, DAY_ON_HOURS, DAY_ON_MILLIS, DAY_ON_MINUTES, DAY_ON_SECONDS, HEX_REG_3, HEX_REG_4, HEX_REG_6, HEX_REG_8, HOUR_ON_MILLS, HOUR_ON_MINUTES, HOUR_ON_SECONDS, HSLA_REG, HSL_REG, HSVA_REG, HSV_REG, MINUTE_ON_MILLS, MINUTE_ON_SECONDS, NAMES, QUARTER_ON_MONTHS, RGBA_REG, RGB_REG, SECOND_ON_MILLS, USE_TOUCH, WEEK_ON_DAYS, WEEK_ON_HOURS, WEEK_ON_MILLIS, WEEK_ON_MINUTES, WEEK_ON_SECONDS, YEAR_ON_MONTHS, YEAR_ON_QUARTERS, addDays, addHalfDays, addHours, addMilliseconds, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, boundRange, compareAsc, compareDesc, createEvent, createEventEmitter, debounce, debounceMinor, deepClone, destroyObject, differenceDays, differenceFullDays, differenceFullHours, differenceFullMinutes, differenceFullMonths, differenceFullQuarters, differenceFullSeconds, differenceFullWeeks, differenceFullYears, differenceHours, differenceMilliseconds, differenceMinutes, differenceMonths, differenceQuarters, differenceSeconds, differenceWeeks, differenceYears, disconnect, dispatchEvent, doubleDigits, endOfDay, flatTree, format, getChineseWeek, getLastSunday, getObservers, getQuarter, getType, groupByProps, has, hslToHsv, hslToRgb, hsvToHsl, hsvToRgb, is, isArray, isBoolean, isColor, isDate, isDefined, isEmpty, isFalse, isFunction, isLeepYear, isMap, isNaN, isNull, isNumber, isObject, isPromise, isRegExp, isSet, isString, isSymbol, isTrue, mergeObjects, multipleFixed, noop, normalizeAlpha, normalizeHsl, normalizeHsv, normalizeRgb, observe, parseColor, parseColorToRgba, parseStringColor, randomString, range, rangeDate, rangeMonth, removeArrayItem, rgbToHex, rgbToHsl, rgbToHsv, rgbaToHex, round, segmentNumber, sortByProps, startOfDay, startOfHour, startOfMinute, startOfMonth, startOfQuarter, startOfSecond, startOfWeek, startOfYear, throttle, toCamelCase, toDate, toFixed, toKebabCase, toNumber, toPascalCase, transformListToMap, transformTree };
export { CLICK_TYPE, CompareAscResult, CompareDescResult, DAY_ON_HOURS, DAY_ON_MILLIS, DAY_ON_MINUTES, DAY_ON_SECONDS, HEX_REG_3, HEX_REG_4, HEX_REG_6, HEX_REG_8, HOUR_ON_MILLS, HOUR_ON_MINUTES, HOUR_ON_SECONDS, HSLA_REG, HSL_REG, HSVA_REG, HSV_REG, MINUTE_ON_MILLS, MINUTE_ON_SECONDS, NAMES, QUARTER_ON_MONTHS, RGBA_REG, RGB_REG, SECOND_ON_MILLS, USE_TOUCH, WEEK_ON_DAYS, WEEK_ON_HOURS, WEEK_ON_MILLIS, WEEK_ON_MINUTES, WEEK_ON_SECONDS, YEAR_ON_MONTHS, YEAR_ON_QUARTERS, addDays, addHalfDays, addHours, addMilliseconds, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, adjustAlpha, boundRange, compareAsc, compareDesc, createBITree, createEvent, createEventEmitter, debounce, debounceFrame, debounceMinor, deepClone, destroyObject, differenceDays, differenceFullDays, differenceFullHours, differenceFullMinutes, differenceFullMonths, differenceFullQuarters, differenceFullSeconds, differenceFullWeeks, differenceFullYears, differenceHours, differenceMilliseconds, differenceMinutes, differenceMonths, differenceQuarters, differenceSeconds, differenceWeeks, differenceYears, disconnect, dispatchEvent, doubleDigits, endOfDay, flatTree, format, getChineseWeek, getLastSunday, getObservers, getQuarter, getType, groupByProps, has, hslToHsv, hslToRgb, hsvToHsl, hsvToRgb, is, isArray, isBigInt, isBoolean, isColor, isDate, isDefined, isEmpty, isFalse, isFunction, isLeepYear, isMap, isNaN, isNull, isNumber, isObject, isPromise, isRegExp, isSet, isString, isSymbol, isTrue, mergeObjects, mixColor, multipleFixed, nextFrameOnce, nextTickOnce, noop, normalizeAlpha, normalizeHsl, normalizeHsv, normalizeRgb, observe, parseColor, parseColorToRgba, parseStringColor, randomString, range, rangeDate, rangeMonth, removeArrayItem, rgbToHex, rgbToHsl, rgbToHsv, rgbaToHex, round, segmentNumber, sortByProps, startOfDay, startOfHour, startOfMinute, startOfMonth, startOfQuarter, startOfSecond, startOfWeek, startOfYear, throttle, toCamelCase, toDate, toFixed, toKebabCase, toNumber, toPascalCase, transformListToMap, transformTree };
{
"name": "@vexip-ui/utils",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -23,2 +23,7 @@ "author": "qmhc",

},
"devDependencies": {
"typescript": "4.6.4",
"vite": "^2.9.9",
"vite-plugin-dts": "^1.1.1"
},
"scripts": {

@@ -25,0 +30,0 @@ "build": "vite build"

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