Housekeeping, fix security vulnerabilities

This commit is contained in:
Angelos Chalaris
2019-08-19 11:18:37 +03:00
parent 3ed60da1cd
commit 6281883952
25 changed files with 6439 additions and 6760 deletions

View File

@ -12,6 +12,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
```
```js
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true

View File

@ -9,9 +9,8 @@ Calls `Object.freeze(obj)` recursively on all unfrozen properties of passed obje
```js
const deepFreeze = obj =>
Object.keys(obj).forEach(
prop =>
!(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
Object.keys(obj).forEach(prop =>
!(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
) || Object.freeze(obj);
```

View File

@ -17,7 +17,7 @@ const deepMapKeys = (obj, f) =>
? Object.keys(obj).reduce((acc, current) => {
const val = obj[current];
acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc;
}, {})
: obj;

View File

@ -10,11 +10,10 @@ If no function is provided, the values will be compared using the equality opera
```js
const matchesWith = (obj, source, fn) =>
Object.keys(source).every(
key =>
obj.hasOwnProperty(key) && fn
? fn(obj[key], source[key], key, obj, source)
: obj[key] == source[key]
Object.keys(source).every(key =>
obj.hasOwnProperty(key) && fn
? fn(obj[key], source[key], key, obj, source)
: obj[key] == source[key]
);
```

View File

@ -14,9 +14,8 @@ The function is invoked with the elements of each group `(...group)`.
```js
const zipWith = (...array) => {
const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;
return Array.from(
{ length: Math.max(...array.map(a => a.length)) },
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
return Array.from({ length: Math.max(...array.map(a => a.length)) }, (_, i) =>
fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])
);
};
```