vest 5.2.11 → 5.2.12
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/debounce/package.json +9 -0
- package/dist/cjs/debounce.development.js +51 -0
- package/dist/cjs/debounce.development.js.map +1 -0
- package/dist/cjs/debounce.js +6 -0
- package/dist/cjs/debounce.production.js +2 -0
- package/dist/cjs/debounce.production.js.map +1 -0
- package/dist/cjs/vest.development.js +543 -544
- package/dist/cjs/vest.development.js.map +1 -1
- package/dist/cjs/vest.production.js +1 -1
- package/dist/cjs/vest.production.js.map +1 -1
- package/dist/es/debounce.development.js +46 -0
- package/dist/es/debounce.development.js.map +1 -0
- package/dist/es/debounce.production.js +2 -0
- package/dist/es/debounce.production.js.map +1 -0
- package/dist/es/vest.development.js +545 -547
- package/dist/es/vest.development.js.map +1 -1
- package/dist/es/vest.production.js +1 -1
- package/dist/es/vest.production.js.map +1 -1
- package/dist/umd/debounce.development.js +53 -0
- package/dist/umd/debounce.development.js.map +1 -0
- package/dist/umd/debounce.production.js +2 -0
- package/dist/umd/debounce.production.js.map +1 -0
- package/dist/umd/vest.development.js +543 -544
- package/dist/umd/vest.development.js.map +1 -1
- package/dist/umd/vest.production.js +1 -1
- package/dist/umd/vest.production.js.map +1 -1
- package/package.json +36 -6
- package/types/SuiteSerializer.d.ts.map +1 -1
- package/types/debounce.d.ts +131 -0
- package/types/debounce.d.ts.map +1 -0
- package/types/vest.d.ts +6 -1
- package/types/vest.d.ts.map +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"main": "../dist/cjs/debounce.js",
|
|
3
|
+
"module": "../dist/es/debounce.production.js",
|
|
4
|
+
"unpkg": "../dist/umd/debounce.production.js",
|
|
5
|
+
"jsdelivr": "../dist/umd/debounce.production.js",
|
|
6
|
+
"name": "debounce",
|
|
7
|
+
"types": "../types/debounce.d.ts",
|
|
8
|
+
"private": true
|
|
9
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vest = require('vest');
|
|
6
|
+
var vestUtils = require('vest-utils');
|
|
7
|
+
var vestjsRuntime = require('vestjs-runtime');
|
|
8
|
+
|
|
9
|
+
const isolateType = 'Debounce';
|
|
10
|
+
function debounce(callback, delay = 0) {
|
|
11
|
+
let timeout = null;
|
|
12
|
+
const f = () => (payload) => new Promise((resolve, reject) => {
|
|
13
|
+
timeout = setTimeout(() => {
|
|
14
|
+
let res = false;
|
|
15
|
+
try {
|
|
16
|
+
res = callback(payload);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
return reject(e);
|
|
20
|
+
}
|
|
21
|
+
if (res === false) {
|
|
22
|
+
return reject();
|
|
23
|
+
}
|
|
24
|
+
return vestUtils.isPromise(res) ? res.then(resolve, reject) : resolve(res);
|
|
25
|
+
}, delay);
|
|
26
|
+
});
|
|
27
|
+
const i = vestjsRuntime.Isolate.create(isolateType, f, {
|
|
28
|
+
clearTimeout: () => {
|
|
29
|
+
if (timeout) {
|
|
30
|
+
clearTimeout(timeout);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return i.output;
|
|
35
|
+
}
|
|
36
|
+
class IsolateDebounceReconciler {
|
|
37
|
+
static match(currentNode, historyNode) {
|
|
38
|
+
return (vestjsRuntime.IsolateSelectors.isIsolateType(currentNode, isolateType) &&
|
|
39
|
+
vestjsRuntime.IsolateSelectors.isIsolateType(historyNode, isolateType));
|
|
40
|
+
}
|
|
41
|
+
static reconcile(current, history) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
(_b = (_a = history === null || history === void 0 ? void 0 : history.data) === null || _a === void 0 ? void 0 : _a.clearTimeout) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
44
|
+
return current;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
vest.registerReconciler(IsolateDebounceReconciler);
|
|
48
|
+
|
|
49
|
+
exports.IsolateDebounceReconciler = IsolateDebounceReconciler;
|
|
50
|
+
exports.default = debounce;
|
|
51
|
+
//# sourceMappingURL=debounce.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.development.js","sources":["../../src/exports/debounce.ts"],"sourcesContent":["import { registerReconciler } from 'vest';\nimport { CB, isPromise, Nullable } from 'vest-utils';\nimport { Isolate, TIsolate, IsolateSelectors } from 'vestjs-runtime';\n\nimport { TestFn, TestFnPayload } from 'TestTypes';\n\nconst isolateType = 'Debounce';\n\nexport default function debounce<Callback extends CB = CB>(\n callback: Callback,\n delay: number = 0,\n): TestFn {\n let timeout: Nullable<NodeJS.Timeout> = null;\n\n const f = () => (payload: TestFnPayload) =>\n new Promise((resolve, reject) => {\n timeout = setTimeout(() => {\n let res = false;\n try {\n res = callback(payload);\n } catch (e) {\n return reject(e);\n }\n\n if (res === false) {\n return reject();\n }\n\n return isPromise(res) ? res.then(resolve, reject) : resolve(res);\n }, delay);\n });\n\n const i = Isolate.create(isolateType, f, {\n clearTimeout: () => {\n if (timeout) {\n clearTimeout(timeout);\n }\n },\n });\n\n return i.output;\n}\n\nexport class IsolateDebounceReconciler {\n static match(currentNode: TIsolate, historyNode: TIsolate): boolean {\n return (\n IsolateSelectors.isIsolateType(currentNode, isolateType) &&\n IsolateSelectors.isIsolateType(historyNode, isolateType)\n );\n }\n\n static reconcile(current: TIsolateDebounce, history: TIsolateDebounce) {\n history?.data?.clearTimeout?.();\n\n return current;\n }\n}\n\nexport type TIsolateDebounce = TIsolate<IsolateDebouncePayload>;\n\nexport type IsolateDebouncePayload = {\n clearTimeout: () => void;\n};\n\nregisterReconciler(IsolateDebounceReconciler);\n"],"names":["isPromise","Isolate","IsolateSelectors","registerReconciler"],"mappings":";;;;;;;;AAMA,MAAM,WAAW,GAAG,UAAU,CAAC;AAEP,SAAA,QAAQ,CAC9B,QAAkB,EAClB,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AAO,KAAA,IAAA,IAAP,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAP,OAAO,CAAE,IAAI,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,YAAY,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAI,CAAC;AAEhC,QAAA,OAAO,OAAO,CAAC;KAChB;AACF,CAAA;AAQDC,uBAAkB,CAAC,yBAAyB,CAAC;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vest"),t=require("vest-utils"),r=require("vestjs-runtime");class o{static match(e,t){return r.IsolateSelectors.isIsolateType(e,"Debounce")&&r.IsolateSelectors.isIsolateType(t,"Debounce")}static reconcile(e,t){var r,o;return null===(o=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.clearTimeout)||void 0===o||o.call(r),e}}e.registerReconciler(o),exports.IsolateDebounceReconciler=o,exports.default=function(e,o=0){let l=null;return r.Isolate.create("Debounce",(()=>r=>new Promise(((s,u)=>{l=setTimeout((()=>{let o=!1;try{o=e(r)}catch(e){return u(e)}return!1===o?u():t.isPromise(o)?o.then(s,u):s(o)}),o)}))),{clearTimeout:()=>{l&&clearTimeout(l)}}).output};
|
|
2
|
+
//# sourceMappingURL=debounce.production.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.production.js","sources":["../../src/exports/debounce.ts"],"sourcesContent":["import { registerReconciler } from 'vest';\nimport { CB, isPromise, Nullable } from 'vest-utils';\nimport { Isolate, TIsolate, IsolateSelectors } from 'vestjs-runtime';\n\nimport { TestFn, TestFnPayload } from 'TestTypes';\n\nconst isolateType = 'Debounce';\n\nexport default function debounce<Callback extends CB = CB>(\n callback: Callback,\n delay: number = 0,\n): TestFn {\n let timeout: Nullable<NodeJS.Timeout> = null;\n\n const f = () => (payload: TestFnPayload) =>\n new Promise((resolve, reject) => {\n timeout = setTimeout(() => {\n let res = false;\n try {\n res = callback(payload);\n } catch (e) {\n return reject(e);\n }\n\n if (res === false) {\n return reject();\n }\n\n return isPromise(res) ? res.then(resolve, reject) : resolve(res);\n }, delay);\n });\n\n const i = Isolate.create(isolateType, f, {\n clearTimeout: () => {\n if (timeout) {\n clearTimeout(timeout);\n }\n },\n });\n\n return i.output;\n}\n\nexport class IsolateDebounceReconciler {\n static match(currentNode: TIsolate, historyNode: TIsolate): boolean {\n return (\n IsolateSelectors.isIsolateType(currentNode, isolateType) &&\n IsolateSelectors.isIsolateType(historyNode, isolateType)\n );\n }\n\n static reconcile(current: TIsolateDebounce, history: TIsolateDebounce) {\n history?.data?.clearTimeout?.();\n\n return current;\n }\n}\n\nexport type TIsolateDebounce = TIsolate<IsolateDebouncePayload>;\n\nexport type IsolateDebouncePayload = {\n clearTimeout: () => void;\n};\n\nregisterReconciler(IsolateDebounceReconciler);\n"],"names":["IsolateDebounceReconciler","static","currentNode","historyNode","IsolateSelectors","isIsolateType","current","history","_b","_a","data","clearTimeout","call","registerReconciler","callback","delay","timeout","Isolate","create","payload","Promise","resolve","reject","setTimeout","res","e","isPromise","then","output"],"mappings":"oJA2CaA,EACXC,aAAaC,EAAuBC,GAClC,OACEC,mBAAiBC,cAAcH,EAxCjB,aAyCdE,EAAAA,iBAAiBC,cAAcF,EAzCjB,WA2CjB,CAEDF,iBAAiBK,EAA2BC,WAG1C,OAF2B,QAA3BC,EAAa,QAAbC,EAAAF,aAAO,EAAPA,EAASG,YAAI,IAAAD,OAAA,EAAAA,EAAEE,oBAAY,IAAAH,GAAAA,EAAAI,KAAAH,GAEpBH,CACR,EASHO,EAAkBA,mBAACb,uDAxDK,SACtBc,EACAC,EAAgB,GAEhB,IAAIC,EAAoC,KA4BxC,OARUC,EAAOA,QAACC,OA1BA,YAQR,IAAOC,GACf,IAAIC,SAAQ,CAACC,EAASC,KACpBN,EAAUO,YAAW,KACnB,IAAIC,GAAM,EACV,IACEA,EAAMV,EAASK,EAGhB,CAFC,MAAOM,GACP,OAAOH,EAAOG,EACf,CAED,OAAY,IAARD,EACKF,IAGFI,EAASA,UAACF,GAAOA,EAAIG,KAAKN,EAASC,GAAUD,EAAQG,EAAI,GAC/DT,EAAM,KAG4B,CACvCJ,aAAc,KACRK,GACFL,aAAaK,EACd,IAIIY,MACX"}
|