Comparing version 3.4.9 to 3.4.10
@@ -5,4 +5,4 @@ import ts from "typescript"; | ||
function isArray(input: ts.Expression): ts.Expression; | ||
function isObject(input: ts.Expression, nullChecked: boolean): ts.Expression; | ||
function isObject(input: ts.Expression, checkNull: boolean): ts.Expression; | ||
function isInstanceOf(input: ts.Expression, type: string): ts.Expression; | ||
} |
@@ -18,11 +18,10 @@ "use strict"; | ||
ExpressionFactory.isArray = isArray; | ||
function isObject(input, nullChecked) { | ||
function isObject(input, checkNull) { | ||
var conditions = [ | ||
typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createStringLiteral("object"), typescript_1.default.factory.createTypeOfExpression(input)), | ||
]; | ||
if (nullChecked === true) | ||
if (checkNull === true) | ||
conditions.push(typescript_1.default.factory.createStrictInequality(typescript_1.default.factory.createNull(), input)); | ||
return conditions.length === 1 | ||
? conditions[0] | ||
: conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); }); | ||
conditions.push(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Array.isArray"), undefined, [input]))); | ||
return conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); }); | ||
} | ||
@@ -29,0 +28,0 @@ ExpressionFactory.isObject = isObject; |
@@ -5,5 +5,5 @@ import ts from "typescript"; | ||
const UNDEFINED: () => ts.Identifier; | ||
const BOOLEAN: (value: boolean) => ts.TrueLiteral | ts.FalseLiteral; | ||
const BOOLEAN: (value: boolean) => ts.FalseLiteral | ts.TrueLiteral; | ||
const INPUT: (str?: string) => ts.Identifier; | ||
const TYPEOF: (input: ts.Expression) => ts.TypeOfExpression; | ||
} |
{ | ||
"name": "typia", | ||
"version": "3.4.9", | ||
"version": "3.4.10", | ||
"description": "Runtime type checkers and 5x faster JSON.stringify() function", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
128
README.md
@@ -44,2 +44,12 @@ # Typia | ||
## Sponsors and Backers | ||
Thanks for your support. | ||
Your donation would encourage `typia` development. | ||
[![Backers](https://opencollective.com/typia/backers.svg?width=1000)](https://opencollective.com/typia) | ||
## Setup | ||
@@ -82,3 +92,3 @@ ### Setup Wizard | ||
### vite | ||
### Vite | ||
When you want to setup `typia` on your frontend project with [`vite`](https://vitejs.dev/), just configure `vite.config.ts` like below. | ||
@@ -208,102 +218,34 @@ | ||
### Nestia | ||
https://github.com/samchon/nestia | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE) | ||
[![npm version](https://img.shields.io/npm/v/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core) | ||
[![Downloads](https://img.shields.io/npm/dm/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core) | ||
[![Build Status](https://github.com/samchon/typia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild) | ||
[![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/nestia/wiki) | ||
Automatic `SDK` and `Swagger` generator for `NestJS`, evolved than ever. | ||
[Nestia](https://github.com/samchon/nestia) is a helper library set for `NestJS`, supporting below features: | ||
`nestia` is an evolved `SDK` and `Swagger` generator, which analyzes your `NestJS` server code in the compilation level. With `nestia` and compilation level analyzer, you don't need to write any swagger or class-validator decorators. | ||
- [`@nestia/core`](https://github.com/samchon/nestia#nestiacore): **15,000x times faster** validation decorator using `typia` | ||
- [`@nestia/sdk`](https://github.com/samchon/nestia#nestiasdk): evolved **SDK** and **Swagger** generator for `@nestia/core` | ||
- `nestia`: just CLI (command line interface) tool | ||
Reading below table and example code, feel how the "compilation level" makes `nestia` stronger. | ||
Components | `nestia`::SDK | `nestia`::swagger | `@nestjs/swagger` | ||
-----------|---|---|--- | ||
Pure DTO interface | ✔ | ✔ | ❌ | ||
Description comments | ✔ | ✔ | ❌ | ||
Simple structure | ✔ | ✔ | ✔ | ||
Generic type | ✔ | ✔ | ❌ | ||
Union type | ✔ | ✔ | ▲ | ||
Intersection type | ✔ | ✔ | ▲ | ||
Conditional type | ✔ | ▲ | ❌ | ||
Auto completion | ✔ | ❌ | ❌ | ||
Type hints | ✔ | ❌ | ❌ | ||
5x faster `JSON.stringify()` | ✔ | ❌ | ❌ | ||
Ensure type safety | ✅ | ❌ | ❌ | ||
```typescript | ||
// IMPORT SDK LIBRARY GENERATED BY NESTIA | ||
import api from "@samchon/shopping-api"; | ||
import { IPage } from "@samchon/shopping-api/lib/structures/IPage"; | ||
import { ISale } from "@samchon/shopping-api/lib/structures/ISale"; | ||
import { ISaleArticleComment } from "@samchon/shopping-api/lib/structures/ISaleArticleComment"; | ||
import { ISaleQuestion } from "@samchon/shopping-api/lib/structures/ISaleQuestion"; | ||
import { Controller } from "@nestjs/common"; | ||
import { TypedBody, TypedRoute } from "@nestia/core"; | ||
export async function trace_sale_question_and_comment | ||
(connection: api.IConnection): Promise<void> | ||
{ | ||
// LIST UP SALE SUMMARIES | ||
const index: IPage<ISale.ISummary> = await api.functional.shoppings.sales.index | ||
( | ||
connection, | ||
"general", | ||
{ limit: 100, page: 1 } | ||
); | ||
import { IBbsArticle } from "@bbs-api/structures/IBbsArticle"; | ||
// PICK A SALE | ||
const sale: ISale = await api.functional.shoppings.sales.at | ||
( | ||
connection, | ||
index.data[0].id | ||
); | ||
console.log("sale", sale); | ||
// WRITE A QUESTION | ||
const question: ISaleQuestion = await api.functional.shoppings.sales.questions.store | ||
( | ||
connection, | ||
"general", | ||
sale.id, | ||
{ | ||
title: "How to use this product?", | ||
body: "The description is not fully enough. Can you introduce me more?", | ||
files: [] | ||
} | ||
); | ||
console.log("question", question); | ||
// WRITE A COMMENT | ||
const comment: ISaleArticleComment = await api.functional.shoppings.sales.comments.store | ||
( | ||
connection, | ||
"general", | ||
sale.id, | ||
question.id, | ||
{ | ||
body: "p.s) Can you send me a detailed catalogue?", | ||
anonymous: false | ||
} | ||
); | ||
console.log("comment", comment); | ||
} | ||
``` | ||
### Nestia-Helper | ||
https://github.com/samchon/nestia-helper | ||
Helper library of `NestJS`, using this `typia`. | ||
`nestia-helper` is a helper library of `NestJS`, which boosts up the `JSON.stringify()` speed 5x times faster about the API responses, automatically. Also, `nestia-helper` supports automatic validation of request body, that is maximum 15,000x times faster than legacy `class-validator` too. | ||
```typescript | ||
import helper from "nestia-helper"; | ||
import * as nest from "@nestjs/common"; | ||
@nest.Controller("bbs/articles") | ||
export class BbsArticlesController | ||
{ | ||
// automatic typia.stringify() for response body | ||
@helper.TypedRoute.Get() | ||
public store( | ||
// automatic typia.assert() for request body | ||
@helper.TypedBody() input: IBbsArticle.IStore | ||
@Controller("bbs/articles") | ||
export class BbsArticlesController { | ||
/** | ||
* Store a new content. | ||
* | ||
* @param inupt Content to store | ||
* @returns Newly archived article | ||
*/ | ||
@TypedRoute.Post() // 10x faster and safer JSON.stringify() | ||
public async store( | ||
// super-fast validator | ||
@TypedBody() input: IBbsArticle.IStore | ||
): Promise<IBbsArticle>; | ||
} | ||
``` |
@@ -21,3 +21,3 @@ import ts from "typescript"; | ||
input: ts.Expression, | ||
nullChecked: boolean, | ||
checkNull: boolean, | ||
): ts.Expression { | ||
@@ -30,3 +30,3 @@ const conditions: ts.Expression[] = [ | ||
]; | ||
if (nullChecked === true) | ||
if (checkNull === true) | ||
conditions.push( | ||
@@ -38,6 +38,14 @@ ts.factory.createStrictInequality( | ||
); | ||
conditions.push( | ||
ts.factory.createStrictEquality( | ||
ts.factory.createFalse(), | ||
ts.factory.createCallExpression( | ||
ts.factory.createIdentifier("Array.isArray"), | ||
undefined, | ||
[input], | ||
), | ||
), | ||
); | ||
return conditions.length === 1 | ||
? conditions[0]! | ||
: conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y)); | ||
return conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y)); | ||
} | ||
@@ -44,0 +52,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21347
1194396
249