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

Broken metadata access for non-root $meta #120

Open
kisaiev opened this issue Oct 30, 2024 · 0 comments
Open

Broken metadata access for non-root $meta #120

kisaiev opened this issue Oct 30, 2024 · 0 comments

Comments

@kisaiev
Copy link

kisaiev commented Oct 30, 2024

Problem

Metadata for primitive values (non-objects) cannot be requested by the key (e.g. Store.meta('/b').

Version

  • Package version: v6.0.2 (latest)
  • Node.js version: v20.16.0 (LTS)
❯ node -v
v20.16.0
❯ npm i @hapipal/confidence@latest
❯ npm list @hapipal/confidence
...
└── @hapipal/[email protected]

Steps to reproduce

import { Store } from '@hapipal/confidence';

const store = new Store({
    a: 'a',
    b: {
        $value: 'b',
        $meta: 'b_meta',
    },
    c: {
        inside_c: 'inside_c',
        $meta: 'inside_c_meta',
    },
    $meta: {
        root: 'root_meta',
    },
});

Actual behaviour

// Data is returned as expected
store.get('/'); // { a: 'a', b: 'b', c: { inside_c: 'inside_c' } }

// Root metadata returned as expected
store.meta('/'); // { root: 'root_meta' }

// Metadata for primitive value is unreachable
store.meta('/b'); // undefined

// Metadata for object is returned as expected
console.log(store.meta('/c')); // inside_c_meta

Expected behaviour

store.meta('/b'); // 'b'
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

No branches or pull requests

1 participant