From dc2d434aa95e07e9ff2e65b242a375e0c10a9e6d Mon Sep 17 00:00:00 2001 From: Ilya Semenov Date: Sat, 24 Dec 2022 22:54:47 +0700 Subject: [PATCH] feat: export individual cleaner functions Export `cleanString` etc. for better tree shaking --- packages/data-cleaner/src/clean/index-ns.ts | 10 ++++++++++ packages/data-cleaner/src/clean/index.ts | 20 ++++++++++---------- packages/data-cleaner/src/errors/index.ts | 2 ++ packages/data-cleaner/src/index.ts | 15 ++++++++++++--- 4 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 packages/data-cleaner/src/clean/index-ns.ts create mode 100644 packages/data-cleaner/src/errors/index.ts diff --git a/packages/data-cleaner/src/clean/index-ns.ts b/packages/data-cleaner/src/clean/index-ns.ts new file mode 100644 index 0000000..ae5e09f --- /dev/null +++ b/packages/data-cleaner/src/clean/index-ns.ts @@ -0,0 +1,10 @@ +export { cleanAny as any, AnySchema } from "./any" +export { cleanArray as array, ArraySchema } from "./array" +export { cleanBoolean as boolean, BooleanSchema } from "./boolean" +export { cleanDate as date, DateSchema } from "./date" +export { cleanEmail as email, EmailSchema } from "./email" +export { cleanFloat as float, FloatSchema } from "./float" +export { cleanInteger as integer, IntegerSchema } from "./integer" +export { cleanObject as object, ObjectSchema } from "./object" +export { cleanString as string, StringSchema } from "./string" +export { cleanUuid as uuid, UuidSchema } from "./uuid" diff --git a/packages/data-cleaner/src/clean/index.ts b/packages/data-cleaner/src/clean/index.ts index ae5e09f..7d6b2ee 100644 --- a/packages/data-cleaner/src/clean/index.ts +++ b/packages/data-cleaner/src/clean/index.ts @@ -1,10 +1,10 @@ -export { cleanAny as any, AnySchema } from "./any" -export { cleanArray as array, ArraySchema } from "./array" -export { cleanBoolean as boolean, BooleanSchema } from "./boolean" -export { cleanDate as date, DateSchema } from "./date" -export { cleanEmail as email, EmailSchema } from "./email" -export { cleanFloat as float, FloatSchema } from "./float" -export { cleanInteger as integer, IntegerSchema } from "./integer" -export { cleanObject as object, ObjectSchema } from "./object" -export { cleanString as string, StringSchema } from "./string" -export { cleanUuid as uuid, UuidSchema } from "./uuid" +export * from "./any" +export * from "./array" +export * from "./boolean" +export * from "./date" +export * from "./email" +export * from "./float" +export * from "./integer" +export * from "./object" +export * from "./string" +export * from "./uuid" diff --git a/packages/data-cleaner/src/errors/index.ts b/packages/data-cleaner/src/errors/index.ts new file mode 100644 index 0000000..39d4e11 --- /dev/null +++ b/packages/data-cleaner/src/errors/index.ts @@ -0,0 +1,2 @@ +export * from "./SchemaError" +export * from "./ValidationError" diff --git a/packages/data-cleaner/src/index.ts b/packages/data-cleaner/src/index.ts index 42f143d..4332f62 100644 --- a/packages/data-cleaner/src/index.ts +++ b/packages/data-cleaner/src/index.ts @@ -1,5 +1,14 @@ +// allows: +// import { cleanString } from "data-cleaner" +// cleanString() export * from "./clean" -export * as clean from "./clean" -export * from "./errors/SchemaError" -export * from "./errors/ValidationError" +// [DEPRECATED] allows: +// import * as clean from "data-cleaner" +// clean.string() +export * from "./clean/index-ns" +// allows: +// import { clean } from "data-cleaner" +// clean.string() +export * as clean from "./clean/index-ns" +export * from "./errors" export * from "./types"