-
Notifications
You must be signed in to change notification settings - Fork 0
Serde Package #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
karnishein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how you expect me to do this well
…ons into the correct object form
packages/serde/index.ts
Outdated
| const binaryTrueValue = 1; | ||
| const binaryModulus = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using magic numbers. move to a consts file
packages/serde/index.ts
Outdated
|
|
||
| const binaryTrueValue = 1; | ||
| const binaryModulus = 2; | ||
| // TODO add signed support! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document this somewhere else then the code
| @@ -0,0 +1,62 @@ | |||
| // בס"ד | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure you actually need this file. is there a built-in type or an NPM package you can use instead
| export const bitArrayLength = 8; | ||
| const singleShift = 1; | ||
| const shouldntInsert = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more magic numbers
| export const bitArrayLength = 8; | ||
| const singleShift = 1; | ||
| const shouldntInsert = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is for a boolean and the value is a number.
packages/serde/index.ts
Outdated
| // TODO add signed support! | ||
| export const serdeUnsignedInt = (bitCount: number): Serde<number> => ({ | ||
| serializer(serialiedData: BitArray, num: number) { | ||
| const arr = new BitArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using abbreviations. arr --> array and num --> number
| @@ -0,0 +1,264 @@ | |||
| // בס"ד | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- extract every serialize and deserialize function to it's own function.
- add a unit test for every function (Optional for this PR can be in another task)
- split every de/serialize function to it's own file by the serialization type.
- create a Factory/Builder function to get the desired Serde when used.
- add a
Readme.mdfile explaining what a Serde is (GPT is great for this)
This package is meant to compact data into a small string for small QR codes