Git Product home page Git Product logo

Comments (7)

wkrick avatar wkrick commented on July 19, 2024 1

@HelloLudger

Interesting. The test cases proposed in the RFC clearly indicate that encoding an empty string results in an empty string...

BASE64("") = ""

I stand corrected.

from lz-string.

HelloLudger avatar HelloLudger commented on July 19, 2024

I never understood why converting an empty string would return null instead of "".

My emotional expectation would be that "" is the return of an empty input and null is returned in the event of an error.

from lz-string.

wkrick avatar wkrick commented on July 19, 2024

@HelloLudger - I think the reason is because an empty string isn't a valid Base64 encoded string. There's no inputs into the Base64 encoding algorithm that generate an empty string so trying to decode an empty string makes no sense. So returning null from the function is a reasonable way to indicate an error due to invalid input.

from lz-string.

HelloLudger avatar HelloLudger commented on July 19, 2024

@wkrick that would be an explaination, but I found no arguments to support that "" is no valid Base64 (or the other way around).

from lz-string.

Rycochet avatar Rycochet commented on July 19, 2024

Two issues here, first is code output (and a breaking change) - an empty string is valid for an empty result, an error should be different. Second is that the typings don't match what they should be and isn't breaking (and is also not going to change if / when the code change)

For the empty string result we do need to check it's not breaking in the other implementations otherwise it can't be changed for legacy reasons (and would need to be part of any future plans etc)

from lz-string.

Rycochet avatar Rycochet commented on July 19, 2024

Just realised that the typings are correct for v2 - and had a look at some of the implementations for other languages, which have reproduced this behaviour faithfully, so it looks like a very breaking change!

from lz-string.

HelloLudger avatar HelloLudger commented on July 19, 2024

Yes... nothing that could be done without breaking. Only idea I have (and read here before in another context) would be adding mirrored functions with a new systematic of return values. (E.g. compressToBase64Preview)

from lz-string.

Related Issues (20)

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.