diff --git a/README.md b/README.md index 4ea8151fa..ec2c86abc 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ > Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less. +[![Sponsored by DigitalOcean](/sponsored_by_DigitalOcean.png)](https://www.digitalocean.com) + - Use Ctrl + F or command + F to search for a snippet. - Contributions welcome, please read the [contribution guide](CONTRIBUTING.md). diff --git a/docs/adapter.html b/docs/adapter.html index b9c269dc6..c2a0febd5 100644 --- a/docs/adapter.html +++ b/docs/adapter.html @@ -152,4 +152,4 @@ Object.assig arrayMax([1, 2, 3]); // 3

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]
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/archive.html b/docs/archive.html index 6d985f931..ae3bc3a41 100644 --- a/docs/archive.html +++ b/docs/archive.html @@ -239,4 +239,4 @@ window.speechSynthesis.speak(msg); };
speechSynthesis('Hello, World'); // // plays the message
-

\ No newline at end of file +
\ No newline at end of file diff --git a/docs/array.html b/docs/array.html index 6659a76cd..1af1734db 100644 --- a/docs/array.html +++ b/docs/array.html @@ -554,4 +554,4 @@ managers; // [100, 200], (a, b, c) => (a != null ? a : 'a') + (b != null ? b : 'b') + (c != null ? c : 'c') ); // [111, 222, '3bc'] - \ No newline at end of file + \ No newline at end of file diff --git a/docs/beginner.html b/docs/beginner.html index 28cd66f04..9a5bc927a 100644 --- a/docs/beginner.html +++ b/docs/beginner.html @@ -144,4 +144,4 @@

truncateString

Truncates a string up to a specified length.

Determine if the string's length is greater than num. Return the string truncated to the desired length, with '...' appended to the end or the original string.

const truncateString = (str, num) =>
   str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
 
truncateString('boomerang', 7); // 'boom...'
-

\ No newline at end of file +
\ No newline at end of file diff --git a/docs/browser.html b/docs/browser.html index f75348af7..9654a06e5 100644 --- a/docs/browser.html +++ b/docs/browser.html @@ -353,4 +353,4 @@ recorder.sta (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) );
UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d'
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/date.html b/docs/date.html index 89ac2f782..aaa579981 100644 --- a/docs/date.html +++ b/docs/date.html @@ -122,4 +122,4 @@ };
tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
 tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26)
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/function.html b/docs/function.html index b27a36689..d4dae1657 100644 --- a/docs/function.html +++ b/docs/function.html @@ -297,4 +297,4 @@ console.log<
const doubleEvenNumbers = when(x => x % 2 === 0, x => x * 2);
 doubleEvenNumbers(2); // 4
 doubleEvenNumbers(1); // 1
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/math.html b/docs/math.html index 8879b5f1f..527971fac 100644 --- a/docs/math.html +++ b/docs/math.html @@ -277,4 +277,4 @@ own individual rating by supplying it as the third argument. Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER));
toSafeInteger('3.2'); // 3
 toSafeInteger(Infinity); // 9007199254740991
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/node.html b/docs/node.html index c71b6bd93..cbc289c18 100644 --- a/docs/node.html +++ b/docs/node.html @@ -154,4 +154,4 @@ console.log< (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) );
UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/object.html b/docs/object.html index 9cf0bcb3c..d5a01492c 100644 --- a/docs/object.html +++ b/docs/object.html @@ -344,4 +344,4 @@ Foo.prototypereturn acc; }, {});
unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 }
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/string.html b/docs/string.html index c658d6d57..dd5a90882 100644 --- a/docs/string.html +++ b/docs/string.html @@ -255,4 +255,4 @@

words

Converts a given string into an array of words.

Use String.split() with a supplied pattern (defaults to non-alpha as a regexp) to convert to an array of strings. Use Array.filter() to remove any empty strings. Omit the second argument to use the default regexp.

const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
 
words('I love javaScript!!'); // ["I", "love", "javaScript"]
 words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"]
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/type.html b/docs/type.html index 160a6d7d6..27b7ffbc1 100644 --- a/docs/type.html +++ b/docs/type.html @@ -181,4 +181,4 @@
isValidJSON('{"name":"Adam","age":20}'); // true
 isValidJSON('{"name":"Adam",age:"20"}'); // false
 isValidJSON(null); // true
-
\ No newline at end of file + \ No newline at end of file diff --git a/docs/utility.html b/docs/utility.html index 458690a22..1869625b4 100644 --- a/docs/utility.html +++ b/docs/utility.html @@ -272,4 +272,4 @@ Logs: { yesNo('yes'); // true yesNo('No'); // false yesNo('Foo', true); // true - \ No newline at end of file + \ No newline at end of file