wallabyjs / quokka

Repository for Quokka.js questions and issues
https://quokkajs.com
1.17k stars 31 forks source link

ramda pipe previous params support #229

Open nampdn opened 6 years ago

nampdn commented 6 years ago

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 commented 4 years ago

Hello, any update on this FR @ArtemGovorov ?

smcenlly commented 4 years ago

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

josuamanuel commented 3 years ago

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

mcky commented 1 year ago

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