Skip to content

Commit

Permalink
Merge pull request #12 from vbudovski/feature/tree-shaking
Browse files Browse the repository at this point in the history
feature: Tree shaking
  • Loading branch information
vbudovski authored Dec 26, 2024
2 parents 4604c5b + 7c00e9e commit 0a00c35
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 62 deletions.
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ class ArraySchema<ElementSchemaType extends AnySchemaType> extends Schema<Infer<
}
}

function array<ElementSchemaType extends AnySchemaType>(
const array = /* @__PURE__ */ <ElementSchemaType extends AnySchemaType>(
...args: ConstructorParameters<typeof ArraySchema<ElementSchemaType>>
): ArraySchema<ElementSchemaType> {
return new ArraySchema(...args);
}
): ArraySchema<ElementSchemaType> => new ArraySchema(...args);

export { array };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/bigint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ class BigIntSchema extends Schema<bigint> {

const singleton = new BigIntSchema();

function bigint(): BigIntSchema {
return singleton;
}
const bigint = /* @__PURE__ */ (): BigIntSchema => singleton;

export { bigint };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class BooleanSchema extends Schema<boolean> {

const singleton = new BooleanSchema();

function boolean(): BooleanSchema {
return singleton;
}
const boolean = /* @__PURE__ */ (): BooleanSchema => singleton;

export { boolean };
6 changes: 3 additions & 3 deletions paseri-lib/src/schemas/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class LazySchema<OutputType> extends Schema<OutputType> {
}
}

function lazy<OutputType>(...args: ConstructorParameters<typeof LazySchema<OutputType>>): LazySchema<OutputType> {
return new LazySchema(...args);
}
const lazy = /* @__PURE__ */ <OutputType>(
...args: ConstructorParameters<typeof LazySchema<OutputType>>
): LazySchema<OutputType> => new LazySchema(...args);

export { lazy };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ class LiteralSchema<OutputType extends LiteralType> extends Schema<OutputType> {
}
}

function literal<OutputType extends LiteralType>(
const literal = /* @__PURE__ */ <OutputType extends LiteralType>(
...args: ConstructorParameters<typeof LiteralSchema<OutputType>>
): LiteralSchema<OutputType> {
return new LiteralSchema(...args);
}
): LiteralSchema<OutputType> => new LiteralSchema(...args);

export { literal };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ class MapSchema<
}
}

function map<ElementKeySchemaType extends AnySchemaType, ElementValueSchemaType extends AnySchemaType>(
const map = /* @__PURE__ */ <ElementKeySchemaType extends AnySchemaType, ElementValueSchemaType extends AnySchemaType>(
...args: ConstructorParameters<typeof MapSchema<ElementKeySchemaType, ElementValueSchemaType>>
): MapSchema<ElementKeySchemaType, ElementValueSchemaType> {
return new MapSchema(...args);
}
): MapSchema<ElementKeySchemaType, ElementValueSchemaType> => new MapSchema(...args);

export { map };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/never.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class NeverSchema extends Schema<never> {

const singleton = new NeverSchema();

function never(): NeverSchema {
return singleton;
}
const never = /* @__PURE__ */ (): NeverSchema => singleton;

export { never };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/null.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class NullSchema extends Schema<null> {
const singleton = new NullSchema();

// `null` is a reserved word.
function null_(): NullSchema {
return singleton;
}
const null_ = /* @__PURE__ */ (): NullSchema => singleton;

export { null_ };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class NumberSchema extends Schema<number> {

const singleton = new NumberSchema();

function number(): NumberSchema {
return singleton;
}
const number = /* @__PURE__ */ (): NumberSchema => singleton;

export { number };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,8 @@ class ObjectSchema<ShapeType extends Record<string, Schema<unknown>>> extends Sc
}
}

function object<ShapeType extends ValidShapeType<ShapeType>>(
const object = /* @__PURE__ */ <ShapeType extends ValidShapeType<ShapeType>>(
...args: ConstructorParameters<typeof ObjectSchema<ShapeType>>
): ObjectSchema<ShapeType> {
return new ObjectSchema(...args);
}
): ObjectSchema<ShapeType> => new ObjectSchema(...args);

export { object };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ class RecordSchema<ElementSchemaType extends AnySchemaType> extends Schema<Infer
}
}

function record<ElementSchemaType extends AnySchemaType>(
const record = /* @__PURE__ */ <ElementSchemaType extends AnySchemaType>(
...args: ConstructorParameters<typeof RecordSchema<ElementSchemaType>>
): RecordSchema<ElementSchemaType> {
return new RecordSchema(...args);
}
): RecordSchema<ElementSchemaType> => new RecordSchema(...args);

export { record };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ class SetSchema<ElementSchemaType extends AnySchemaType> extends Schema<Infer<Se
}
}

function set<ElementSchemaType extends AnySchemaType>(
const set = /* @__PURE__ */ <ElementSchemaType extends AnySchemaType>(
...args: ConstructorParameters<typeof SetSchema<ElementSchemaType>>
): SetSchema<ElementSchemaType> {
return new SetSchema(...args);
}
): SetSchema<ElementSchemaType> => new SetSchema(...args);

export { set };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ class StringSchema extends Schema<string> {

const singleton = new StringSchema();

function string(): StringSchema {
return singleton;
}
const string = /* @__PURE__ */ (): StringSchema => singleton;

export { string, emailRegex, emojiRegex, uuidRegex, nanoidRegex };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class SymbolSchema extends Schema<symbol> {

const singleton = new SymbolSchema();

function symbol(): SymbolSchema {
return singleton;
}
const symbol = /* @__PURE__ */ (): SymbolSchema => singleton;

export { symbol };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/tuple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ class TupleSchema<TupleSchemaType extends ValidTupleSchemaType> extends Schema<I
}
}

function tuple<TupleSchemaType extends ValidTupleSchemaType>(
const tuple = /* @__PURE__ */ <TupleSchemaType extends ValidTupleSchemaType>(
...args: ConstructorParameters<typeof TupleSchema<TupleSchemaType>>
): TupleSchema<TupleSchemaType> {
return new TupleSchema(...args);
}
): TupleSchema<TupleSchemaType> => new TupleSchema(...args);

export { tuple };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/undefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class UndefinedSchema extends Schema<undefined> {
const singleton = new UndefinedSchema();

// `undefined` is a reserved word.
function undefined_(): UndefinedSchema {
return singleton;
}
const undefined_ = /* @__PURE__ */ (): UndefinedSchema => singleton;

export { undefined_ };
6 changes: 2 additions & 4 deletions paseri-lib/src/schemas/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ class UnionSchema<TupleType extends ValidTupleType> extends Schema<Infer<TupleTo
}
}

function union<TupleType extends ValidTupleType>(
const union = /* @__PURE__ */ <TupleType extends ValidTupleType>(
...args: ConstructorParameters<typeof UnionSchema<TupleType>>
): UnionSchema<TupleType> {
return new UnionSchema(...args);
}
): UnionSchema<TupleType> => new UnionSchema(...args);

export { union };
4 changes: 1 addition & 3 deletions paseri-lib/src/schemas/unknown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class UnknownSchema extends Schema<unknown> {

const singleton = new UnknownSchema();

function unknown(): UnknownSchema {
return singleton;
}
const unknown = /* @__PURE__ */ (): UnknownSchema => singleton;

export { unknown };

0 comments on commit 0a00c35

Please sign in to comment.