risposta di @gcanti su italiajs.slack.com in #fp
ambedue servono per risolvere un problema di composizione di funzioni, ma in due situazioni diverse. Partiamo dal caso più semplice, diciamo che hai due funzioni:
f: (a: A) => B
g: (b: B) => C
import { parse } from "jsr:@std/yaml@1"; | |
import { walk } from "jsr:@std/fs@1/walk"; | |
interface Frontmatter { | |
date?: string; | |
[key: string]: unknown; | |
} | |
const folderPath = Deno.args[0]; |
Questa non è farina del mio sacco, io ho solo copia incollato la discussione. Kudos to Giulio Canti
@vncz ho un consiglio su come procedere a strutturare un programma funzionale, con me ha funzionato bene, vediamo se funziona anche per te
In linea teorica e generale procedo così
#!/usr/bin/env /usr/local/bin/node | |
const { execSync } = require('child_process'); | |
const basedir = | |
'/Users/simonepicciani/Dropbox (Personal)/IFTTT/reddit/wallpapers/'; | |
const command = | |
"sqlite3 '/Users/simonepicciani/Library/Application Support/Dock/desktoppicture.db' 'select value from data;'"; | |
const res = execSync(command) | |
.toString('utf8') |
}, { | |
// if the file ends with .inline.svg read the content from file | |
// useful if you want to inline the image and style it via css | |
test: /\.inline.svg$/, | |
loader: 'raw-loader', | |
}, { | |
// if the file ends only with .svg load as an image | |
// to use it like this <img scr={...} /> | |
test: /(s)((?!inline).)*svg$/, | |
loader: 'file-loader', |
/** | |
* Created by simone.picciani on 21/12/2016. | |
*/ | |
object ScalaAPI { | |
def main(args: Array[String]): Unit = { | |
val initTime = System.currentTimeMillis | |
// val phrase = "send more money" |
//Uses Highcharts and Rambda | |
// live example for conversion => http://goo.gl/I2OdwZ | |
// jsbin of result | |
var pieData = [ | |
{ y: 1.242, name: 'EM' }, { y: 29.017, name: 'EM' }, { y: 2.874, name: 'EM' }, { y: 0.474, name: 'EM' }, { y: 33.363, name: 'EM' }, { y: 33.03, name: 'EM' }, | |
{ y: 2.67, name: 'NA' }, { y: 28.551, name: 'NA' }, { y: 2.195, name: 'NA' }, { y: 0.524, name: 'NA' }, { y: 34.131, name: 'NA' }, { y: 31.929, name: 'NA' }, | |
{ y: 0.138, name: 'FE' }, { y: 28.115, name: 'FE' }, { y: 1.576, name: 'FE' }, { y: 0.829, name: 'FE' }, { y: 34.923, name: 'FE' }, { y: 34.419, name: 'FE' }, | |
{ y: 0.547, name: 'GC' }, { y: 25.642, name: 'GC' }, { y: 2.503, name: 'GC' }, { y: 0.398, name: 'GC' }, { y: 35.753, name: 'GC' }, { y: 35.157, name: 'GC' } | |
]; |
//uses Ramdajs | |
function f( object ) { | |
function opt( val ) { | |
return String(val) || 'None'; | |
} | |
return R.replace( /\s+|\.+|\,+/g, '' , R.join('', R.map( opt, R.values( object ) ) ) ) | |
} | |
var o = {a:"This prop has spaces",n:12.3, r:null, z:0, data:[1,2,3]} |
/** | |
* isFunction - Function that check if a something is a function, yo dawg | |
* | |
* @param {...*} functionToCheck function to check without the parens () | |
* @return {boolean} | |
*/ | |
function isFunction( functionToCheck ) { | |
var getType = {}; | |
return functionToCheck && getType.toString.call( functionToCheck ) === '[object Function]'; | |
} |