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);
+ }
30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.
\ No newline at end of file
diff --git a/snippets/isArrayLike.md b/snippets/isArrayLike.md
index 83c8acb81..36eae12a9 100644
--- a/snippets/isArrayLike.md
+++ b/snippets/isArrayLike.md
@@ -6,18 +6,17 @@ Use `Array.from()` and a `try... catch` block to check if the provided argument
```js
const isArrayLike = arr => {
- try{
+ try {
Array.from(arr);
return true;
- }
- catch(e){
+ } catch (e) {
return false;
}
-}
+};
```
```js
-isArrayLike(document.querySelector('.className')) // true
-isArrayLike('abc') // true
-isArrayLike(null) // false
+isArrayLike(document.querySelector('.className')); // true
+isArrayLike('abc'); // true
+isArrayLike(null); // false
```
diff --git a/snippets/isValidJSON.md b/snippets/isValidJSON.md
index 56211961b..e9898caee 100644
--- a/snippets/isValidJSON.md
+++ b/snippets/isValidJSON.md
@@ -6,14 +6,13 @@ Use `JSON.parse()` and a `try... catch` block to check if the provided argument
```js
const isValidJSON = obj => {
- try{
+ try {
JSON.parse(obj);
return true;
- }
- catch(e){
+ } catch (e) {
return false;
}
-}
+};
```
```js
diff --git a/tag_database b/tag_database
index e2bb75c7e..c02508fff 100644
--- a/tag_database
+++ b/tag_database
@@ -66,6 +66,7 @@ inRange:math
intersection:array
isArmstrongNumber:math
isArray:utility
+isArrayLike:uncategorized
isBoolean:utility
isDivisible:math
isEven:math
@@ -75,6 +76,7 @@ isNumber:utility
isPrime:math
isString:utility
isSymbol:utility
+isValidJSON:uncategorized
JSONToDate:date
JSONToFile:node
last:array