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

Dot Prop Views #103

Open
Richienb opened this issue Jan 1, 2023 · 2 comments · May be fixed by #113
Open

Dot Prop Views #103

Richienb opened this issue Jan 1, 2023 · 2 comments · May be fixed by #113

Comments

@Richienb
Copy link
Contributor

Richienb commented Jan 1, 2023

Consider the following API:

import dotProp from 'dot-prop';

const object = {};
const view = dotProp(object);

view['foo.bar'] = 1;

console.log(object.foo.bar);
//=> 1

console.log(view['foo.bar']);
//=> 1

console.log('foo.bar' in view);
//=> true

delete view['foo.bar']

console.log('foo.bar' in view);
//=> false

Fully possible using Proxy

@Richienb Richienb changed the title Cleaner interface Dot Prop Views Apr 8, 2024
@Richienb Richienb linked a pull request Apr 8, 2024 that will close this issue
@sindresorhus
Copy link
Owner

Seems like a cool experiment, but I'm finding it hard to think where I would want to use this in practice though. Proxy also comes with some performance and usability (does not work with private class fields, etc) downsides.

When would you use this and for what?

@Richienb
Copy link
Contributor Author

Richienb commented Apr 9, 2024

I was thinking something like using it alongside a flat database. Will leave this open for when someone reads about it here, then encounters a need for it in the wild.

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

Successfully merging a pull request may close this issue.

2 participants