quokka icon indicating copy to clipboard operation
quokka copied to clipboard

ramda pipe previous params support

Open nampdn opened this issue 6 years ago • 4 comments

Issue description or question

Ramda is a functional programming library which will pass the arguments at the final function. It would be great if we could get access to the previous arguments get passed to the next function in the pipe. Currently, I have to recall all of the previous function to get the output at the logging function.

Sample code

Current:

import * as R from 'ramda'
import {paramCase, pascalCase, lowerCase} from 'change-case'

const getType = name =>
  R.pipe(
    paramCase /* ? $(name) */, // =>  ios-background
    R.split('-') /* ? $(paramCase(name)) */, // =>  [ 'ios', 'background' ]
    R.takeLast(1) /* ? $(R.split('-',paramCase(name))) */, // =>  [ 'background' ]
    pascalCase /* ? $(R.takeLast(1, R.split('-',paramCase(name)))) */, // => Background
  )(name)

console.log(getType('iOSBackground')); // => Background

Feature request: Supose $$ is the returned value from the previous function, we could use like this:

import * as R from 'ramda'
import {paramCase, pascalCase, lowerCase} from 'change-case'

const getType = name =>
  R.pipe(
    paramCase /* ? $(name) */, // =>  ios-background
    R.split('-') /* ? $($$) */, // =>  [ 'ios', 'background' ]
    R.takeLast(1) /* ? $($$) */, // =>  [ 'background' ]
    pascalCase /* ? $($$) */, // => Background
  )(name)

console.log(getType('iOSBackground')); // => Background

Code editor version

Visual Studio Code v1.25.1

OS name and version

OSX

nampdn avatar Jul 27 '18 05:07 nampdn

Hello, any update on this FR @ArtemGovorov ?

nampdn avatar Jan 16 '20 07:01 nampdn

@nampdn - we don't have any immediate plans to implement this feature request.

smcenlly avatar Jan 16 '20 23:01 smcenlly

@ArtemGovorov It looks a nice feature that could be valuable to revisit:

  • Getting Functional Programming more and more popular
  • Being functional too verbose and it would be a great complement to show the intent of the code with live comments.

josuamanuel avatar Dec 23 '20 01:12 josuamanuel

I appreciate it's not as nice as being able to leave a comment there that won't be executed at runtime, but you can debug pipes fairly easily using R.tap

Code - 2022-10-03 at 12 19 17

mcky avatar Oct 03 '22 11:10 mcky