question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use ES6 Proxy to throw on non-existing assertions

See original GitHub issue

With ES6 proxies it should be possible to have the following:

expect(someVariable).to.exiist;

throw which would remove one of the reasons why assertions on property access are problematic.

This will still need to work in browsers not supporting ES6 proxies (now: all browsers but this will soon change).

Refs #56.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
aaronjensencommented, Mar 31, 2016

The obvious solution would be to introduce a breaking change and require all assertions to be actual function calls

This is the obvious and right solution imo. It’d be a breaking change, sure, but it’d be worth it.

0reactions
meebercommented, Jun 27, 2016

Added in #721

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 ways to use ES6 proxies to enhance your objects
In this article, we will cover three things you can do with proxies that will enhance your objects.
Read more >
How to throw error when accessing non existent property of ...
ES2015+ offers proxies, and if you wrap the object in a proxy, you can then have the proxy throw an error when you...
Read more >
Creating defensive objects with ES6 proxies
This proxy uses a new object as its target (the first argument to ... The goal is to throw an error whenever a...
Read more >
Metaprogramming with Proxies • Deep JavaScript - Exploring JS
Let's use JavaScript as both metaprogramming language and base programming language. ... assert.equal(proxy.city, 'Paris'); revoke(); assert.throws( ...
Read more >
Proxies and Reflection | es6
A proxy, created using new Proxy() , is an object that you use in place of ... of JavaScript is that reading nonexistent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found