@signaltree/ng-forms 4.1.4 → 4.1.6
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/constants.js +6 -0
- package/dist/core/async-validators.js +24 -0
- package/dist/core/ng-forms.js +880 -0
- package/dist/core/validators.js +56 -0
- package/dist/deep-clone.js +80 -0
- package/dist/history/history.js +113 -0
- package/dist/index.js +4 -0
- package/dist/lru-cache.js +64 -0
- package/dist/match-path.js +13 -0
- package/dist/merge-deep.js +26 -0
- package/dist/parse-path.js +13 -0
- package/dist/snapshots-equal.js +5 -0
- package/dist/tslib.es6.js +34 -0
- package/package.json +23 -33
- package/src/audit/audit.d.ts +11 -0
- package/src/audit/index.d.ts +1 -0
- package/src/core/async-validators.d.ts +3 -0
- package/src/core/ng-forms.d.ts +90 -0
- package/src/core/validators.d.ts +9 -0
- package/src/history/history.d.ts +21 -0
- package/src/history/index.d.ts +1 -0
- package/src/index.d.ts +4 -0
- package/src/rxjs/index.d.ts +1 -0
- package/src/rxjs/public-api.d.ts +1 -0
- package/src/rxjs/rxjs-bridge.d.ts +3 -0
- package/src/wizard/index.d.ts +1 -0
- package/src/wizard/wizard.d.ts +19 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isObservable, firstValueFrom } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
function unique(checkFn, message = 'Already exists') {
|
|
4
|
+
return async value => {
|
|
5
|
+
if (!value) return null;
|
|
6
|
+
const exists = await checkFn(value);
|
|
7
|
+
return exists ? message : null;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function debounce(validator, delayMs) {
|
|
11
|
+
let timeoutId;
|
|
12
|
+
return async value => {
|
|
13
|
+
return new Promise(resolve => {
|
|
14
|
+
clearTimeout(timeoutId);
|
|
15
|
+
timeoutId = setTimeout(async () => {
|
|
16
|
+
const maybeAsync = validator(value);
|
|
17
|
+
const result = isObservable(maybeAsync) ? await firstValueFrom(maybeAsync) : await maybeAsync;
|
|
18
|
+
resolve(result);
|
|
19
|
+
}, delayMs);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { debounce, unique };
|