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

[Feature Idea] Const values #114

Open
Bnaya opened this issue Jun 20, 2020 · 0 comments
Open

[Feature Idea] Const values #114

Bnaya opened this issue Jun 20, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Bnaya
Copy link
Owner

Bnaya commented Jun 20, 2020

Support saving values as const values, means they will be nested-immutable, and contiguous memory as possible.

Another idea: lock array & object structures, but allow updates that will use same amount of memory.

The involved data structures cloud be more efficient, as they are for read only, so they will be optimize for read and not update.

Take into account: what about circularities, and saving part of the tree into mutable branch of objectbuffer.

A possible api to save values as const:

import { saveAsConst } from '@bnaya/objectbuffer';
const ob = createObjectBuffer();

saveAsConst(() => {
  ob.const = {a: 1, b: [1, 2, 3]}
});
ob.const.a === 1; // true
ob.const.a = 2; // THROW!!

Worth noting:
https://github.com/tc39/proposal-record-tuple#examples

@Bnaya Bnaya changed the title [Feature IDe] [Feature Idea] Const values Jun 20, 2020
@Bnaya Bnaya added enhancement New feature or request help wanted Extra attention is needed labels Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant