From ce08cc12343ed6d0d062f79f28313124f97824a1 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Sat, 20 Jul 2019 09:46:25 +0000 Subject: [PATCH] Travis build: 1313 --- README.md | 5 +++-- docs/date.html | 4 ++-- docs/function.html | 1 + snippets/checkProp.md | 1 + test/_30s.js | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 92bda6ba1..0f134dd39 100644 --- a/README.md +++ b/README.md @@ -4531,11 +4531,11 @@ isWeekday(); // true (if current date is 2019-07-19) Results in a boolean representation of a specific date. Pass the specific date object firstly. -Use `Date.getDay()` to check weekend then return a boolean. +Use `Date.getDay()` to check weekend based on the day being returned as 0 - 6 using a modulo operation then return a boolean. ```js const isWeekend = (t = new Date()) => { - return t.getDay() === 0 || t.getDay() === 6; + return t.getDay() % 6 === 0; }; ``` @@ -4817,6 +4817,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/docs/date.html b/docs/date.html index 196cd9d9b..8cd64ebed 100644 --- a/docs/date.html +++ b/docs/date.html @@ -139,8 +139,8 @@ return t.getDay() % 6 !== 0; };
isWeekday(); // true (if current date is 2019-07-19) -
Results in a boolean representation of a specific date.
Pass the specific date object firstly. Use Date.getDay() to check weekend then return a boolean.
const isWeekend = (t = new Date()) => { - return t.getDay() === 0 || t.getDay() === 6; +
Results in a boolean representation of a specific date.
Pass the specific date object firstly. Use Date.getDay() to check weekend based on the day being returned as 0 - 6 using a modulo operation then return a boolean.
const isWeekend = (t = new Date()) => { + return t.getDay() % 6 === 0; };
isWeekend(); // 2018-10-19 (if current date is 2018-10-18)
Returns the maximum of the given dates.
Use the ES6 spread syntax with Math.max to find the maximum date value, new Date() to convert it to a Date object.
const maxDate = dates => new Date(Math.max(...dates)); diff --git a/docs/function.html b/docs/function.html index 41700dc2a..d3d643ffc 100644 --- a/docs/function.html +++ b/docs/function.html @@ -158,6 +158,7 @@ console.log< + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/snippets/checkProp.md b/snippets/checkProp.md index 465b862f1..5b76c6b3e 100644 --- a/snippets/checkProp.md +++ b/snippets/checkProp.md @@ -23,6 +23,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/test/_30s.js b/test/_30s.js index 7110da6b0..8005768f4 100644 --- a/test/_30s.js +++ b/test/_30s.js @@ -662,7 +662,7 @@ const isWeekday = (t = new Date()) => { return t.getDay() % 6 !== 0; }; const isWeekend = (t = new Date()) => { - return t.getDay() === 0 || t.getDay() === 6; + return t.getDay() % 6 === 0; }; const isWritableStream = val => val !== null &&