quokka
quokka copied to clipboard
ramda pipe previous params support
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
Hello, any update on this FR @ArtemGovorov ?
@nampdn - we don't have any immediate plans to implement this feature request.
@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.
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