origamitower / folktale

[not actively maintained!] A standard library for functional programming in JavaScript
https://folktale.origamitower.com/
MIT License
2.05k stars 102 forks source link

Add fromNullable method to Maybe #201

Closed HeeL closed 6 years ago

HeeL commented 6 years ago

Add Maybe.fromNullable

HeeL commented 6 years ago

@robotlolita Coverage Check doesn't seem to recognize any of the branches I've tested. Do you know what might be the issue here and how I can fix this? Did I get the idea of your property-base testing correctly?

robotlolita commented 6 years ago

Oh. Maybe already has a fromNullable defined (see https://github.com/origamitower/folktale/blob/master/packages/base/source/maybe/index.js#L38).

"static" functions go on the index.js module, and "instance" methods go on the maybe.js module. I suppose the structure and the way they're defined right now can be quite confusing :x

So, you've defined an instance method here, you'd only be able to call that with something like Maybe.of().fromNullable(value), the tests then end up calling the static function that is defined on index.js

HeeL commented 6 years ago

I see, thank you for pointing this out