Discussion
Loading...

Discussion

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Jordan Sissel
@whack@hachyderm.io  ·  activity timestamp 3 weeks ago

Weirdness going on in nodejs's fs.lstat() gives an "fs.Stats" object, but saying "blah instanceof fs.Stats" evaluates to false.

fs.Stats is a function, not a class or whatever... the real object returned is actually a "fs.StatsBase" which is hidden somewhere inaccessible. Only way I've found to do it is by finding a known fs.lstat() response, getting that object's prototype, then asking if the the object uses that prototype... THere's some wild history here and I wanna know how it got this way.

  • Copy link
  • Flag this post
  • Block
Jordan Sissel
@whack@hachyderm.io replied  ·  activity timestamp 3 weeks ago

And even if isPrototypeOf is the only way to do it, typescript doesn't know how to use this for type narrowing anyway. Fun!

https://www.typescriptlang.org/play/?#code/MYGwhgzhAEBiD29oG8BQqC+7jwHYQBdoAPaAXmlwFMB3ORACgEoBuVHfIheABQCd4BJBQDyAIwBWVYAQB0AcyoF+gwQE8ADlREAzBsSbodAV1wyAlnmjAAFtIDWDAF4AuekgA+lYwFsxVPiYUVGhocx1oBgJNKngIp3IKACJcX38+JKC0UNCOCHgQKlkQeHkGJOitOO8-AMyQnIB6RuhKqghgPnMNIntceBoYBPMYMBr0sNxWmxHoMRLgewbQpxZoZugbeAA3AOgfeGMIKmgdvaFoCC26GhswIjaOrp7oPoGYBqxQ8MjhzjAzLEItwsstrHh8oViqVyuZ-oC4vUcusWo9Ot1ev1BtAAOROHFhUbuSbTWbzeCLMGrT4NH4MbgqISyEaM9RaXTOJig5F5ApFEplJIMgRCTJsZEbNHPIgAE3g7VwOMxA02KouuDAfAEdAIMwgsjBG3yYSIhHMIBApNw9iGhOgY1MlimbVx3GgXlStT4OKpaw2W12fH2h2Op0DrSQVxVt3urRiTwxryxH1CWCwqGatgcDAArIZ2HZFgxqHRuMwmEA

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login