From 62bb691a8b82e1db297d218e975cfeefcd071d6b Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Tue, 16 Jan 2018 15:14:29 +0000
Subject: [PATCH] Travis build: 1265
---
README.md | 79 ++++++++++++++++++++++-
docs/index.html | 16 ++++-
snippets/initializeArrayWithRangeRight.md | 4 +-
3 files changed, 95 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index fc64e5408..b3607ac90 100644
--- a/README.md
+++ b/README.md
@@ -112,6 +112,7 @@ average(1, 2, 3);
* [`initial`](#initial)
* [`initialize2DArray`](#initialize2darray)
* [`initializeArrayWithRange`](#initializearraywithrange)
+* [`initializeArrayWithRangeRight`](#initializearraywithrangeright)
* [`initializeArrayWithValues`](#initializearraywithvalues)
* [`intersection`](#intersection)
* [`isSorted`](#issorted)
@@ -329,6 +330,7 @@ average(1, 2, 3);
* [`isBoolean`](#isboolean)
* [`isFunction`](#isfunction)
* [`isMap`](#ismap)
+* [`isNil`](#isnil)
* [`isNull`](#isnull)
* [`isNumber`](#isnumber)
* [`isObject`](#isobject)
@@ -339,6 +341,7 @@ average(1, 2, 3);
* [`isString`](#isstring)
* [`isSymbol`](#issymbol)
* [`isTypedArray`](#istypedarray)
+* [`isUndefined`](#isundefined)
* [`isValidJSON`](#isvalidjson)
* [`isWeakMap`](#isweakmap)
* [`isWeakSet`](#isweakset)
@@ -1024,7 +1027,7 @@ initialize2DArray(2, 2, 0); // [[0,0], [0,0]]
### initializeArrayWithRange
-Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with there common difference `step`.
+Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.
Use `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.map()` to fill with the desired values in a range.
You can omit `start` to use a default value of `0`.
@@ -1049,6 +1052,35 @@ initializeArrayWithRange(9, 0, 2); // [0,2,4,6,8]
[⬆ Back to top](#table-of-contents)
+### initializeArrayWithRangeRight
+
+Initializes an array containing the numbers in the specified range (in reverse) where `start` and `end` are inclusive with their common difference `step`.
+
+Use `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.map()` to fill with the desired values in a range.
+You can omit `start` to use a default value of `0`.
+You can omit `step` to use a default value of `1`.
+
+```js
+const initializeArrayWithRangeRight = (end, start = 0, step = 1) =>
+ Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(
+ (v, i, arr) => (arr.length - i - 1) * step + start
+ );
+```
+
+
+Examples
+
+```js
+initializeArrayWithRangeRight(5); // [5,4,3,2,1,0]
+initializeArrayWithRangeRight(7, 3); // [7,6,5,4,3]
+initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0]
+```
+
+
+
+ [⬆ Back to top](#table-of-contents)
+
+
### initializeArrayWithValues
Initializes and fills an array with the specified values.
@@ -5277,6 +5309,29 @@ isMap(new Map()); // true
[⬆ Back to top](#table-of-contents)
+### isNil
+
+Returns `true` if the specified value is `null` or `undefined`, `false` otherwise.
+
+Use the strict equality operator to check if the value and of `val` are equal to `null` or `undefined`.
+
+```js
+const isNil = val => val === undefined || val === null;
+```
+
+
+Examples
+
+```js
+isNil(null); // true
+isNil(undefined); // true
+```
+
+
+
+ [⬆ Back to top](#table-of-contents)
+
+
### isNull
Returns `true` if the specified value is `null`, `false` otherwise.
@@ -5520,6 +5575,28 @@ isTypedArray(new TypedArray()); // true
[⬆ Back to top](#table-of-contents)
+### isUndefined
+
+Returns `true` if the specified value is `undefined`, `false` otherwise.
+
+Use the strict equality operator to check if the value and of `val` are equal to `undefined`.
+
+```js
+const isUndefined = val => val === undefined;
+```
+
+
+Examples
+
+```js
+isUndefined(undefined); // true
+```
+
+
+
+ [⬆ Back to top](#table-of-contents)
+
+
### isValidJSON
Checks if the provided argument is a valid JSON.
diff --git a/docs/index.html b/docs/index.html
index 70ea19b9d..35d97f198 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -50,7 +50,7 @@
scrollToTop();
}
}, false);
- }
30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.
Adapter
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.
Initializes a 2D array of given width and height and value.
Use Array.map() to generate h rows where each is a new array of size w initialize with value. If the value is not provided, default to null.
constinitialize2DArray=(w, h, val =null)=>
Array.from({ length: h }).map(()=> Array.from({ length: w }).fill(val));
initialize2DArray(2,2,0);// [[0,0], [0,0]]
-
initializeArrayWithRange
Initializes an array containing the numbers in the specified range where start and end are inclusive with there common difference step.
Use Array.from(Math.ceil((end+1-start)/step)) to create an array of the desired length(the amounts of elements is equal to (end-start)/step or (end+1-start)/step for inclusive end), Array.map() to fill with the desired values in a range. You can omit start to use a default value of 0. You can omit step to use a default value of 1.
Initializes an array containing the numbers in the specified range where start and end are inclusive with their common difference step.
Use Array.from(Math.ceil((end+1-start)/step)) to create an array of the desired length(the amounts of elements is equal to (end-start)/step or (end+1-start)/step for inclusive end), Array.map() to fill with the desired values in a range. You can omit start to use a default value of 0. You can omit step to use a default value of 1.
Initializes an array containing the numbers in the specified range (in reverse) where start and end are inclusive with their common difference step.
Use Array.from(Math.ceil((end+1-start)/step)) to create an array of the desired length(the amounts of elements is equal to (end-start)/step or (end+1-start)/step for inclusive end), Array.map() to fill with the desired values in a range. You can omit start to use a default value of 0. You can omit step to use a default value of 1.