Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:17
    CrossEye commented #2779
  • Jan 31 2019 21:04
    ArturAralin commented #2779
  • Jan 31 2019 20:08
    CrossEye commented #2779
  • Jan 31 2019 18:56
    buzzdecafe commented #2631
  • Jan 31 2019 18:09
    ArturAralin commented #2779
  • Jan 31 2019 16:18
    CrossEye commented #2779
  • Jan 31 2019 16:10
    CrossEye commented #2631
  • Jan 31 2019 16:06
    CrossEye commented #2777
  • Jan 31 2019 14:44
    ArturAralin opened #2779
  • Jan 31 2019 07:39
    inferusvv commented #2631
  • Jan 31 2019 03:07
    sespinozj commented #2771
  • Jan 31 2019 02:33
    machad0 commented #2771
  • Jan 31 2019 02:26
    JeffreyChan commented #2777
  • Jan 30 2019 14:30
    CrossEye closed #2777
  • Jan 30 2019 12:13
    vanyadymousky updated the wiki
  • Jan 30 2019 01:42
    JeffreyChan commented #2777
  • Jan 29 2019 21:06
    vanyadymousky updated the wiki
  • Jan 29 2019 16:28
    CrossEye commented #2777
  • Jan 29 2019 15:50
    mbostock commented #2772
  • Jan 29 2019 15:48
    CrossEye commented #2772
Brad Compton (he/him)
@Bradcomp
Most languages don't use prototypical inheritance
The scoping is weird and it didn't get classes till 2015-ish?
Long Dao
@longebane
but isn't prototypical inheritance still a subset of OO
Brad Compton (he/him)
@Bradcomp
Then you have stuff like calland apply
It is, but if it was inspired by Java it certainly had a ... unique take
Ian Hofmann-Hicks
@evilsoft
Yes, but not the norm @longebane. what some would call Traditional OO
Brad Compton (he/him)
@Bradcomp
You can use prototypes similar to classes, but they can also be used for some rad metaprogramming, multiple inheritance, mixins, etc.
Long Dao
@longebane
Ok, then instead of "JS is an OO language", what would be better?
that's essentially what I'm getting at
Brad Compton (he/him)
@Bradcomp
JS is a multi-paradigm language supporting OO, Functional, and Imperative programming styles, as well as allowing the user to mix and match
Long Dao
@longebane
deja vu. I feel like I've seen that before
Ian Hofmann-Hicks
@evilsoft
:+1: to that @Bradcomp
Long Dao
@longebane
looks great!
Ian Hofmann-Hicks
@evilsoft
:sheep: :it:
Long Dao
@longebane
:red_circle: :eyes:
Brad Compton (he/him)
@Bradcomp
Because of this, it can support a wide variety of applications and use cases. It also provides a number of footguns for users that await the incautious developer.
Long Dao
@longebane
footgun?
Brad Compton (he/him)
@Bradcomp
It will pretty much let you do anything and won't try to stop you
Long Dao
@longebane
traps?
Brad Compton (he/him)
@Bradcomp
Leading to a number of ways to shoot yourself in the foot
self sabotage
:stuck_out_tongue_closed_eyes:
Long Dao
@longebane
yeah. good stuff. thanks my brah's
Ian Hofmann-Hicks
@evilsoft
Anytime! Is your course going to be public?
Carl Parrish
@carl-parrish

I have an object {} my object may have several nested properties.
const myObj = {prop1: {prop2: {prop3: data: null}}}
I need to set data if it's empty

 if ( R.isNil(myObj.prop1.prop2.prop3.data))
  {
     myObj.prop1.prop2.prop3.data = myCurrentDataObj ;
 }

This works as long a prop1, prop2 & prop3 exists. But sometimes they don't so I tried

If (R.isNil(myObj.prop1)){ myObj.pro1 = {prop2: {prop3: data: {}}}; }

Do I actually have to explicitly check to see if every property has been defined before I can set data? I was hoping that something like R.lensProp and R.set could solve this for me but if so I haven't figured it out yet.

Brad Compton (he/him)
@Bradcomp
Look at R.pathSatisfies
and other similar functions
Carl Parrish
@carl-parrish
thanks
Brad Compton (he/him)
@Bradcomp
const dataPath =  ['prop1', 'prop2', 'prop3', 'data'];
when (
  pathSatisfies(isNil, dataPath),
  assocPath(dataPath, {})
)(myObj);
assocPath will create intermediate properties I am pretty sure
Carl Parrish
@carl-parrish
will try that now.
Brad Compton (he/him)
@Bradcomp
also change out the {} with myCurrentDataObj
and it won't update your input, but instead create a new object based on the old one
Carl Parrish
@carl-parrish
but only if it was nil right?
Brad Compton (he/him)
@Bradcomp
If pathSatisfies returns false (the property isn't nil) then it will just return myObj unchanged
dimatter
@dimatter
hey all. what is wrong with the following? const previous = R.defaultTo([0,0], R.nth(-1))
when calling it with an empty array I was expecting the defaults
Riku Tiira
@rikutiira
@dimatter you are checking default of a truthly value (a curried function returned R.nth(-1))
You could do R.compose(R.defaultTo([0,0]), R.nth(-1))
Ben Briggs
@ben-eb
Ooo, I hadn't used sortWith before, that's better still :)
pentatronix
@pentatronix
How would one traverse with a lensPath? I have been trying to wrap my brain around partial.lenses for a while and I get nowhere :(
What I would be after is the equivalent to x = lensPath(['a', *, 'd']); which would return all d children of any elements that are children of a.
Twizzes
@Twizzes
const obj = { a: [{ d: 1 }, { d: 2 }, { d: 3 }] };
const aChildrenD = R.pipe(R.view(R.lensProp("a")), R.map(R.view(R.lensProp("d"))));

console.log(aChildrenD(obj));
// => [1,2,3]
this only works if a can be operated on by R.map
@pentatronix
pentatronix
@pentatronix
@Twizzes , ah makes sense. So effectively you build up lenses of the sub objects, and wherever you need to you just compose with map or reduce etc.
pentatronix
@pentatronix
Thanks. I had not seen a particularly clear usage for lenses, especially in complex read only situations.
Alex McKay
@alexandermckay
I am trying to a find a function in the ramda library that does the same thing as the callback helper function I have written below. Could someone please let me know if it exists?
const callback = (fn) => (...args) => () => fn(...args)

const obj = {
  method: (x, y) => x + y
}

const exists = always(has('method', obj))
const execute = callback(prop('method', obj))('Invoke ', 'Fn')

when(exists, execute)(null)
Brad Compton (he/him)
@Bradcomp
@alexandermckay That might be what you are looking for.
However, your version looks fine too