How do you do that thin you (sinclair) do? #833
-
Hello Sinclair! Long time to talk! Hope you are doing well! I am back with a few questions for you.
Thanks so much! PS: don't forget to sleep! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@jessekrubin Heya, sorry for the delay in reply.
I mostly just author them manually. README's usually get updated on minor revisions where I try to provide high level code examples demonstrating new features while maintaining copy written for older features to ensure consistency. I spend quite a bit of time going through each section of the README ensuring what's written is consistent across each section and as concisely written as possible (I assume most readers prefer code examples with small supplementary copy explaining the code) I don't think I do anything particularly special with the READMEs I manage. I mostly just write what I'd like to see documentation wise :)
Unfortunately, I don't keep a blog (mostly because I don't have much time to write blog content). To be honest I wouldn't know what to write even if I did have one!
TypeBox uses symbols for a variety of reasons (which is quite a lengthy discussion). But are generally used in TypeBox for the following reasons:
In terms of scenarios where you might use Symbols, mostly they are used to ensure value uniqueness and that a value can be distinctly differentiable from another value. There's quite a few places where this is useful, but in terms of common usage, you may see Symbols assigned to objects where the Symbol describes some attribute or behavior of an object that is leveraged by auxiliary infrastructure, and where the infrastructure is dependent on that attribute being uniquely distinguishable. This is a bit of an abstract description, but the following shows the concept in practice. const T = Type.String() // { [Kind]: 'String' } // unique intrinsic symbol
Value.Check(T, ...) // symbol read via dependent infrastructure... class Iter {
* [Symbol.iterator]() { // unique intrinsic symbol
yield 1
yield 2
yield 3
}
}
for(const value of new Iter()) { // symbol invoked via dependent infrastructure...
console.log(value)
}
Hopefully one day :)
Uncertain. Currently the TypeCompiler only produces a very fast import { Type, TSchema, StaticDecode } from '@sinclair/typebox'
// TODO: Figure out a way to compile the following routines
function Parse<T extends TSchema, R = StaticDecode<T>>(schema: T, value: unknown): R {
const converted = Value.Convert(schema, value)
const cleaned = Value.Clean(schema, converted)
const defaulted = Value.Default(schema, cleaned)
return Value.Decode(schema, defaulted)
}
I feel serialization (encode and decode) is a domain unto itself and probably best handled by other libraries.
Yes, eventually :) (stay tuned) Hope this brings some insights! |
Beta Was this translation helpful? Give feedback.
@jessekrubin Heya, sorry for the delay in reply.
I mostly just author them manually. README's usually get updated on minor revisions where I try to provide high level code examples demonstrating new features while maintaining copy written for older features to ensure consistency. I spend quite a bit of time going through each section of the README ensuring what's written is consistent across each section and as concisely writte…