knex-utils
Advanced tools
Comparing version 5.1.0 to 5.2.0
export { checkHeartbeat, HEARTBEAT_QUERIES } from './lib/heartbeatUtils'; | ||
export { copyWithoutUndefined, pick, isEmptyObject } from './lib/objectUtils'; | ||
export { copyWithoutUndefined, pick, isEmptyObject, groupBy } from './lib/objectUtils'; | ||
export { chunk } from './lib/chunkUtils'; | ||
export { updateJoinTable, calculateEntityListDiff } from './lib/diffUtils'; | ||
export type { UpdateJoinTableParams, EntityListDiff } from './lib/diffUtils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateEntityListDiff = exports.updateJoinTable = exports.chunk = exports.isEmptyObject = exports.pick = exports.copyWithoutUndefined = exports.HEARTBEAT_QUERIES = exports.checkHeartbeat = void 0; | ||
exports.calculateEntityListDiff = exports.updateJoinTable = exports.chunk = exports.groupBy = exports.isEmptyObject = exports.pick = exports.copyWithoutUndefined = exports.HEARTBEAT_QUERIES = exports.checkHeartbeat = void 0; | ||
var heartbeatUtils_1 = require("./lib/heartbeatUtils"); | ||
@@ -11,2 +11,3 @@ Object.defineProperty(exports, "checkHeartbeat", { enumerable: true, get: function () { return heartbeatUtils_1.checkHeartbeat; } }); | ||
Object.defineProperty(exports, "isEmptyObject", { enumerable: true, get: function () { return objectUtils_1.isEmptyObject; } }); | ||
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return objectUtils_1.groupBy; } }); | ||
var chunkUtils_1 = require("./lib/chunkUtils"); | ||
@@ -13,0 +14,0 @@ Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return chunkUtils_1.chunk; } }); |
export declare function copyWithoutUndefined<T extends Record<K, V>, K extends string | number | symbol, V>(originalValue: T): T; | ||
export declare function pick<T, K extends string | number | symbol>(source: T, propNames: readonly K[]): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>; | ||
export declare function isEmptyObject(params: Record<string, any>): boolean; | ||
export declare function groupBy<T>(inputArray: T[], propName: string): Record<string, T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isEmptyObject = exports.pick = exports.copyWithoutUndefined = void 0; | ||
exports.groupBy = exports.isEmptyObject = exports.pick = exports.copyWithoutUndefined = void 0; | ||
function copyWithoutUndefined(originalValue) { | ||
@@ -37,2 +37,19 @@ return Object.keys(originalValue).reduce((acc, key) => { | ||
exports.isEmptyObject = isEmptyObject; | ||
function groupBy(inputArray, propName) { | ||
return inputArray.reduce((result, entry) => { | ||
// @ts-ignore | ||
const key = entry[propName]; | ||
// @ts-ignore | ||
if (Object.hasOwnProperty.call(result, key)) { | ||
// @ts-ignore | ||
result[key].push(entry); | ||
} | ||
else { | ||
// @ts-ignore | ||
result[key] = [entry]; | ||
} | ||
return result; | ||
}, {}); | ||
} | ||
exports.groupBy = groupBy; | ||
//# sourceMappingURL=objectUtils.js.map |
{ | ||
"name": "knex-utils", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -44,2 +44,4 @@ # knex-utils | ||
* `groupBy(inputArray: T[], propName: string): Record<string, T>` - Creates an object composed of keys that are equal to the values of properties specified by `propName` in the original data. Values of that object's fields are arrays, filled with original objects from `inputArray`. | ||
* `isEmptyObject(params: Record<string, any>): boolean` - returns true, if object has only undefined properties. This is useful e. g. for optional update params, to determine whether whole operation can be skipped. For a full example see `pick` method. | ||
@@ -46,0 +48,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27924
284
123
0