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

Booleans are received as strings? #384

Open
pateketrueke opened this issue Oct 13, 2017 · 0 comments
Open

Booleans are received as strings? #384

pateketrueke opened this issue Oct 13, 2017 · 0 comments

Comments

@pateketrueke
Copy link

Hi, I'm super excited about this project, fun and interesting!

Of course I was playing around to make it work, so I tried to understand this:

cb(null, (bool === 'true'));

I wrote my own hasProp plugin which receives booleans perfectly, so it could be used as {^hasProp("name", false)} without issues:

function hasProp(prop, val, cb) {
  const memory = this.user.memory;
  const userId = this.user.id;

  memory.db.get({ subject: prop, predicate: userId }, (err, res) => {
    const value = res[0] && res[0].object;

    if (typeof value !== 'undefined' && value !== null) {
      cb(null, val === true);
    } else {
      cb(null, val === false);
    }
  });
}

I don't feel this consistent, unless you encourage us to use plugins as {^hasProp("name", "false")} which is bit weird imho.

The question is, why you used a string comparison instead?

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