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

empty Uint8Array fails to encode #13

Closed
wanderer opened this issue Apr 24, 2017 · 2 comments
Closed

empty Uint8Array fails to encode #13

wanderer opened this issue Apr 24, 2017 · 2 comments
Assignees

Comments

@wanderer
Copy link

empty Uint8Array fails to encode

@wanderer
Copy link
Author

actully all Uint8Array fail :(

const cbor = require('./')

const array = new Uint8Array([0, 0])
let encoded = cbor.encode(array) // returns <Buffer f5>
const obj = cbor.decodeFirst(encoded)
console.log(obj)

results in

/home/null/code/borc/src/encoder.js:458
          result[i].copy(res, index)
                    ^

TypeError: result[i].copy is not a function
    at Encoder.finalize (/home/null/code/borc/src/encoder.js:458:21)
    at Object.encode (/home/null/code/borc/src/encoder.js:505:16)
    at Object.<anonymous> (/home/null/code/borc/test.js:5:20)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:422:7)

@dignifiedquire
Copy link
Owner

That's probably because they are so similar to Buffer but not quite the same thing..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants