Coder Social home page Coder Social logo

Comments (7)

vweevers avatar vweevers commented on May 28, 2024

You wouldn't be able to use the full range of bytes, as two must be reserved for separator and lt logic. Limiting the prefix to ASCII characters makes that easier to enforce.

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 28, 2024

The prefix separator is by default ! right? It's still possible to conflict with ! just by giving a prefix like abc!dsfgd. So why not allow raw buffers as prefixes, since you can always check if the prefix separator bytes is within the raw buffer bytes? One can use the buf.includes method to do this.

A more robust solution may use escaping applied to the prefix to always escape any occurrences of the prefix separator...

Not sure what you mean by lt logic.

from subleveldown.

vweevers avatar vweevers commented on May 28, 2024

Sure, it's possible, at the cost of complexity. Can you explain your use case? I'm curious about the benefit of buffer prefixes, if you can't use the full range of bytes.

It's still possible to conflict with ! just by giving a prefix like abc!dsfgd

Not important for the discussion but FYI: subleveldown will throw a RangeError if you do that.

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 28, 2024

I'm using subleveldown to store dynamic sub-levels. Depending on the usecase, I would prefer to use the name of the sublevel to be a raw buffer instead because sometimes I'm using the names as indexes. And the value I'm indexing on is itself a buffer. Right now it just involves converting to a string which seems unnecessary. However I guess a robust solution would require prefix-separator escaping.

from subleveldown.

vweevers avatar vweevers commented on May 28, 2024

Wouldn't escaping hurt the ability to use it as an index?

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 28, 2024

Only for the sublevel prefix/names. We're not affecting the keys. Not sure what you mean by hurting its ability to use it as an index.

from subleveldown.

vweevers avatar vweevers commented on May 28, 2024

Can you share some code to clarify the use case?

from subleveldown.

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.