Skip to content

Commit

Permalink
Revision 0.20.0 Codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Jul 27, 2023
1 parent 407efd3 commit a1441a9
Show file tree
Hide file tree
Showing 31 changed files with 1,196 additions and 877 deletions.
3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-cast.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-check.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-clone.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-convert.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-create.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-delta.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-equal.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-guard.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-hash.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-mutate.ts

This file was deleted.

3 changes: 0 additions & 3 deletions benchmark/compression/module/typebox-value-pointer.ts

This file was deleted.

29 changes: 9 additions & 20 deletions changelog/0.30.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,13 @@ For information on configuring custom formats on Ajv, refer to https://ajv.js.or

// Revision 0.30.0
//
┌───────────────────────┬────────────┬────────────┬─────────────┐
│ (index) │ CompiledMinifiedCompression
├───────────────────────┼────────────┼────────────┼─────────────┤
typebox/compiler'128.5 kb'' 58.7 kb''2.19 x'
typebox/errors'110.7 kb'' 50.1 kb''2.21 x'
typebox/system' 75.4 kb'' 31.3 kb''2.41 x'
typebox/value/cast'123.0 kb'' 51.8 kb''2.37 x'
typebox/value/check' 95.3 kb'' 40.0 kb''2.38 x'
typebox/value/clone' 3.0 kb'' 1.3 kb''2.23 x'
typebox/value/convert'108.1 kb'' 45.6 kb''2.37 x'
typebox/value/create'108.8 kb'' 46.1 kb''2.36 x'
typebox/value/delta' 85.2 kb'' 35.7 kb''2.38 x'
typebox/value/equal' 2.9 kb'' 1.5 kb''1.97 x'
typebox/value/guard' 2.8 kb'' 1.4 kb''1.99 x'
typebox/value/hash' 4.1 kb'' 1.9 kb''2.09 x'
typebox/value/mutate' 8.7 kb'' 3.5 kb''2.46 x'
typebox/value/pointer' 3.2 kb'' 1.2 kb''2.61 x'
typebox/value'180.6 kb'' 80.2 kb''2.25 x'
typebox' 74.3 kb'' 30.8 kb''2.41 x'
└───────────────────────┴────────────┴────────────┴─────────────┘
┌──────────────────────┬────────────┬────────────┬─────────────┐
│ (index) │ CompiledMinifiedCompression
├──────────────────────┼────────────┼────────────┼─────────────┤
typebox/compiler'128.9 kb'' 58.5 kb''2.20 x'
typebox/errors'111.1 kb'' 49.8 kb''2.23 x'
typebox/system' 75.9 kb'' 31.4 kb''2.42 x'
typebox/value'180.4 kb'' 79.0 kb''2.28 x'
typebox' 74.8 kb'' 31.0 kb''2.42 x'
└──────────────────────┴────────────┴────────────┴─────────────┘
```
31 changes: 27 additions & 4 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TypeSystem } from '@sinclair/typebox/system'
import { TypeCompiler } from '@sinclair/typebox/compiler'
import { Value, ValuePointer } from '@sinclair/typebox/value'
import { Type, TypeGuard, Kind, Static, TSchema, Optional } from '@sinclair/typebox'
import { Type, TypeGuard, Kind, Static, TSchema, Optional, TNumber } from '@sinclair/typebox'

// Modifiers
// - Deprecate Modifier Symbol
Expand Down Expand Up @@ -32,6 +32,29 @@ import { Type, TypeGuard, Kind, Static, TSchema, Optional } from '@sinclair/type
// - figure out what to do with non-nomimal-object
// - rename is-plain-object

import { Check } from '@sinclair/typebox/value/check'
import { Cast } from '@sinclair/typebox/value/cast'
import { Convert } from '@sinclair/typebox/value/convert'
import { TTransform, Transform, Encode, Decode } from '@sinclair/typebox/transform'

import * as Types from '@sinclair/typebox'

// export type UnwrapTransformIntersect<T extends TSchema[]> = T extends [infer L, ...infer R]
// ?
// export type UnwrapTransform<T extends TSchema> =
// T extends Types.TIntersect<

const T = Transform(Type.String(), {
decode: (value) => new Date(),
encode: (value) => 'string',
})

const U = Transform(T, {
decode: (value) => 1,
encode: (value) => new Date(),
})

const D = Decode(U, '')
const E = Encode(U, D)

console.log(D)
console.log(E)

type T = Static<typeof T>
Loading

0 comments on commit a1441a9

Please sign in to comment.