Skip to content
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

Refactoting of decoder for better maintainability #76

Merged
merged 40 commits into from Apr 26, 2019

Commits on Apr 22, 2019

  1. Configuration menu
    Copy the full SHA
    a0f5f62 View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2019

  1. Refactoring: inlining hasMinBufferSize and simplifying decode(buf)

    Changes to be committed:
      modified:   lib/decoder.js
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    12f63ee View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    991cc76 View commit details
    Browse the repository at this point in the history
  3. In decodeMap(...) simplify counting amount of bytes consumed

    Well, provided that initialOffset is the value passed as an argument:
    console.log(headerLength + totalBytesConsumed === offset - initialOffset)
    // true   --- always
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    287d374 View commit details
    Browse the repository at this point in the history
  4. Imporove maintainability

    1. getSize now is implemented through hash not switch statement.
       More concise and appear to be much faster.
    
    2. Created helpers.js file, and functions that logically unrelated
       to decoding/encoding will go there.
    
    3. Where possible prefer flat code that nested branches
    
    4. In decodeExt dramatically simplify all the things.
    
    Changes to be committed:
    	modified:   lib/decoder.js
    	new file:   lib/helpers.js
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    f7345f0 View commit details
    Browse the repository at this point in the history
  5. Getting rid of "offset + 1" artificial expression

    It's caused by not incrementing offset after reaading first byte.
    To handle this change I first of all introduce "initialOffset" and
    change everywhere offset to "initial offset". This commit does
    this part of the job.
    
    Then I will clean 1-by-1 every affected function and branch.
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    8a932aa View commit details
    Browse the repository at this point in the history
  6. Keep on getting intent more clear

    1. Remove "else" statements that go after "return"
    2. Where appropriate (another 1-4 bytes have been read) offset is incremented
    3. So that expressions like "initialOffset + 2" --- "... + 5" could be replaced by just "offset"
    
    Changes to be committed:
      modified:   lib/decoder.js
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    a9ec4fb View commit details
    Browse the repository at this point in the history
  7. Implemented all integers and all kinds of floats

    1. function decodeSigned (buf, offset, size)
    2. function decodeFloat (buf, offset, size)
    3. function decodeExt (buf, offset, type, size, headerSize)
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    11ef5e6 View commit details
    Browse the repository at this point in the history
  8. Added missing Ranges as TODO commends

    Currently:
    
    | RANGE      |  STATUS             | function name (if exists) or type name  |
    |------------|---------------------|-----------------|
    | 0x00, 0x7f |  MISSING COMPLETELY | positive fixint
    | 0x80, 0x8f |  MISSING COMPLETELY | fixmap
    | 0x90, 0x9f |  MISSING COMPLETELY | fixarr
    | 0xa0, 0xbf |  MISSING COMPLETELY | fixstr
    | 0xc0, 0xc3 |  DONE               | decodeConstants(...)
    | 0xc4, 0xc6 |  OLD CODE           | decodeBuffers(...)
    | 0xc7, 0xc9 |  WIP NOW            | decodeExt(...)
    | 0xca, 0xcb |  DONE               | decodeFloat
    | 0xcc, 0xcf |  DONE               | decodeUnsignedInt()
    | 0xd0, 0xd3 |  DONE               | decodeSigned()
    | 0xd4, 0xd8 |  DONE               | decodeFixExt()
    | 0xd9, 0xdb |  OLD CODE           | decodeStr(...)
    | 0xdc, 0xdd |  OLD CODE           | decodeArray(...)
    | 0xde, 0xdf |  OLD CODE           | decodeMap(...)
    | 0xe0, 0xff |  MISSING COMPLETELY | negative fixint
    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    65ce0ba View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    c5789c7 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    a511bdd View commit details
    Browse the repository at this point in the history
  11. gitignore updated

    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    db3f3e8 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    3ae90f9 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a902377 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    e3546c8 View commit details
    Browse the repository at this point in the history
  15. Update .gitignore

    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    6319853 View commit details
    Browse the repository at this point in the history
  16. decodeArray

    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    f2840b6 View commit details
    Browse the repository at this point in the history
  17. small arrays and

    thephoenixofthevoid committed Apr 23, 2019
    Configuration menu
    Copy the full SHA
    ebb90c0 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    67d253c View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    83cb8ac View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2019

  1. Configuration menu
    Copy the full SHA
    e3be779 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f70ee03 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c2c4b18 View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2019

  1. Few changes

    thephoenixofthevoid committed Apr 25, 2019
    Configuration menu
    Copy the full SHA
    6f725ac View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    76a8958 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8d5003a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    672e68c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    698c73e View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c2e3c1b View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2cbbaeb View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    4b7f55f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    c53969f View commit details
    Browse the repository at this point in the history
  10. Clean up index.js

    thephoenixofthevoid committed Apr 25, 2019
    Configuration menu
    Copy the full SHA
    c80300c View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    c02177f View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    1d96857 View commit details
    Browse the repository at this point in the history
  13. Small fixes

    thephoenixofthevoid committed Apr 25, 2019
    Configuration menu
    Copy the full SHA
    45a8340 View commit details
    Browse the repository at this point in the history
  14. Small fixes

    thephoenixofthevoid committed Apr 25, 2019
    Configuration menu
    Copy the full SHA
    b5bd1fd View commit details
    Browse the repository at this point in the history
  15. Fix travis builds

    thephoenixofthevoid committed Apr 25, 2019
    Configuration menu
    Copy the full SHA
    40d2871 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    311de36 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4a404e2 View commit details
    Browse the repository at this point in the history