Proposal: `maxDepth` on objects

Isiah Meadows isiahmeadows at gmail.com
Sun Oct 21 14:30:26 UTC 2018


Are there other use cases for this? This reason doesn't really seem
compelling.

(Not TC39, but I wouldn't expect this to be considered without a way
stronger use case.)
On Sun, Oct 21, 2018 at 09:45 Oliver Dunk <oliver at oliverdunk.com> wrote:

> I’d love to see some sort of `maxDepth` property on objects.
>
> For `{}`, it would return `0`.
> In the case of `{keyOne: true}`, it would return `1`.
> For `{keyOne: {anotherKey: false}, keyTwo: false}`, it would return `2`.
>
> My particular use case is validating a JSON payload sent by a user to
> prevent abuse. I don’t want to force a particular structure or set of keys,
> but I do want to make sure the level of nesting doesn’t get silly.
>
> The code to implement this is fairly short, but looks a bit messy. It’d be
> really nice to have a property instead.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20181021/69a5f535/attachment.html>


More information about the es-discuss mailing list