Skip to content

Commit

Permalink
Merge pull request #13 from grafana/feat/add-async-check-util
Browse files Browse the repository at this point in the history
Add async check util
  • Loading branch information
allansson authored Aug 16, 2024
2 parents d0d6f82 + f01e1f0 commit f631eeb
Show file tree
Hide file tree
Showing 16 changed files with 933 additions and 315 deletions.
5 changes: 4 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"presets": [
[
"@babel/preset-env"
]
],
[
"@babel/preset-typescript"
]
],
"plugins": [ "@babel/plugin-transform-block-scoping"]
}
11 changes: 11 additions & 0 deletions build/check.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type CheckValue = Array<unknown> | Record<string | number | symbol, unknown> | boolean | string | number | null | undefined;
type Checker<T> = ((value: T) => CheckValue) | ((value: T) => Promise<CheckValue>) | CheckValue | Promise<CheckValue>;
interface CheckMap<T> {
[key: string]: Checker<T>;
}
interface SyncCheckMap {
[key: string]: ((value: any) => CheckValue) | CheckValue;
}
type CheckResult<C extends CheckMap<any>> = C extends SyncCheckMap ? boolean : Promise<boolean>;
export declare function check<T, C extends CheckMap<T>>(value: T, checkers: C, tags?: Record<string, string>): CheckResult<C>;
export {};
12 changes: 12 additions & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { check } from './check.ts';
import { parseDuration } from './stages.js';
import { getCurrentStageIndex } from './stages.js';
import { tagWithCurrentStageIndex } from './stages.js';
import { tagWithCurrentStageProfile } from './stages.js';
import { findBetween } from './utils.js';
import { normalDistributionStages } from './utils.js';
import { randomIntBetween } from './utils.js';
import { randomItem } from './utils.js';
import { randomString } from './utils.js';
import { uuidv4 } from './utils.js';
export { check, parseDuration, getCurrentStageIndex, tagWithCurrentStageIndex, tagWithCurrentStageProfile, findBetween, normalDistributionStages, randomIntBetween, randomItem, randomString, uuidv4 };
2 changes: 1 addition & 1 deletion build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions build/index.min.js

This file was deleted.

Loading

0 comments on commit f631eeb

Please sign in to comment.