Housekeeping, fix security vulnerabilities
This commit is contained in:
@ -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
|
||||
|
||||
@ -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);
|
||||
```
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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]
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@ -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])
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user