Giter VIP home page Giter VIP logo

Comments (6)

spc476 avatar spc476 commented on August 28, 2024

I found the bug, but I'm not sure how I want to handle it. The intended code was supposed to throw an error, but thinking about it now, I'm not sure if I want to do that as it is a valid condition. I currently throw errors on bad input, which I'm also thinking was a bad idea (throwing on encoding is fine as that's a programming error, but upon decoding? That's not the programmer's fault but the sender's---at least, that's my thinking).

from cbor.

spc476 avatar spc476 commented on August 28, 2024

It now throws an error on no input, which was the original intent.

from cbor.

daurnimator avatar daurnimator commented on August 28, 2024

Is there something I can encode to get "nothing"?

from cbor.

spc476 avatar spc476 commented on August 28, 2024

That's an interesting question---by "nothing" to you mean a 0-byte blob of data? Or some CBOR value that represents "nothing"? I never thought about the former (what would that even mean?) and the later can be accomplished by calling cbor.SIMPLE.null(), which returns a CBOR null value or by calling cbor.SIMPLE.undefined(), which returns a CBOR undefined value. I'm not sure what would be better.

from cbor.

daurnimator avatar daurnimator commented on August 28, 2024

by "nothing" to you mean a 0-byte blob of data

That's what I originally attempted. But I now see that that is probably incorrect

Or some CBOR value that represents "nothing"? I never thought about the former (what would that even mean?) and the later can be accomplished by calling cbor.SIMPLE.null(), which returns a CBOR null value or by calling cbor.SIMPLE.undefined(), which returns a CBOR undefined value. I'm not sure what would be better.

I guess I was looking for cbor.encode(nil)

from cbor.

spc476 avatar spc476 commented on August 28, 2024

But that works. cbor.encode() and cbor.encode(nil) both return a string of one character, "\246" which is a CBOR null value.

from cbor.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.