Skip to content

Instantly share code, notes, and snippets.

@rdsn
rdsn / transformtopercentshares
Last active April 9, 2020 18:46
Функция преобразующая доли, представленные в виде рациональных, в доли в процентном выражении
const shares = ['1.5', '3', '6', '1.5'];
const transformToPercentShares = (rationalShares) => {
if (!rationalShares) {
throw new Error('Argument is missing');
} else if (!Array.isArray(rationalShares)) {
throw new TypeError('Argument should be an array');
} else if (!rationalShares.length) {
throw new Error('Argument must contain at least one value');
}
@rdsn
rdsn / es6-compose.md
Created July 5, 2021 03:54 — forked from JamieMason/es6-compose.md
ES6 JavaScript compose function

ES6 JavaScript Compose Function

Definition

const compose = (...fns) =>
  fns.reduceRight((prevFn, nextFn) =>
    (...args) => nextFn(prevFn(...args)),
    value => value
 );