From 67690e01f968a2e90d8f34a99bc92a1c1eaf0ffe Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Sat, 6 Jan 2018 12:10:41 +0000 Subject: [PATCH] Travis build: 1061 --- README.md | 155 +++++++++++++++++++++++++----------------------- docs/index.html | 34 +++++------ 2 files changed, 97 insertions(+), 92 deletions(-) diff --git a/README.md b/README.md index abdfd39a0..79ba0b7b9 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ average(1, 2, 3); * [`flattenDepth`](#flattendepth) * [`groupBy`](#groupby) * [`head`](#head) +* [`indexOfAll`](#indexofall) * [`initial`](#initial) * [`initialize2DArray`](#initialize2darray) * [`initializeArrayWithRange`](#initializearraywithrange) @@ -285,6 +286,8 @@ average(1, 2, 3); * [`escapeRegExp`](#escaperegexp) * [`fromCamelCase`](#fromcamelcase) * [`isAbsoluteURL`](#isabsoluteurl) +* [`isLowerCase`](#islowercase) +* [`isUpperCase`](#isuppercase) * [`mask`](#mask) * [`palindrome`](#palindrome) * [`pluralize`](#pluralize) @@ -342,17 +345,6 @@ average(1, 2, 3); -### _Uncategorized_ - -
-View contents - -* [`indexOfAll`](#indexofall) -* [`isLowerCase`](#islowercase) -* [`isUpperCase`](#isuppercase) - -
- --- ## 🔌 Adapter @@ -876,6 +868,34 @@ head([1, 2, 3]); // 1
[⬆ Back to top](#table-of-contents) +### indexOfAll + +Returns all indices of `val` in an array. If `val` never occurs, returns `[-1]`. + +Use `Array.forEach()` to loop over elements and `Array.push()` to store indices for matching elements. +Return `[-1]` if `length` of the array of indices is `0`, otherwise return the array of indices. + +```js +const indexOfAll = (arr, val) => { + const indices = []; + arr.forEach((el, i) => el === val && indices.push(i)); + return indices.length ? indices : [-1]; +}; +``` + +
+Examples + +```js +indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3] +indexOfAll([1, 2, 3], 4); // [-1] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### initial Returns all the elements of an array except the last one. @@ -4119,6 +4139,55 @@ isAbsoluteURL('/foo/bar'); // false
[⬆ Back to top](#table-of-contents) +### isLowerCase + +Checks if a string is lower case. + +Convert the given string to lower case, using `String.toLowerCase()` and compare it to the original. + +```js +const isLowerCase = str => str === str.toLowerCase(); +``` + +
+Examples + +```js +isLowerCase('abc'); // true +isLowerCase('a3@$'); // true +isLowerCase('Ab4'); // false +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + +### isUpperCase + +Checks if a string is upper case. + +Convert the given string to upper case, using `String.toUpperCase()` and compare it to the original. + + +```js +const isUpperCase = str => str === str.toUpperCase(); +``` + +
+Examples + +```js +isUpperCase('ABC'); // true +isLowerCase('A3@$'); // true +isLowerCase('aB4'); // false +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### mask Replaces all but the last `num` of characters with the specified mask character. @@ -5141,70 +5210,6 @@ yesNo('Foo', true); // true
[⬆ Back to top](#table-of-contents) ---- - ## _Uncategorized_ - -### indexOfAll - -Returns all indices of `val` in an array. If `val` never occurs, returns `[-1]`. - -Use `Array.forEach()` to loop over elements and `Array.push()` to store indices for matching elements. -Return `[-1]` if `length` of the array of indices is `0`, otherwise return the array of indices. - -```js -const indexOfAll = (arr, val) => { - const indices = []; - arr.forEach((el, i) => el === val && indices.push(i)); - return indices.length ? indices : [-1]; -}; -``` - -```js -indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3] -indexOfAll([1, 2, 3], 4); // [-1] -``` - -
[⬆ back to top](#table-of-contents) - - -### isLowerCase - -Checks if a string is lower case. - -Convert the given string to lower case, using `String.toLowerCase()` and compare it to the original. - -```js -const isLowerCase = str => str === str.toLowerCase(); -``` - -```js -isLowerCase('abc'); // true -isLowerCase('a3@$'); // true -isLowerCase('Ab4'); // false -``` - -
[⬆ back to top](#table-of-contents) - - -### isUpperCase - -Checks if a string is upper case. - -Convert the given string to upper case, using `String.toUpperCase()` and compare it to the original. - - -```js -const isUpperCase = str => str === str.toUpperCase(); -``` - -```js -isUpperCase('ABC'); // true -isLowerCase('A3@$'); // true -isLowerCase('aB4'); // false -``` - -
[⬆ back to top](#table-of-contents) - ## Collaborators diff --git a/docs/index.html b/docs/index.html index eb2d12c09..5eb613a54 100644 --- a/docs/index.html +++ b/docs/index.html @@ -40,7 +40,7 @@ },1700); } }, false); - }

logo 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.

const call = (key, ...args) => context => context[key](...args);
+      }

logo 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.

const call = (key, ...args) => context => context[key](...args);
 
Promise.resolve([1, 2, 3])
   .then(call('map', x => 2 * x))
   .then(console.log); //[ 2, 4, 6 ]
@@ -125,6 +125,13 @@ Object.assig
 groupBy(['one', 'two', 'three'], 'length'); // {3: ['one', 'two'], 5: ['three']}
 

Returns the head of a list.

Use arr[0] to return the first element of the passed array.

const head = arr => arr[0];
 
head([1, 2, 3]); // 1
+

indexOfAll

Returns all indices of val in an array. If val never occurs, returns [-1].

Use Array.forEach() to loop over elements and Array.push() to store indices for matching elements. Return [-1] if length of the array of indices is 0, otherwise return the array of indices.

const indexOfAll = (arr, val) => {
+  const indices = [];
+  arr.forEach((el, i) => el === val && indices.push(i));
+  return indices.length ? indices : [-1];
+};
+
indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3]
+indexOfAll([1, 2, 3], 4); // [-1]
 

initial

Returns all the elements of an array except the last one.

Use arr.slice(0,-1) to return all but the last element of the array.

const initial = arr => arr.slice(0, -1);
 
initial([1, 2, 3]); // [1,2]
 

initialize2DArray

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.

const initialize2DArray = (w, h, val = null) =>
@@ -863,6 +870,14 @@ console.log<
 
isAbsoluteURL('https://google.com'); // true
 isAbsoluteURL('ftp://www.myserver.net'); // true
 isAbsoluteURL('/foo/bar'); // false
+

isLowerCase

Checks if a string is lower case.

Convert the given string to lower case, using String.toLowerCase() and compare it to the original.

const isLowerCase = str => str === str.toLowerCase();
+
isLowerCase('abc'); // true
+isLowerCase('a3@$'); // true
+isLowerCase('Ab4'); // false
+

isUpperCase

Checks if a string is upper case.

Convert the given string to upper case, using String.toUpperCase() and compare it to the original.

const isUpperCase = str => str === str.toUpperCase();
+
isUpperCase('ABC'); // true
+isLowerCase('A3@$'); // true
+isLowerCase('aB4'); // false
 

mask

Replaces all but the last num of characters with the specified mask character.

Use String.slice() to grab the portion of the characters that need to be masked and use String.replace() with a regexp to replace every character with the mask character. Concatenate the masked characters with the remaining unmasked portion of the string. Omit the second argument, num, to keep a default of 4 characters unmasked. If num is negative, the unmasked characters will be at the start of the string. Omit the third argument, mask, to use a default character of '*' for the mask.

const mask = (cc, num = 4, mask = '*') =>
   ('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
 
mask(1234567890); // '******7890'
@@ -1104,19 +1119,4 @@ console.log<
 yesNo('yes'); // true
 yesNo('No'); // false
 yesNo('Foo', true); // true
-

Uncategorized

indexOfAll

Returns all indices of val in an array. If val never occurs, returns [-1].

Use Array.forEach() to loop over elements and Array.push() to store indices for matching elements. Return [-1] if length of the array of indices is 0, otherwise return the array of indices.

const indexOfAll = (arr, val) => {
-  const indices = [];
-  arr.forEach((el, i) => el === val && indices.push(i));
-  return indices.length ? indices : [-1];
-};
-
indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3]
-indexOfAll([1, 2, 3], 4); // [-1]
-

isLowerCase

Checks if a string is lower case.

Convert the given string to lower case, using String.toLowerCase() and compare it to the original.

const isLowerCase = str => str === str.toLowerCase();
-
isLowerCase('abc'); // true
-isLowerCase('a3@$'); // true
-isLowerCase('Ab4'); // false
-

isUpperCase

Checks if a string is upper case.

Convert the given string to upper case, using String.toUpperCase() and compare it to the original.

const isUpperCase = str => str === str.toUpperCase();
-
isUpperCase('ABC'); // true
-isLowerCase('A3@$'); // true
-isLowerCase('aB4'); // false
-
\ No newline at end of file +
\ No newline at end of file