pubo-utils 1.0.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/dist/pubo-utils.js +1 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/random/index.d.ts +1 -0
- package/es/random/index.js +3 -0
- package/es/watch-dog/index.d.ts +12 -0
- package/es/watch-dog/index.js +40 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +25 -0
- package/lib/random/index.d.ts +1 -0
- package/lib/random/index.js +10 -0
- package/lib/watch-dog/index.d.ts +12 -0
- package/lib/watch-dog/index.js +46 -0
- package/package.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["pubo-utils"]=n():t["pubo-utils"]=n()}(this,(function(){return function(t){var n={};function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(n){return t[n]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=0)}([function(t,n,e){"use strict";e.r(n),e.d(n,"random",(function(){return o})),e.d(n,"WatchDog",(function(){return r}));var o=function(){return Math.random().toString(32).slice(2,10)},r=function(){function t(t){var n=t.limit,e=void 0===n?1:n,o=t.onError;this.count=0,this.limit=1,this.limit=e,this.onError=o}return t.prototype.init=function(){var t=this;setInterval((function(){return t.onTimer()}),1e3)},t.prototype.feed=function(){this.count=0},t.prototype.onError=function(){},t.prototype.onTimer=function(){this.count>this.limit&&"function"==typeof this.onError?(this.onError(),this.count=0):this.count++},t}()}])}));
|
package/es/index.d.ts
ADDED
package/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const random: () => string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var WatchDog =
|
|
2
|
+
/** @class */
|
|
3
|
+
function () {
|
|
4
|
+
function WatchDog(_a) {
|
|
5
|
+
var _b = _a.limit,
|
|
6
|
+
limit = _b === void 0 ? 1 : _b,
|
|
7
|
+
onError = _a.onError;
|
|
8
|
+
this.count = 0;
|
|
9
|
+
this.limit = 1;
|
|
10
|
+
this.limit = limit;
|
|
11
|
+
this.onError = onError;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
WatchDog.prototype.init = function () {
|
|
15
|
+
var _this = this;
|
|
16
|
+
|
|
17
|
+
setInterval(function () {
|
|
18
|
+
return _this.onTimer();
|
|
19
|
+
}, 1000);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
WatchDog.prototype.feed = function () {
|
|
23
|
+
this.count = 0;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
WatchDog.prototype.onError = function () {};
|
|
27
|
+
|
|
28
|
+
WatchDog.prototype.onTimer = function () {
|
|
29
|
+
if (this.count > this.limit && typeof this.onError === 'function') {
|
|
30
|
+
this.onError();
|
|
31
|
+
this.count = 0;
|
|
32
|
+
} else {
|
|
33
|
+
this.count++;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return WatchDog;
|
|
38
|
+
}();
|
|
39
|
+
|
|
40
|
+
export default WatchDog;
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
"default": mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.WatchDog = exports.random = void 0;
|
|
13
|
+
|
|
14
|
+
var random_1 = require("./random");
|
|
15
|
+
|
|
16
|
+
Object.defineProperty(exports, "random", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return random_1.random;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var watch_dog_1 = __importDefault(require("./watch-dog"));
|
|
24
|
+
|
|
25
|
+
exports.WatchDog = watch_dog_1["default"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const random: () => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var WatchDog =
|
|
8
|
+
/** @class */
|
|
9
|
+
function () {
|
|
10
|
+
function WatchDog(_a) {
|
|
11
|
+
var _b = _a.limit,
|
|
12
|
+
limit = _b === void 0 ? 1 : _b,
|
|
13
|
+
onError = _a.onError;
|
|
14
|
+
this.count = 0;
|
|
15
|
+
this.limit = 1;
|
|
16
|
+
this.limit = limit;
|
|
17
|
+
this.onError = onError;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
WatchDog.prototype.init = function () {
|
|
21
|
+
var _this = this;
|
|
22
|
+
|
|
23
|
+
setInterval(function () {
|
|
24
|
+
return _this.onTimer();
|
|
25
|
+
}, 1000);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
WatchDog.prototype.feed = function () {
|
|
29
|
+
this.count = 0;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
WatchDog.prototype.onError = function () {};
|
|
33
|
+
|
|
34
|
+
WatchDog.prototype.onTimer = function () {
|
|
35
|
+
if (this.count > this.limit && typeof this.onError === 'function') {
|
|
36
|
+
this.onError();
|
|
37
|
+
this.count = 0;
|
|
38
|
+
} else {
|
|
39
|
+
this.count++;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return WatchDog;
|
|
44
|
+
}();
|
|
45
|
+
|
|
46
|
+
exports["default"] = WatchDog;
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pubo-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./lib/index.js",
|
|
5
|
+
"module": "./es/index.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
|
+
"unpkg": "dist/index.js",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "gulp && webpack-cli"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"lib",
|
|
15
|
+
"es",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=8.0.0"
|
|
20
|
+
}
|
|
21
|
+
}
|