Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keystonejs/utils

Package Overview
Dependencies
Maintainers
6
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keystonejs/utils - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

6

CHANGELOG.md
# @keystonejs/utils
## 5.2.1
### Patch Changes
- [`dcdd8ed9`](https://github.com/keystonejs/keystone/commit/dcdd8ed9142cf3328a7af80bc167ef93c7669b09) [#2381](https://github.com/keystonejs/keystone/pull/2381) Thanks [@timleslie](https://github.com/timleslie)! - Updated `@babel/*` dependency packages to latest versions.
## 5.2.0

@@ -4,0 +10,0 @@

50

dist/utils.cjs.dev.js

@@ -21,15 +21,9 @@ 'use strict';

const mapKeys = (obj, func) => Object.entries(obj).reduce((acc, _ref) => {
let [key, value] = _ref;
return _objectSpread({}, acc, {
[key]: func(value, key, obj)
});
}, {}); // { key: value, ... } => { mapFn(key, value): value, ... }
const mapKeys = (obj, func) => Object.entries(obj).reduce((acc, [key, value]) => _objectSpread({}, acc, {
[key]: func(value, key, obj)
}), {}); // { key: value, ... } => { mapFn(key, value): value, ... }
const mapKeyNames = (obj, func) => Object.entries(obj).reduce((acc, _ref2) => {
let [key, value] = _ref2;
return _objectSpread({}, acc, {
[func(key, value, obj)]: value
});
}, {});
const mapKeyNames = (obj, func) => Object.entries(obj).reduce((acc, [key, value]) => _objectSpread({}, acc, {
[func(key, value, obj)]: value
}), {});
const resolveAllKeys = obj => {

@@ -51,8 +45,5 @@ const returnValue = {};

if (Object.keys(errors).length) {
const firstError = results.find((_ref3) => {
let {
isRejected
} = _ref3;
return isRejected;
}).reason; // Use the first error as the message so it's at least meaningful
const firstError = results.find(({
isRejected
}) => isRejected).reason; // Use the first error as the message so it's at least meaningful

@@ -81,8 +72,5 @@ const error = new Error(firstError.message || firstError.toString());

}), {});
const filterValues = (obj, predicate) => Object.entries(obj).reduce((acc, _ref4) => {
let [key, value] = _ref4;
return predicate(value) ? _objectSpread({}, acc, {
[key]: value
}) : acc;
}, {}); // [x, y, z] => { x[keyedBy]: mapFn(x), ... }
const filterValues = (obj, predicate) => Object.entries(obj).reduce((acc, [key, value]) => predicate(value) ? _objectSpread({}, acc, {
[key]: value
}) : acc, {}); // [x, y, z] => { x[keyedBy]: mapFn(x), ... }
// [{ name: 'a', animal: 'cat' },

@@ -98,15 +86,9 @@ // { name: 'b', animal: 'dog' },

const arrayToObject = function arrayToObject(objs, keyedBy) {
let mapFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : i => i;
return objs.reduce((acc, obj) => _objectSpread({}, acc, {
[obj[keyedBy]]: mapFn(obj)
}), {});
}; // [[1, 2, 3], [4, 5], 6, [[7, 8], [9, 10]]] => [1, 2, 3, 4, 5, 6, [7, 8], [9, 10]]
const arrayToObject = (objs, keyedBy, mapFn = i => i) => objs.reduce((acc, obj) => _objectSpread({}, acc, {
[obj[keyedBy]]: mapFn(obj)
}), {}); // [[1, 2, 3], [4, 5], 6, [[7, 8], [9, 10]]] => [1, 2, 3, 4, 5, 6, [7, 8], [9, 10]]
const flatten = arr => Array.prototype.concat(...arr); // flatMap([{ vals: [2, 2] }, { vals: [3] }], x => x.vals) => [2, 2, 3]
const flatMap = function flatMap(arr) {
let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
return flatten(arr.map(fn));
}; // { foo: [1, 2, 3], bar: [4, 5, 6]} => [{ foo: 1, bar: 4}, { foo: 2, bar: 5}, { foo: 3, bar: 6 }]
const flatMap = (arr, fn = identity) => flatten(arr.map(fn)); // { foo: [1, 2, 3], bar: [4, 5, 6]} => [{ foo: 1, bar: 4}, { foo: 2, bar: 5}, { foo: 3, bar: 6 }]

@@ -113,0 +95,0 @@ const zipObj = obj => Object.values(obj)[0].map((_, i) => Object.keys(obj).reduce((acc, k) => _objectSpread({}, acc, {

@@ -36,13 +36,7 @@ "use strict";

const noop = x => x, identity = noop, getType = thing => Object.prototype.toString.call(thing).replace(/\[object (.*)\]/, "$1"), escapeRegExp = str => (str || "").replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), mapKeys = (obj, func) => Object.entries(obj).reduce((acc, _ref) => {
let [key, value] = _ref;
return _objectSpread({}, acc, {
[key]: func(value, key, obj)
});
}, {}), mapKeyNames = (obj, func) => Object.entries(obj).reduce((acc, _ref2) => {
let [key, value] = _ref2;
return _objectSpread({}, acc, {
[func(key, value, obj)]: value
});
}, {}), resolveAllKeys = obj => {
const noop = x => x, identity = noop, getType = thing => Object.prototype.toString.call(thing).replace(/\[object (.*)\]/, "$1"), escapeRegExp = str => (str || "").replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), mapKeys = (obj, func) => Object.entries(obj).reduce((acc, [key, value]) => _objectSpread({}, acc, {
[key]: func(value, key, obj)
}), {}), mapKeyNames = (obj, func) => Object.entries(obj).reduce((acc, [key, value]) => _objectSpread({}, acc, {
[func(key, value, obj)]: value
}), {}), resolveAllKeys = obj => {
const returnValue = {}, errors = {}, allPromises = Object.keys(obj).map(key => pReflect(obj[key]).then(val => (val.isFulfilled ? returnValue[key] = val.value : val.isRejected && (errors[key] = val.reason),

@@ -52,6 +46,3 @@ val)));

if (Object.keys(errors).length) {
const firstError = results.find(_ref3 => {
let {isRejected: isRejected} = _ref3;
return isRejected;
}).reason, error = new Error(firstError.message || firstError.toString());
const firstError = results.find(({isRejected: isRejected}) => isRejected).reason, error = new Error(firstError.message || firstError.toString());
throw error.errors = errors, error;

@@ -65,16 +56,7 @@ }

[key]: val
}), {}), filterValues = (obj, predicate) => Object.entries(obj).reduce((acc, _ref4) => {
let [key, value] = _ref4;
return predicate(value) ? _objectSpread({}, acc, {
[key]: value
}) : acc;
}, {}), arrayToObject = function(objs, keyedBy) {
let mapFn = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : i => i;
return objs.reduce((acc, obj) => _objectSpread({}, acc, {
[obj[keyedBy]]: mapFn(obj)
}), {});
}, flatten = arr => Array.prototype.concat(...arr), flatMap = function(arr) {
let fn = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : identity;
return flatten(arr.map(fn));
}, zipObj = obj => Object.values(obj)[0].map((_, i) => Object.keys(obj).reduce((acc, k) => _objectSpread({}, acc, {
}), {}), filterValues = (obj, predicate) => Object.entries(obj).reduce((acc, [key, value]) => predicate(value) ? _objectSpread({}, acc, {
[key]: value
}) : acc, {}), arrayToObject = (objs, keyedBy, mapFn = (i => i)) => objs.reduce((acc, obj) => _objectSpread({}, acc, {
[obj[keyedBy]]: mapFn(obj)
}), {}), flatten = arr => Array.prototype.concat(...arr), flatMap = (arr, fn = identity) => flatten(arr.map(fn)), zipObj = obj => Object.values(obj)[0].map((_, i) => Object.keys(obj).reduce((acc, k) => _objectSpread({}, acc, {
[k]: obj[k][i]

@@ -81,0 +63,0 @@ }), {})), compose = fns => o => fns.reduce((acc, fn) => fn(acc), o), mergeWhereClause = (queryArgs, whereClauseToMergeIn) => {

@@ -15,15 +15,9 @@ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';

const mapKeys = (obj, func) => Object.entries(obj).reduce((acc, _ref) => {
let [key, value] = _ref;
return _objectSpread({}, acc, {
[key]: func(value, key, obj)
});
}, {}); // { key: value, ... } => { mapFn(key, value): value, ... }
const mapKeys = (obj, func) => Object.entries(obj).reduce((acc, [key, value]) => _objectSpread({}, acc, {
[key]: func(value, key, obj)
}), {}); // { key: value, ... } => { mapFn(key, value): value, ... }
const mapKeyNames = (obj, func) => Object.entries(obj).reduce((acc, _ref2) => {
let [key, value] = _ref2;
return _objectSpread({}, acc, {
[func(key, value, obj)]: value
});
}, {});
const mapKeyNames = (obj, func) => Object.entries(obj).reduce((acc, [key, value]) => _objectSpread({}, acc, {
[func(key, value, obj)]: value
}), {});
const resolveAllKeys = obj => {

@@ -45,8 +39,5 @@ const returnValue = {};

if (Object.keys(errors).length) {
const firstError = results.find((_ref3) => {
let {
isRejected
} = _ref3;
return isRejected;
}).reason; // Use the first error as the message so it's at least meaningful
const firstError = results.find(({
isRejected
}) => isRejected).reason; // Use the first error as the message so it's at least meaningful

@@ -75,8 +66,5 @@ const error = new Error(firstError.message || firstError.toString());

}), {});
const filterValues = (obj, predicate) => Object.entries(obj).reduce((acc, _ref4) => {
let [key, value] = _ref4;
return predicate(value) ? _objectSpread({}, acc, {
[key]: value
}) : acc;
}, {}); // [x, y, z] => { x[keyedBy]: mapFn(x), ... }
const filterValues = (obj, predicate) => Object.entries(obj).reduce((acc, [key, value]) => predicate(value) ? _objectSpread({}, acc, {
[key]: value
}) : acc, {}); // [x, y, z] => { x[keyedBy]: mapFn(x), ... }
// [{ name: 'a', animal: 'cat' },

@@ -92,15 +80,9 @@ // { name: 'b', animal: 'dog' },

const arrayToObject = function arrayToObject(objs, keyedBy) {
let mapFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : i => i;
return objs.reduce((acc, obj) => _objectSpread({}, acc, {
[obj[keyedBy]]: mapFn(obj)
}), {});
}; // [[1, 2, 3], [4, 5], 6, [[7, 8], [9, 10]]] => [1, 2, 3, 4, 5, 6, [7, 8], [9, 10]]
const arrayToObject = (objs, keyedBy, mapFn = i => i) => objs.reduce((acc, obj) => _objectSpread({}, acc, {
[obj[keyedBy]]: mapFn(obj)
}), {}); // [[1, 2, 3], [4, 5], 6, [[7, 8], [9, 10]]] => [1, 2, 3, 4, 5, 6, [7, 8], [9, 10]]
const flatten = arr => Array.prototype.concat(...arr); // flatMap([{ vals: [2, 2] }, { vals: [3] }], x => x.vals) => [2, 2, 3]
const flatMap = function flatMap(arr) {
let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
return flatten(arr.map(fn));
}; // { foo: [1, 2, 3], bar: [4, 5, 6]} => [{ foo: 1, bar: 4}, { foo: 2, bar: 5}, { foo: 3, bar: 6 }]
const flatMap = (arr, fn = identity) => flatten(arr.map(fn)); // { foo: [1, 2, 3], bar: [4, 5, 6]} => [{ foo: 1, bar: 4}, { foo: 2, bar: 5}, { foo: 3, bar: 6 }]

@@ -107,0 +89,0 @@ const zipObj = obj => Object.values(obj)[0].map((_, i) => Object.keys(obj).reduce((acc, k) => _objectSpread({}, acc, {

{
"name": "@keystonejs/utils",
"description": "Common utility functions used throughout @keystonejs packages.",
"version": "5.2.0",
"version": "5.2.1",
"author": "The KeystoneJS Development Team",

@@ -15,3 +15,3 @@ "license": "MIT",

"dependencies": {
"@babel/runtime": "^7.7.7",
"@babel/runtime": "^7.8.4",
"p-is-promise": "^3.0.0",

@@ -18,0 +18,0 @@ "p-lazy": "^3.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc