Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ones-design/utils

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ones-design/utils - npm Package Compare versions

Comparing version 1.10.0 to 1.10.1-rc.0

54

./dist/index.js

@@ -31,6 +31,42 @@ import { isEqual as isEqual$1 } from '@senojs/lodash';

/**
* @file 工具函数 - 警告
* @file 工具函数 - 控制台警告
* @author htmlin
*/
let logs = {
error: {},
warn: {}
};
let timer = null;
/**
* 合并 1s 内的重复日志
* @param log 日志信息
* @param type 日志类型
*/
function debounceLogs(log, type = 'error') {
const assertlogs = logs[type];
if (!assertlogs[log]) {
assertlogs[log] = 1;
} else {
assertlogs[log]++;
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
Object.entries(logs).forEach(([key, value]) => {
for (const log in value) {
console[key](`[ONES Design] ${log}` + (value[log] > 1 ? ` (×${value[log]})` : ''));
}
});
logs = {
error: {},
warn: {}
};
timer = null;
}, 500);
}
/**
* 错误警告

@@ -41,10 +77,14 @@ * @param {boolean} condition - 条件表达式

function warn(condition, msg) {
if (!condition) {
console.error(`[ONES Design] ${msg}`);
}
if (condition) return;
debounceLogs(msg);
}
/**
* 警告提示
* @param {boolean} condition - 条件表达式
* @param {string} msg - 当 condition 结果为 false 时提示的警告信息
*/
function tip(condition, msg) {
if (!condition) {
console.warn(`[ONES Design] ${msg}`);
}
if (condition) return;
debounceLogs(msg, 'warn');
}

@@ -51,0 +91,0 @@

@@ -31,6 +31,42 @@ import { isEqual as isEqual$1 } from '@senojs/lodash';

/**
* @file 工具函数 - 警告
* @file 工具函数 - 控制台警告
* @author htmlin
*/
let logs = {
error: {},
warn: {}
};
let timer = null;
/**
* 合并 1s 内的重复日志
* @param log 日志信息
* @param type 日志类型
*/
function debounceLogs(log, type = 'error') {
const assertlogs = logs[type];
if (!assertlogs[log]) {
assertlogs[log] = 1;
} else {
assertlogs[log]++;
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
Object.entries(logs).forEach(([key, value]) => {
for (const log in value) {
console[key](`[ONES Design] ${log}` + (value[log] > 1 ? ` (×${value[log]})` : ''));
}
});
logs = {
error: {},
warn: {}
};
timer = null;
}, 500);
}
/**
* 错误警告

@@ -41,10 +77,14 @@ * @param {boolean} condition - 条件表达式

function warn(condition, msg) {
if (!condition) {
console.error(`[ONES Design] ${msg}`);
}
if (condition) return;
debounceLogs(msg);
}
/**
* 警告提示
* @param {boolean} condition - 条件表达式
* @param {string} msg - 当 condition 结果为 false 时提示的警告信息
*/
function tip(condition, msg) {
if (!condition) {
console.warn(`[ONES Design] ${msg}`);
}
if (condition) return;
debounceLogs(msg, 'warn');
}

@@ -51,0 +91,0 @@

9

dist/types/warn.d.ts
/**
* @file 工具函数 - 警告
* @author htmlin
* 错误警告
* @param {boolean} condition - 条件表达式
* @param {string} msg - 当 condition 结果为 false 时提示的警告信息
*/
declare function warn(condition: boolean, msg: string): void;
/**
* 错误警告
* 警告提示
* @param {boolean} condition - 条件表达式
* @param {string} msg - 当 condition 结果为 false 时提示的警告信息
*/
declare function warn(condition: boolean, msg: string): void;
declare function tip(condition: boolean, msg: string): void;
export { warn, tip };
{
"name": "@ones-design/utils",
"version": "1.10.0",
"version": "1.10.1-rc.0",
"description": "ONES Design",

@@ -57,3 +57,3 @@ "type": "module",

},
"gitHead": "2cc0fc8d62d3f97f95be8fd6ee8a752ea84e5f04"
"gitHead": "3aa363849c517182e32a6a8e7a7953a6e356b5ea"
}
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