From 8fb04bf37bfa84a22f124a258e59d3c2ca6194c8 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Wed, 5 Jun 2019 07:47:17 +0000 Subject: [PATCH] Travis build: 1209 --- README.md | 15 +++++++-------- docs/about.html | 3 +-- docs/adapter.html | 4 ++-- docs/archive.html | 2 +- docs/browser.html | 2 +- docs/date.html | 2 +- docs/function.html | 3 ++- docs/glossary.html | 2 +- docs/index.html | 10 +++++----- docs/math.html | 6 +++--- docs/node.html | 2 +- docs/object.html | 2 +- docs/string.html | 2 +- docs/type.html | 2 +- docs/utility.html | 2 +- snippets/checkProp.md | 1 + snippets/factorial.md | 4 ++-- snippets/pipeAsyncFunctions.md | 2 +- snippets/remove.md | 6 +++--- test/_30s.js | 10 +++++----- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index cba5fdb04..fabe09e29 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ > Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less. -[](https://www.digitalocean.com) - * Use Ctrl + F or command + F to search for a snippet. * Contributions welcome, please read the [contribution guide](CONTRIBUTING.md). * Snippets are written in ES6, use the [Babel transpiler](https://babeljs.io/) to ensure backwards-compatibility. @@ -680,7 +678,7 @@ const sum = pipeAsyncFunctions( x => x + 3, async x => (await x) + 4 ); -(async () => { +(async() => { console.log(await sum(5)); // 15 (after one second) })(); ``` @@ -2330,9 +2328,9 @@ The `func` is invoked with three arguments (`value, index, array`). const remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) + arr.splice(arr.indexOf(val), 1); + return acc.concat(val); + }, []) : []; ``` @@ -4745,6 +4743,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true @@ -5621,8 +5620,8 @@ Throws an exception if `n` is a negative number. const factorial = n => n < 0 ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() + throw new TypeError('Negative numbers are not allowed!'); + })() : n <= 1 ? 1 : n * factorial(n - 1); diff --git a/docs/about.html b/docs/about.html index ba38d9e08..5fe628ed9 100644 --- a/docs/about.html +++ b/docs/about.html @@ -582,8 +582,7 @@
30 seconds of code is licensed under the CC0-1.0
license.
Logos made by Angelos Chalaris and ribbon made by Tim Holman are licensed under the MIT
- license.
Sponsored by DigitalOcean
About Contributing Archive Glossary
diff --git a/docs/adapter.html b/docs/adapter.html index ca583c80e..54ecf67c8 100644 --- a/docs/adapter.html +++ b/docs/adapter.html @@ -133,7 +133,7 @@ Object.assig x => x + 3, async x => (await x) + 4 ); -(async () => { +(async() => { console.log(await sum(5)); // 15 (after one second) })();Learn new ES6 JavaScript language features like arrow function, destructuring, generators & more to write cleaner and more productive, readable programs.
Performs left-to-right function composition.
Use Array.prototype.reduce() with the spread operator (...) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); @@ -160,4 +160,4 @@ Object.assig arrayMax([1, 2, 3]); // 3
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] -