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

i think the other implementation is a bit more clear/concise though

:+1:

Kevin Thompson
@kthompson
Oh, I just found this...
const toMap3 = R.indexBy(R.prop('id'));
mitcho
@mitchoSR_twitter
gotta love that progression haha
Gezim Hoxha
@HappyGezim_twitter
Why does the object in filter (second param) have to have an index type of 'string'?
Lewis
@6ewis
hi
do you have a cleaner alternative
Lewis
@6ewis
const showColumns= (visibleColumns)  =>
  headers.reduce((acc, header) => {
    const indexOfVisibleColumn = visibleColumns.map(col => col.name).indexOf(header.name);
    if ( indexOfVisibleColumn !== -1) {
      const { title } = visibleColumns[indexOfVisibleColumn]
      title  ?
        acc.push({ ...header, title }) :
        acc.push({ ...header })
    }; 

    console.log("how does acc look like", acc);
    return acc;
  }, []); 
;
Twizzes
@Twizzes
@6ewis
const visibleNames = R.map(R.prop('name'))

headers.filter(header => R.includes(R.prop('name')(header), visibleNames(visibleColumns)))
Julien Gonzalez
@customcommander
Is it right/appropriate to have this ramda-adjunct package “advertised" so many times in the Ramda Cookbook? I was tempted to raise a PR to remove this but wanted to check first. Personally I don’t think it is; it causes confusion more than anything.
Julien Gonzalez
@customcommander

I mean isn’t a link in “Related projects” enough?
https://github.com/ramda/ramda/wiki#related-projects

If other projects were doing the same thing, the Cookbook could become a messy place IMHO.

Oscar Bolmsten
@oscar-b
Any @types maintainer here? Either I'm daft or there's missing type for takeLastWhile when used with a string.
Daniel Cheung
@danvim
I just added "rambda": "^4.4.0" to my project. From the docs, I see that it supposedly has the invert and invertObj functions. However, I can't find them in the dist. When I open up src under the node_module, I do see invert and invertObj in their respective files though.
Anyone knows what has happened to them?
Syaiful Bahri
@syaiful6
@danvim i guess it's typo problem, it's ramda not rambda
John Hartnup
@ukslim
rambda is a "faster alternative to Ramda" -- but I don't see anything about invert in its docs: https://selfrefactor.github.io/rambda/#/
I do see invert in Rambda docs's list of "Ramda methods missing in Rambda" - https://github.com/selfrefactor/rambda/blob/master/files/ramdaMissing.md
John Hartnup
@ukslim
Interesting - Rambda's authors say they see the fewer methods as an advantage, and it looks as if they feel the methods they've chosen to omit are ones you're likely not to need. But I see tons of functions that my team uses a lot. converge, applySpec, cond, unless, when ...
Daniel Cheung
@danvim
Thanks, that's interesting. It's my first time using ramda. I used to use lodash. Thought it made sense if the name would contain a 'b', but it didn't.
John Hartnup
@ukslim
Since I've broken my Gitter silence: a plug for the library I recently published - https://www.npmjs.com/package/ramda-decimal#ramda-decimal
Feedback very welcome.
kapilpipaliya
@kapilpipaliya
thanks for ramda
Lewis
@6ewis
R.isNil(a) || R.isNil(b)
Oskar Grunning
@sQVe
What would be the best way to write a signature for a object {k: v} but with a specfic design? It has the name Container in my TypeScript code but I'm a bit unsure how I should write the Hindley Milner signature.
combineContainers :: {k: v} -> {k: v} -> {k: v} seems a bit too generic - or am I wrong?
Brad Compton (he/him)
@Bradcomp
@6ewis any(isNil, [a, b])?
@sQVe is Container like a specific record type, or is it more like a typeclass?
Norbert
@norbertpy
Folks, what stops the 0.27.0 version to be published?
John Hartnup
@ukslim
@6ewis Why do you feel 'shortest' is a useful aim? And why mix Ramda and non-Ramda styles? or(isNil(a), isNil(b))
Mike Lambert
@lambert-velir
hey guys! I had a problem the other day, I needed to include all elements that had the field excluded set to true, but also all the elements that are before for after one that has excluded true
here's some sample data:
[
  {
    id: 1
  },
  {
    id: 2
  },
  {
    id: 3,
    excluded: true
  },
  {
    id: 4,
    excluded: true
  },
  {
    id: 5
  },
  {
    id: 6
  }
];
so the results should be 2, 3, 4, 5
I ended up using a regular [].reduce because I had an index, and could look at i -1 and i + 1
I was thinking about using R.aperture, but it doesn't quite do what I need
essentially, I need a filter that can look at the elements next to it
here's my solution:
array.reduce((acc, d, i) => {
  const excluded = d => d && d.exclude === true;

  if (excluded(d) || excluded(array[i - 1]) || excluded(array[i + 1])) {
    return acc.concat(d);
  }
  else {
    return acc;
  }
}, [])
John Hartnup
@ukslim
I'd be thinking about doing something slightly dirty with addIndex() and peeking into the original array.
Mike Lambert
@lambert-velir
yeah, similar to what I did above
Lewis
@6ewis

// given an arr of data objects, returns the field with the lowest minimum value
// i.e. which field has the lowest point on the graph: ['accumulatedDeposit', 'balance']?
export const getLowerMinimumOfFields = (data, fields) => {
  let lowest = { value: Infinity, type: '' };
  data.forEach((dateData) => {
    fields.forEach((field) => {
      if (dateData[field] < lowest.value) {
        lowest.value = dateData[field];
        lowest.type = field;
      }
    });
  });
  return lowest.type;
};
let's see the best ramda kungfu
@Bradcomp thank you
@ukslim it's not a aim - it's a bonus when it makes it more readble
// check if the lowest point is accumulatedDeposit or balance and use the lowest
  • field = field || getLowerMinimumOfFields(data, ['balance', 'accumulatedDeposit']);
John Hartnup
@ukslim
@6ewis Aha, OK. Shortness and readability often compete.
John Hartnup
@ukslim
@6ewis :
const data = [{ a: 1, b: 2, type: 'foo'}, {a: 2, b: 3, type: 'bar'}]
const fields = ['a', 'b'];
const lowestProp = pipe(props(fields), apply(min))
const lowestObj = reduce(minBy(lowestProp), { a: Infinity, type: 'init'});
const lowestObjType = pipe(lowestObj, prop('type'));

lowestObjType(data); // 'foo'
John Hartnup
@ukslim
Oops, lowestProp there only works for 2 properties.
Better: const lowestProp = pipe(props(fields), reduce(min, Infinity))
And actually you can do
const lowestObj = reduce(minBy(lowestProp), {});
John Hartnup
@ukslim
... if you don't mind lowestObjType([]) returning undefined, because min(0, undefined) is 0
John Hartnup
@ukslim
const data = [{ a: 1, b: 2, type: 'foo'}, {a: 2, b: 3, type: 'bar'}, {a: 2, b: 3, c: 0, type: 'baz'}]
const myFields = ['a', 'b', 'c'];
const lowestProp = fields => pipe(props(fields), reduce(min, Infinity))
const lowestObj = fields => reduce(minBy(lowestProp(fields)), {});
const lowestObjType = fields => pipe(lowestObj(fields), prop('type'));

lowestObjType(myFields)(data); // 'baz'

// or if it matters to you...
const lowestObjType2 = uncurryN(2, lowestObjType);
lowestObjType2(myFields, data); // 'baz'
Steven Duncan
@skuzbot
Could someone settle an ongoing discussion we've got going on in my office? How does one pronounce Ramda?