Merge remote-tracking branch 'origin/master'

This commit is contained in:
Angelos Chalaris
2020-04-16 23:07:42 +03:00
9 changed files with 80 additions and 81 deletions

View File

@ -23,5 +23,5 @@ const equals = (a, b) => {
```js
equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'foo' }); // true
equals([ 1, 2, 3 ], { 0: 1, 1: 2, 2: 3 }); // true
equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 }); // true
```

View File

@ -9,8 +9,7 @@ Return `'undefined'` or `'null'` if the value is `undefined` or `null`.
Otherwise, use `Object.prototype.constructor.name` to get the name of the constructor.
```js
const getType = v =>
v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name;
const getType = v => (v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name);
```
```js

View File

@ -17,8 +17,8 @@ const join = (arr, separator = ',', end = separator) =>
i === arr.length - 2
? acc + val + end
: i === arr.length - 1
? acc + val
: acc + val + separator,
? acc + val
: acc + val + separator,
''
);
```

View File

@ -13,10 +13,10 @@ Return the `queryString` or an empty string when the `queryParameters` are falsy
const objectToQueryString = queryParameters => {
return queryParameters
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {
const symbol = queryString.length === 0 ? '?' : '&';
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : '';
return queryString;
}, '')
const symbol = queryString.length === 0 ? '?' : '&';
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : '';
return queryString;
}, '')
: '';
};
```

View File

@ -20,7 +20,7 @@ const sum = pipeAsyncFunctions(
x => x + 3,
async x => (await x) + 4
);
(async() => {
(async () => {
console.log(await sum(5)); // 15 (after one second)
})();
```

View File

@ -12,9 +12,9 @@ The `func` is invoked with three arguments (`value, index, array`).
const remove = (arr, func) =>
Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
: [];
```

View File

@ -16,10 +16,10 @@ const size = val =>
Array.isArray(val)
? val.length
: val && typeof val === 'object'
? val.size || val.length || Object.keys(val).length
: typeof val === 'string'
? new Blob([val]).size
: 0;
? val.size || val.length || Object.keys(val).length
: typeof val === 'string'
? new Blob([val]).size
: 0;
```
```js