Skip to content

Commit

Permalink
style: format source code
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 19, 2023
1 parent 9b7bc07 commit 74ca7e0
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 18 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@
![](https://github.com/thetutlage/static/blob/main/sponsorkit/sponsors.png?raw=true)

[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/vinejs/vine/test.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/vinejs/vine/actions/workflows/test.yml "Github action"

[gh-workflow-url]: https://github.com/vinejs/vine/actions/workflows/test.yml 'Github action'
[npm-image]: https://img.shields.io/npm/v/@vinejs/vine/latest.svg?style=for-the-badge&logo=npm
[npm-url]: https://www.npmjs.com/package/@vinejs/vine/v/latest "npm"

[npm-url]: https://www.npmjs.com/package/@vinejs/vine/v/latest 'npm'
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript

[license-url]: LICENSE.md
[license-image]: https://img.shields.io/github/license/vinejs/vine?style=for-the-badge

[snyk-image]: https://img.shields.io/snyk/vulnerabilities/github/vinejs/vine?label=Snyk%20Vulnerabilities&style=for-the-badge
[snyk-url]: https://snyk.io/test/github/vinejs/vine?targetFile=package.json "snyk"
[snyk-url]: https://snyk.io/test/github/vinejs/vine?targetFile=package.json 'snyk'
8 changes: 8 additions & 0 deletions benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Following are the results from the benchmarks executed on the `Apple M1 Mac - 16
- VineJS performance is the outcome of our pre-compiling API. Both Yup and Zod have no option for pre-compiling schemas.

## Benchmarking against a flat object

The source for this benchmark is saved inside the [./benchmarks/flat_object.ts](./benchmarks/flat_object.ts) file. You may run the benchmark as follows.

```sh
Expand All @@ -15,6 +16,7 @@ node build/benchmarks/flat_object.js
```

### Results

```
===============================
Benchmarking with flat object
Expand All @@ -26,6 +28,7 @@ Fastest is Vine
```

## Benchmarking against a nested object

The source for this benchmark is saved inside the [./benchmarks/nested_object.ts](./benchmarks/nested_object.ts) file. You may run the benchmark as follows.

```sh
Expand All @@ -34,6 +37,7 @@ node build/benchmarks/nested_object.js
```

### Results

```
=================================
Benchmarking with nested object
Expand All @@ -45,6 +49,7 @@ Fastest is Vine
```

## Benchmarking arrays

The source for this benchmark is saved inside the [./benchmarks/array.ts](./benchmarks/array.ts) file. You may run the benchmark as follows.

```sh
Expand All @@ -53,6 +58,7 @@ node build/benchmarks/array.js
```

### Results

```
======================
Benchmarking arrays
Expand All @@ -64,6 +70,7 @@ Fastest is Vine
```

## Benchmarking unions

The source for this benchmark is saved inside the [./benchmarks/union.ts](./benchmarks/union.ts) file. You may run the benchmark as follows.

> **Note**: Yup does not support unions, so there are no benchmarks for it.
Expand All @@ -74,6 +81,7 @@ node build/benchmarks/union.js
```

### Results

```
=======================
Benchmarking unions
Expand Down
5 changes: 4 additions & 1 deletion src/errors/validation_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export class ValidationError extends Error {
*/
code: string = 'E_VALIDATION_ERROR'

constructor(public messages: any, options?: ErrorOptions) {
constructor(
public messages: any,
options?: ErrorOptions
) {
super('Validation failure', options)
const ErrorConstructor = this.constructor as typeof ValidationError
Error.captureStackTrace(this, ErrorConstructor)
Expand Down
2 changes: 1 addition & 1 deletion src/schema/base/literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class OptionalModifier<Schema extends BaseModifiersType<any, any>> extends BaseM
*/
class TransformModifier<
Schema extends BaseModifiersType<any, any>,
Output
Output,
> extends BaseModifiersType<Output, Output> {
/**
* The output value of the field. The property points to a type only
Expand Down
6 changes: 3 additions & 3 deletions src/schema/camelcase_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type WordInPascalCase<Type> = Capitalize<WordInCamelCase<Uncapitalize<Type & str

type WordInCamelCase<
Type,
Character extends string = ''
Character extends string = '',
> = Type extends `${Character}${infer NextCharacter}${infer _}`
? NextCharacter extends Capitalize<NextCharacter>
? Character
Expand All @@ -45,7 +45,7 @@ type IsPascalCase<Type> = Type extends Capitalize<Type & string> ? true : false
/** snake_case, CONSTANT_CASE, kebab-case or COBOL-CASE */
type SeparatorCaseParser<
Type,
Tuple extends readonly any[] = []
Tuple extends readonly any[] = [],
> = Type extends `${infer Word}${Separator}${infer Tail}`
? SeparatorCaseParser<Tail, [...Tuple, Lowercase<Word>]>
: Type extends `${infer Word}`
Expand Down Expand Up @@ -80,7 +80,7 @@ type SplitAnyCase<Type> = IncludesSeparator<Type> extends true

type PascalCapitalizer<Type, Tuple extends readonly any[] = []> = Type extends [
infer Head,
...infer Tail
...infer Tail,
]
? Head extends string
? PascalCapitalizer<Tail, [...Tuple, Capitalize<Head>]>
Expand Down
2 changes: 1 addition & 1 deletion src/schema/object/conditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { ParserOptions, SchemaTypes } from '../../types.js'
export class GroupConditional<
Properties extends Record<string, SchemaTypes>,
Output,
CamelCaseOutput
CamelCaseOutput,
> {
declare [OTYPE]: Output;
declare [COTYPE]: CamelCaseOutput
Expand Down
4 changes: 2 additions & 2 deletions src/schema/object/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { Validation, SchemaTypes, FieldOptions, ParserOptions } from '../..
* Converts schema properties to camelCase
*/
export class VineCamelCaseObject<
Schema extends VineObject<any, any, any>
Schema extends VineObject<any, any, any>,
> extends BaseModifiersType<Schema[typeof COTYPE], Schema[typeof COTYPE]> {
#schema: Schema;

Expand Down Expand Up @@ -65,7 +65,7 @@ export class VineCamelCaseObject<
export class VineObject<
Properties extends Record<string, SchemaTypes>,
Output,
CamelCaseOutput
CamelCaseOutput,
> extends BaseType<Output, CamelCaseOutput> {
/**
* Object properties
Expand Down
2 changes: 1 addition & 1 deletion src/schema/tuple/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { FieldOptions, ParserOptions, SchemaTypes, Validation } from '../..
export class VineTuple<
Schema extends SchemaTypes[],
Output extends any[],
CamelCaseOutput extends any[]
CamelCaseOutput extends any[],
> extends BaseType<Output, CamelCaseOutput> {
#schemas: [...Schema]

Expand Down
2 changes: 1 addition & 1 deletion src/vine/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const COMPILER_ERROR_MESSAGES = {
*/
export class VineValidator<
Schema extends SchemaTypes,
MetaData extends undefined | Record<string, any>
MetaData extends undefined | Record<string, any>,
> {
/**
* Reference to static types
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"rootDir": "./",
"outDir": "./build"
}
}
}

0 comments on commit 74ca7e0

Please sign in to comment.