From 87acfd680ebfd61ac173b78127967c2fc60f8aef Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Wed, 24 Jan 2018 13:59:43 +0000 Subject: [PATCH] Travis build: 1398 --- README.md | 10 ---------- docs/index.html | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 87b3253ec..93bb6b044 100644 --- a/README.md +++ b/README.md @@ -85,14 +85,6 @@ average(1, 2, 3); * [`pipeFunctions`](#pipefunctions) * [`promisify`](#promisify) * [`spreadOver`](#spreadover) - - - -### Adaptor - -
-View contents - * [`unary`](#unary)
@@ -626,8 +618,6 @@ arrayMax([1, 2, 3]); // 3
[⬆ Back to top](#table-of-contents) ---- - ## Adaptor ### unary diff --git a/docs/index.html b/docs/index.html index 39a9ae8a6..55e0a2b47 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -92,7 +92,7 @@ Object.assig
 

spreadOver

Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.

Use closures and the spread operator (...) to map the array of arguments to the inputs of the function.

const spreadOver = fn => argsArr => fn(...argsArr);
 
const arrayMax = spreadOver(Math.max);
 arrayMax([1, 2, 3]); // 3
-

Adaptor

unary

Creates a function that accepts up to one argument, ignoring any additional arguments.

Call the provided function, fn, with just the first argument given.

const unary = fn => val => fn(val);
+

unary

Creates a function that accepts up to one argument, ignoring any additional arguments.

Call the provided function, fn, with just the first argument given.

const unary = fn => val => fn(val);
 
['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10]
 

Array

chunk

Chunks an array into smaller arrays of a specified size.

Use Array.from() to create a new array, that fits the number of chunks that will be produced. Use Array.slice() to map each element of the new array to a chunk the length of size. If the original array can't be split evenly, the final chunk will contain the remaining elements.

const chunk = (arr, size) =>
   Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>