Giter Club home page Giter Club logo

frontier-cool-quiz-2-nested-key-value-pair-tree-viewer's Introduction

Nested Key-Value Pair Tree Viewer

How to run this project

Install Dependencies

Run npm install to install the dependencies.

Starting Dev Server

Run npm run dev to start the dev server.

Building App

Run npm run build to build the app.

By default, the build output will be placed at dist. You can deploy this dist folder to any of your preferred platforms.

Testing App Locally

After the app is built, you can test it locally by running npm run preview.

The vite preview command will boot up a local static web server that serves the files from dist at http://localhost:4173.

Problem and Challenges

Primitive leaves

Consider this input:

  • common.feature.experience = Try It Now!
  • common.feature.chooseFabric = Choose Fabric

Now, if another common.feature is added afterward, it would replace all common.feature.* entries added before, which is bad because some kv-pair just silently disappears.

On the other hand, if a common.feature is already added, subsequent common.feature.* would walk through a node that is not an object, throwing an error, which is even worse.

My solution is to treat the tree view as a real "tree" with a value stored on each node. Each leaf is now just a node with no children instead of a primitive value, so it's no problem to walk through it and create more nested children.

This solution solves both problems and keeps the code clean and easy to implement.

Prototype Pollution

Having __proto__ in a key would cause the write to the shared Object.prototype object instead and cause undesired behaviors.

I fixed this by using an object with no prototype so you can't accidentally write it.

frontier-cool-quiz-2-nested-key-value-pair-tree-viewer's People

Contributors

zetaraku avatar

Watchers

 avatar

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.