These are chat archives for ramda/ramda

25th
Jan 2019
Julien BONNIN
@Powerplex
Jan 25 15:42
Hello :) Is it normal that hasPath has a weird behaviour on the window object ? https://tinyurl.com/ybf6ysv5
Or should I create an issue ?
Julien BONNIN
@Powerplex
Jan 25 15:59

apparently the _has (internal) does :
function _has(prop, obj) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
why not simply do :
function _has(prop, obj) {
return obj[prop] != null;
}

?

Brad Compton (he/him)
@Bradcomp
Jan 25 16:00
Because hasPath(['a'], {a: null}) should return true
Julien BONNIN
@Powerplex
Jan 25 16:00
My code fails because document has no prototype
Alex Deas
@alex-deas_gitlab
Jan 25 16:00
It checks ownProperties
Julien BONNIN
@Powerplex
Jan 25 16:00
Oh yes my bad.
So it simply cannot be used on document ?
Alex Deas
@alex-deas_gitlab
Jan 25 16:01
Object.getOwnPropertyNames(document).filter(x => x === "createElement")
> []
Brad Compton (he/him)
@Bradcomp
Jan 25 16:02
Maybe try pathSatisfies?
pathSatisfies(complement(isNil), ['document', 'createElement'], window) // => true
Simon
@Splace42
Jan 25 16:04
@Bradcomp path is good too ! :)
Brad Compton (he/him)
@Bradcomp
Jan 25 16:07
Better than complement(isNil) in this case would is(Function)
Simon
@Splace42
Jan 25 16:07
I wonder why there is no "prototype" on document object
Julien BONNIN
@Powerplex
Jan 25 16:11
Thank you for you answers :) It makes a bit more sense
I went with pipe(path(['document', 'createElement']), is(Function))(window)
Brad Compton (he/him)
@Bradcomp
Jan 25 16:14
Nice!
Tristan Forward
@tforward
Jan 25 20:40

Anyone see this article making the rounds, about "High-performance array transformations?"
https://codeburst.io/high-performance-array-transformations-68aae138a5f2

The Ramda solution he gives is "280x slower than the naive version, completely unusable."
I don't know enough about transduce to comment but I get the feeling he is doing it wrong.
Search "Haven’t your heard of transducers?" and will take you to the section in question, curious about Ramda's community's thoughts on this one

Brad Compton (he/him)
@Bradcomp
Jan 25 20:44

Creating intermediate data structures, especially large ones, is almost always going to result in severe punishment.

This is the takeaway from the article. At the bottom of the transducer section he fixes it using push instead of append. Immutability comes with a cost in performance without special data structures. It's typically up to the developer to determine if that cost is worth the safety it provides.

Transducers tackle the multiple passes issue (important for both perf and for lazy / infinite structures) but Ramda will never mutate your input. As a result, it can often create a lot of garbage when working with large structures, as well as create way more allocations than necessary.
Tristan Forward
@tforward
Jan 25 20:53
Thank you! Right tool for right job kinda thing