3 ms·
Within the current js syntax, you can make the code looks readable with a chain or pipe with a simple function https://github.com/beenotung/tslib/blob/master/sr
by aabbcc1241 4y ago
Within the current js syntax, you can make the code looks readable with a chain or pipe with a simple function
https://github.com/beenotung/tslib/blob/master/src/pipe.ts https://github.com/beenotung/tslib/blob/master/src/pipe.ts
You can even use an array if you don't need to peek the value in the middle of a chain of operations
Example:
createChain(
Object.entries(envars)
.map(([key, value]) => `${key}=${value}`)
.join(' ')
)
.map(keys => `$ ${keys}`)
.map(pattern => chalk.dim(%, 'node', args.join(' ')))
.use(line => console.log(line))
In each step, you can name the intermediate result accordingly to it's meaning, should be more readable than calling it %