@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.
package/dist/index.umd.js CHANGED
@@ -243,7 +243,7 @@
243
243
  const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
244
244
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
245
245
 
246
- const version = "2.11.1";
246
+ const version = "2.11.3";
247
247
 
248
248
  /* eslint-disable */
249
249
  // ==UserScript==
@@ -1337,10 +1337,19 @@
1337
1337
  if (isNaN(level)) {
1338
1338
  throw new TypeError(`输入错误的level:${level}`);
1339
1339
  }
1340
+ if (level < 0 || level > 1) {
1341
+ throw new TypeError(`level must between 0~1.0: ${level}`);
1342
+ }
1340
1343
  const rgbc = this.hexToRgb(color);
1341
1344
  for (let index = 0; index < 3; index++) {
1342
1345
  const rgbcItemValue = rgbc[index];
1343
- const value = Math.floor(Number(rgbcItemValue) * (1 - level));
1346
+ let value = Math.floor(Number(rgbcItemValue) * (1 - level));
1347
+ if (value > 255) {
1348
+ value = 255;
1349
+ }
1350
+ else if (value < 0) {
1351
+ value = 0;
1352
+ }
1344
1353
  Reflect.set(rgbc, index, value);
1345
1354
  }
1346
1355
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
@@ -1360,10 +1369,19 @@
1360
1369
  if (isNaN(level)) {
1361
1370
  throw new TypeError(`输入错误的level:${level}`);
1362
1371
  }
1372
+ if (level < 0 || level > 1) {
1373
+ throw new TypeError(`level must between 0~1.0: ${level}`);
1374
+ }
1363
1375
  const rgbc = this.hexToRgb(color);
1364
1376
  for (let index = 0; index < 3; index++) {
1365
1377
  const rgbcItemValue = Number(rgbc[index]);
1366
- const value = Math.floor(255 - rgbcItemValue * level + rgbcItemValue);
1378
+ let value = Math.floor(255 - rgbcItemValue * level + rgbcItemValue);
1379
+ if (value > 255) {
1380
+ value = 255;
1381
+ }
1382
+ else if (value < 0) {
1383
+ value = 0;
1384
+ }
1367
1385
  Reflect.set(rgbc, index, value);
1368
1386
  }
1369
1387
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
@@ -7995,9 +8013,22 @@
7995
8013
  return result;
7996
8014
  }
7997
8015
  else {
7998
- return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
7999
- return compareFun(item, item2);
8000
- }));
8016
+ const compareSet = new Set(compareArrayData);
8017
+ const result = [];
8018
+ for (let i = 0; i < uniqueArrayData.length; i++) {
8019
+ const item = uniqueArrayData[i];
8020
+ let flag = false;
8021
+ for (const compareItem of compareSet) {
8022
+ if (compareFun(item, compareItem)) {
8023
+ flag = true;
8024
+ break;
8025
+ }
8026
+ }
8027
+ if (!flag) {
8028
+ result.push(item);
8029
+ }
8030
+ }
8031
+ return result;
8001
8032
  }
8002
8033
  }
8003
8034
  /**