@whitesev/utils 2.11.1 → 2.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -240,7 +240,7 @@ var Utils = (function () {
240
240
  const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
241
241
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
242
242
 
243
- const version = "2.11.1";
243
+ const version = "2.11.3";
244
244
 
245
245
  /* eslint-disable */
246
246
  // ==UserScript==
@@ -1334,10 +1334,19 @@ var Utils = (function () {
1334
1334
  if (isNaN(level)) {
1335
1335
  throw new TypeError(`输入错误的level:${level}`);
1336
1336
  }
1337
+ if (level < 0 || level > 1) {
1338
+ throw new TypeError(`level must between 0~1.0: ${level}`);
1339
+ }
1337
1340
  const rgbc = this.hexToRgb(color);
1338
1341
  for (let index = 0; index < 3; index++) {
1339
1342
  const rgbcItemValue = rgbc[index];
1340
- const value = Math.floor(Number(rgbcItemValue) * (1 - level));
1343
+ let value = Math.floor(Number(rgbcItemValue) * (1 - level));
1344
+ if (value > 255) {
1345
+ value = 255;
1346
+ }
1347
+ else if (value < 0) {
1348
+ value = 0;
1349
+ }
1341
1350
  Reflect.set(rgbc, index, value);
1342
1351
  }
1343
1352
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
@@ -1357,10 +1366,19 @@ var Utils = (function () {
1357
1366
  if (isNaN(level)) {
1358
1367
  throw new TypeError(`输入错误的level:${level}`);
1359
1368
  }
1369
+ if (level < 0 || level > 1) {
1370
+ throw new TypeError(`level must between 0~1.0: ${level}`);
1371
+ }
1360
1372
  const rgbc = this.hexToRgb(color);
1361
1373
  for (let index = 0; index < 3; index++) {
1362
1374
  const rgbcItemValue = Number(rgbc[index]);
1363
- const value = Math.floor(255 - rgbcItemValue * level + rgbcItemValue);
1375
+ let value = Math.floor(255 - rgbcItemValue * level + rgbcItemValue);
1376
+ if (value > 255) {
1377
+ value = 255;
1378
+ }
1379
+ else if (value < 0) {
1380
+ value = 0;
1381
+ }
1364
1382
  Reflect.set(rgbc, index, value);
1365
1383
  }
1366
1384
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
@@ -7992,9 +8010,22 @@ var Utils = (function () {
7992
8010
  return result;
7993
8011
  }
7994
8012
  else {
7995
- return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
7996
- return compareFun(item, item2);
7997
- }));
8013
+ const compareSet = new Set(compareArrayData);
8014
+ const result = [];
8015
+ for (let i = 0; i < uniqueArrayData.length; i++) {
8016
+ const item = uniqueArrayData[i];
8017
+ let flag = false;
8018
+ for (const compareItem of compareSet) {
8019
+ if (compareFun(item, compareItem)) {
8020
+ flag = true;
8021
+ break;
8022
+ }
8023
+ }
8024
+ if (!flag) {
8025
+ result.push(item);
8026
+ }
8027
+ }
8028
+ return result;
7998
8029
  }
7999
8030
  }
8000
8031
  /**