by

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
Ben Briggs
@ben-eb
@algoshipda 4 -> 3 with R.o(R.zipObj(['x', 'y', 'z']), R.props(['a', 'b', 'c']))
Oscar Bolmsten
@oscar-b
Is there a "preferred" style for pipe/compose when auto formatting? Any maintainer who would care to chime in? prettier/prettier#6921
Twizzes
@Twizzes
sorry if sanctuary is verbotten
Charles Hughes
@chughes87
anyone know a nice way to update all the keys in a given object? I need to prefix them all with a static string.. Object.entries and then R.zip comes to mind but I wish there was a cleaner way...
Brad Compton (he/him)
@Bradcomp
Something like this?
Charles Hughes
@chughes87
oh hell yall are already talking about this sorry for not reading :laughing:
Brad Compton (he/him)
@Bradcomp
Oh no prob! The wiki isn't well publicized
I try to bring it up whenever I can :smile:
Charles Hughes
@chughes87
@Twizzes do you strongly prefer Sanctuary to Ramda? I'm curious about it
Also I just wanna do a shout out. I've been using Ramda for a few months now and it is just glorious. Thanks to the developers/maintainers so much :pray:
Twizzes
@Twizzes
@chughes87 the sanctuary docs do a much better job at explaining the differences than I ever could:
For a direct function to function comparison, see: https://github.com/sanctuary-js/sanctuary/wiki/Ramda-to-Sanctuary
As you can see, sanctuary is more focused, and embraces further some of the concepts of functional programming, whereas ramda has a lot more utility functions and relaxes some of the constraints traditional FP enforces, making ramda somewhat more user friendly to folks from imperitive backgrounds
Twizzes
@Twizzes
Ramda is an easier sell to established teams using OOP, sanctuary is more for getting as close to FP in JavaScript as possible and a great way to learn FP for js devs
Patrick Laplante
@patbonecrusher
Hello all, really dumb question. How would you handle something like a socket in a composition chain. For instance, how would I do something like this but using functional composition.
Url = “localhost:8080”
connection = open_connection(url)
result = Send_data(connection, data)
raw_response = Get_response(connection)
response = parse(response)
Gerald
@jk121960
While I am not sure but it seems that get response should be receiving the result, if not you can curry it in but it could look like the following
        const sendData = R.curry(send_data)(R.__,data)
        const result = R.pipe(
            open_connection
            , sendData
            , get_response
            ,parse
        )(url);
sorry I missed some of the cases, get_response refers to Get_response and send_data refers to Send_data
Gerald
@jk121960
if you wish to actually use compose, change pipe to compose and reverse the argument function order
Charles Hughes
@chughes87
I'm curious how people here generally approach debugging their Ramda code? I've found the easiest/most fluid way to be putting a breakpoint at the top of a pipe call and playing around with the code in the debug console in vscode. I've wondered if I should try Emacs since it seems to support more repl based development that I'm trying to replicate here...
I've been wondering how feasible it might be to write a little VSCode extension that would put the outputs of each line inline in faded text when you're on a breakpoint. It seems to me like it would be pretty difficult
Kurt Milam
@kurtmilam

@chughes87 I sometimes use something like this:

const log = x => (console.log(x), x)

const pipeLog = (...fns) =>
  pipe(log, ...intersperse(log, fns), log)

pipeLog(inc, inc, inc)(0) // logs 0, 1, 2, 3

// also

pipe(dec, dec, log, dec)(100) // logs 98

REPL: https://bit.ly/2QKz2P1

Matt McKellar-Spence
@MattMS
tap(console.log) is pretty easy for quick debugging.
var b = pipe(add(1), tap(console.log), add(1));
b(1); // = 3 (and prints 2)
Charles Hughes
@chughes87
Ooo the pipeLog implementation there is pretty cool thanks!
Dimitri Mitropoulos
@dimitropoulos
I have a version of this I use too
const DEBUG_MODE = true;
let debugTimestamps: { [label: string]: number }[] = [];
const debugPipe = (label: string) => <T>(input: T) => {
  if (DEBUG_MODE) {
    debugTimestamps = [
      ...debugTimestamps,
      {
        [label]: performance.now(),
      },
    ];
    console.log({ [label]: input });
  }
  return input;
}
it's basically the same thing, but allows for some recording of timestamps, and then I have a startDebug or endDebug that basically just grabs the debugTimestamps and prints the performance numbers
Hyunseok Oh
@algoshipda
how can i make this function in ramda way?
const fn = x => id => R.prop(id, x);
Ian Hofmann-Hicks
@evilsoft
Try R.flip(R.prop), that should flip the arguments to R.prop
The C combinator I believe it is called
Ian Hofmann-Hicks
@evilsoft
const fn =
  R.flip(R.prop)
flip is very useful when you have to use other libs/apis that are not set up for easy composition with the data last format (or in cases where your data is the key name). But very handy tool in your belt, none the less
Hyunseok Oh
@algoshipda
@evilsoft wow thanks
Charles Hughes
@chughes87
@algoshipda you could also use _ which i think is more readable: https://ramdajs.com/docs/#__
so const fn = R.prop(R._, x) I believe?
Ian Hofmann-Hicks
@evilsoft
Personally I find the placholders a little less readable than using combinators like flip which provide descriptive names for how the combinator acts on the functions. But I think it is really just a taste thing.
Charles Hughes
@chughes87
Yeah I could go either way in this case. I think for functions that take 3+ arguments though there is little choice
Ian Hofmann-Hicks
@evilsoft
also would that x need to be provided, like const fn = x => R.prop(R._, x). and that would loose the nice auto curry that flip would of provided. so you would probably wanna wrap that in an R.curry
Charles Hughes
@chughes87
yah good point
wangzengdi
@adispring
what's other purpose of internal api _arity, except for limiting arguments'length to less than or equals to 10
for being easy to curry the function returned by other functions ?such as compose and pipe
Long Dao
@longebane
Awww yeah
Ian Hofmann-Hicks
@evilsoft
:wave: @longebane how the heck are ya
kapilpipaliya
@kapilpipaliya
onDestroy(() => { service.send('DESTROY'); });
how can i write this in ramda?