ut2 1.18.0 → 1.19.0
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/README.md +1 -0
- package/dist/ut2.js +119 -100
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/index.js +1 -0
- package/es/internals/helpers.js +1 -1
- package/es/limit.js +21 -0
- package/lib/index.js +2 -0
- package/lib/internals/helpers.js +1 -1
- package/lib/limit.js +23 -0
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/limit.d.ts +28 -0
package/README.md
CHANGED
|
@@ -94,6 +94,7 @@ const debounced = debounce(() => {
|
|
|
94
94
|
- [curry](https://caijf.github.io/ut2/module-Function.html#.curry) - 柯里化函数。
|
|
95
95
|
- [debounce](https://caijf.github.io/ut2/module-Function.html#.debounce) - 防抖函数。
|
|
96
96
|
- [delay](https://caijf.github.io/ut2/module-Function.html#.delay) - 延迟触发。
|
|
97
|
+
- [limit](https://caijf.github.io/ut2/module-Function.html#.limit) - 限流函数。
|
|
97
98
|
- [memoize](https://caijf.github.io/ut2/module-Function.html#.memoize) - 缓存函数结果。
|
|
98
99
|
- [negate](https://caijf.github.io/ut2/module-Function.html#.negate) - 否定断言。
|
|
99
100
|
- [once](https://caijf.github.io/ut2/module-Function.html#.once) - 只执行一次。
|
package/dist/ut2.js
CHANGED
|
@@ -607,7 +607,7 @@
|
|
|
607
607
|
return value == null || value !== value ? defaultValue : value;
|
|
608
608
|
};
|
|
609
609
|
|
|
610
|
-
var VERSION = "1.
|
|
610
|
+
var VERSION = "1.19.0";
|
|
611
611
|
var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
|
|
612
612
|
var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
|
|
613
613
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
@@ -784,6 +784,123 @@
|
|
|
784
784
|
}, wait);
|
|
785
785
|
}
|
|
786
786
|
|
|
787
|
+
/******************************************************************************
|
|
788
|
+
Copyright (c) Microsoft Corporation.
|
|
789
|
+
|
|
790
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
791
|
+
purpose with or without fee is hereby granted.
|
|
792
|
+
|
|
793
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
794
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
795
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
796
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
797
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
798
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
799
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
800
|
+
***************************************************************************** */
|
|
801
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
805
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
806
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
807
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
808
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
809
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
810
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function __generator(thisArg, body) {
|
|
815
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
816
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
817
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
818
|
+
function step(op) {
|
|
819
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
820
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
821
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
822
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
823
|
+
switch (op[0]) {
|
|
824
|
+
case 0: case 1: t = op; break;
|
|
825
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
826
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
827
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
828
|
+
default:
|
|
829
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
830
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
831
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
832
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
833
|
+
if (t[2]) _.ops.pop();
|
|
834
|
+
_.trys.pop(); continue;
|
|
835
|
+
}
|
|
836
|
+
op = body.call(thisArg, _);
|
|
837
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
838
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function __values(o) {
|
|
843
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
844
|
+
if (m) return m.call(o);
|
|
845
|
+
if (o && typeof o.length === "number") return {
|
|
846
|
+
next: function () {
|
|
847
|
+
if (o && i >= o.length) o = void 0;
|
|
848
|
+
return { value: o && o[i++], done: !o };
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function __read(o, n) {
|
|
855
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
856
|
+
if (!m) return o;
|
|
857
|
+
var i = m.call(o), r, ar = [], e;
|
|
858
|
+
try {
|
|
859
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
860
|
+
}
|
|
861
|
+
catch (error) { e = { error: error }; }
|
|
862
|
+
finally {
|
|
863
|
+
try {
|
|
864
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
865
|
+
}
|
|
866
|
+
finally { if (e) throw e.error; }
|
|
867
|
+
}
|
|
868
|
+
return ar;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function __spreadArray(to, from, pack) {
|
|
872
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
873
|
+
if (ar || !(i in from)) {
|
|
874
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
875
|
+
ar[i] = from[i];
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
882
|
+
var e = new Error(message);
|
|
883
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
function limit(fn, timespan) {
|
|
887
|
+
var pending = false;
|
|
888
|
+
function limited() {
|
|
889
|
+
var args = [];
|
|
890
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
891
|
+
args[_i] = arguments[_i];
|
|
892
|
+
}
|
|
893
|
+
if (pending)
|
|
894
|
+
return;
|
|
895
|
+
pending = true;
|
|
896
|
+
fn.apply(void 0, __spreadArray([], __read(args), false));
|
|
897
|
+
setTimeout(function () {
|
|
898
|
+
pending = false;
|
|
899
|
+
}, timespan);
|
|
900
|
+
}
|
|
901
|
+
return limited;
|
|
902
|
+
}
|
|
903
|
+
|
|
787
904
|
function equalArrayLike(arg1, arg2, strictCheck) {
|
|
788
905
|
if (strictCheck === void 0) { strictCheck = true; }
|
|
789
906
|
if (eq(arg1, arg2, strictCheck))
|
|
@@ -1478,105 +1595,6 @@
|
|
|
1478
1595
|
return getKeysIn(object).concat(getSymbolsIn(object));
|
|
1479
1596
|
}
|
|
1480
1597
|
|
|
1481
|
-
/******************************************************************************
|
|
1482
|
-
Copyright (c) Microsoft Corporation.
|
|
1483
|
-
|
|
1484
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1485
|
-
purpose with or without fee is hereby granted.
|
|
1486
|
-
|
|
1487
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1488
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1489
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1490
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1491
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1492
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1493
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1494
|
-
***************************************************************************** */
|
|
1495
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1499
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1500
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1501
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1502
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1503
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1504
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1505
|
-
});
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
function __generator(thisArg, body) {
|
|
1509
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
1510
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1511
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1512
|
-
function step(op) {
|
|
1513
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1514
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
1515
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1516
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1517
|
-
switch (op[0]) {
|
|
1518
|
-
case 0: case 1: t = op; break;
|
|
1519
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1520
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1521
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1522
|
-
default:
|
|
1523
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1524
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1525
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1526
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1527
|
-
if (t[2]) _.ops.pop();
|
|
1528
|
-
_.trys.pop(); continue;
|
|
1529
|
-
}
|
|
1530
|
-
op = body.call(thisArg, _);
|
|
1531
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1532
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
function __values(o) {
|
|
1537
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
1538
|
-
if (m) return m.call(o);
|
|
1539
|
-
if (o && typeof o.length === "number") return {
|
|
1540
|
-
next: function () {
|
|
1541
|
-
if (o && i >= o.length) o = void 0;
|
|
1542
|
-
return { value: o && o[i++], done: !o };
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
function __read(o, n) {
|
|
1549
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1550
|
-
if (!m) return o;
|
|
1551
|
-
var i = m.call(o), r, ar = [], e;
|
|
1552
|
-
try {
|
|
1553
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1554
|
-
}
|
|
1555
|
-
catch (error) { e = { error: error }; }
|
|
1556
|
-
finally {
|
|
1557
|
-
try {
|
|
1558
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1559
|
-
}
|
|
1560
|
-
finally { if (e) throw e.error; }
|
|
1561
|
-
}
|
|
1562
|
-
return ar;
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
function __spreadArray(to, from, pack) {
|
|
1566
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1567
|
-
if (ar || !(i in from)) {
|
|
1568
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1569
|
-
ar[i] = from[i];
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1576
|
-
var e = new Error(message);
|
|
1577
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1578
|
-
};
|
|
1579
|
-
|
|
1580
1598
|
var findKey = function (obj, predicate) {
|
|
1581
1599
|
var e_1, _a;
|
|
1582
1600
|
if (predicate === void 0) { predicate = stubFlase; }
|
|
@@ -2268,6 +2286,7 @@
|
|
|
2268
2286
|
exports.keyBy = keyBy;
|
|
2269
2287
|
exports.keys = keys;
|
|
2270
2288
|
exports.keysIn = keysIn;
|
|
2289
|
+
exports.limit = limit;
|
|
2271
2290
|
exports.list = list;
|
|
2272
2291
|
exports.lowerCase = lowerCase;
|
|
2273
2292
|
exports.lowerFirst = lowerFirst;
|