high
- Remove jsbn
- Remove invoke third argument
- Simplify tl usage
medium
function upperExpr (template, ...expressions) { | |
return template.reduce((accumulator, part, i) => { | |
return accumulator + expressions[i - 1].toUpperCase() + part | |
}) | |
} | |
var name = 'nico' | |
var outfit = 'leather jacket' | |
var text = upperExpr`hello ${name}, you look lovely today in that ${outfit}` | |
console.log(text) |
import { tap } from 'ramda' | |
const tapLog = (...tags) => tap( | |
(...values) => console.log(...tags,...values)) | |
//USAGE | |
import { pipe } from 'ramda' | |
const debuggedSteps = pipe( |
{ | |
"parser": "babel-eslint", | |
"parserOptions": { | |
"ecmaVersion": 8, | |
"ecmaFeatures": { | |
"experimentalObjectRestSpread": true | |
} | |
}, | |
"extends": [ | |
"eslint:recommended", |
function pps (obj) { | |
let count = 1 | |
while (obj) { | |
const okeys = Object.keys(obj) | |
const str = okeys.length > 0 ? | |
`[${okeys.join(', ')}]` : `[${obj.constructor.name}]` | |
console.log(`[${count++}]: ${str}`) | |
obj = Object.getPrototypeOf(obj) | |
} | |
} |
function mergeTemplateArgs(strings, ...values) { | |
const stringsLn = strings.length | |
const hasValues = stringsLn > 1 | |
if (!hasValues) return strings | |
const pairsCount = stringsLn - 1 | |
const fullLength = pairsCount * 2 + 1 | |
const result = Array(fullLength) | |
result[fullLength -1] = strings[stringsLn-1] | |
for (let i = 0, j = 0; i < pairsCount; i++, j+=2) { | |
result[j] = strings[i] |
let TCO_ENABLED | |
let stackDepth = 0 | |
try { | |
(function foo(x){ | |
stackDepth+=1 | |
if (x < 5E5) return foo( x + 1 ) | |
})( 1 ) | |
TCO_ENABLED = true | |
} |
function fooASM(stdlib,foreign,heap) { | |
"use asm"; | |
var arr = new stdlib.Int32Array( heap ); | |
function foo(x,y) { | |
x = x | 0; | |
y = y | 0; | |
var i = 0; |
import { propOr, pipe, adjust, __, map, useWith, into, toPairs } from 'ramda' | |
const reducePairs = useWith(into({})) | |
const getNameField = | |
keyMap => key => propOr(key, key, keyMap) | |
const reducer = pipe( | |
getNameField, | |
adjust(__, 0), | |
map |
//@flow | |
function curry2<A, B, R>(fn : (A, B) => R) : A => B => R { | |
return function (a : A) : B => R { | |
return function (b : B) : R { | |
return fn(a, b); | |
}; | |
}; | |
}; | |
function curry3<A, B, C, R>(fn : (A, B, C) => R) : A => B => C => R { |