@iot-app-kit/core
Advanced tools
Comparing version 9.1.0 to 9.2.0
@@ -25,2 +25,20 @@ "use strict"; | ||
exports.subtractIntervals = subtractIntervals; | ||
// removes duplicates (by timestamp) in a data (Datapoint[][]) | ||
const uniqByKeepLast = (data, key) => { | ||
return data.map((datum) => { | ||
if (Array.isArray(datum)) { | ||
return [ | ||
...new Map(datum.map((d, index) => { | ||
if (typeof d === 'object' && !!d) { | ||
return [d[key], d]; | ||
} | ||
return [index, d]; | ||
})).values(), | ||
]; | ||
} | ||
else { | ||
return datum; | ||
} | ||
}); | ||
}; | ||
/** | ||
@@ -89,7 +107,9 @@ * Merges together to lists of items given a way to compare items. | ||
updatedItems.splice(insertIndex, overlappingIntervals.length, combinedItems); | ||
// removing duplicate timestamps in an interval | ||
const updatedItemsUniqueByTimestamp = uniqByKeepLast(updatedItems, 'x'); | ||
return { | ||
intervals: updatedIntervals, | ||
items: updatedItems, | ||
items: updatedItemsUniqueByTimestamp, | ||
}; | ||
}; | ||
exports.addInterval = addInterval; |
@@ -43,2 +43,3 @@ import { AggregateType } from '@aws-sdk/client-iotsitewise'; | ||
}) => RequestInformationAndRange[]; | ||
export declare const dataPointCompare: <T extends Primitive = number>(a: DataPoint<T>, b: DataPoint<T>) => number; | ||
export declare const EMPTY_CACHE: IntervalStructure<DataPoint<Primitive>>; | ||
@@ -45,0 +46,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.maxCacheDuration = exports.validateRequestConfig = exports.checkCacheForRecentPoint = exports.addToDataPointCache = exports.createDataPointCache = exports.EMPTY_CACHE = exports.getRequestInformations = exports.getDateRangesToRequest = exports.unexpiredCacheIntervals = void 0; | ||
exports.maxCacheDuration = exports.validateRequestConfig = exports.checkCacheForRecentPoint = exports.addToDataPointCache = exports.createDataPointCache = exports.EMPTY_CACHE = exports.dataPointCompare = exports.getRequestInformations = exports.getDateRangesToRequest = exports.unexpiredCacheIntervals = void 0; | ||
const time_1 = require("../../../common/time"); | ||
@@ -170,2 +170,3 @@ const getDataStreamStore_1 = require("../getDataStreamStore"); | ||
}; | ||
exports.dataPointCompare = dataPointCompare; | ||
exports.EMPTY_CACHE = { | ||
@@ -184,3 +185,3 @@ intervals: [], | ||
} | ||
return (0, intervalStructure_1.addInterval)(cache, [start.getTime(), end.getTime()], data, dataPointCompare); | ||
return (0, intervalStructure_1.addInterval)(cache, [start.getTime(), end.getTime()], data, exports.dataPointCompare); | ||
}; | ||
@@ -187,0 +188,0 @@ exports.addToDataPointCache = addToDataPointCache; |
@@ -19,2 +19,20 @@ import { simplify, substract, intersect as intersectFn } from 'intervals-fn'; | ||
}; | ||
// removes duplicates (by timestamp) in a data (Datapoint[][]) | ||
const uniqByKeepLast = (data, key) => { | ||
return data.map((datum) => { | ||
if (Array.isArray(datum)) { | ||
return [ | ||
...new Map(datum.map((d, index) => { | ||
if (typeof d === 'object' && !!d) { | ||
return [d[key], d]; | ||
} | ||
return [index, d]; | ||
})).values(), | ||
]; | ||
} | ||
else { | ||
return datum; | ||
} | ||
}); | ||
}; | ||
/** | ||
@@ -82,6 +100,8 @@ * Merges together to lists of items given a way to compare items. | ||
updatedItems.splice(insertIndex, overlappingIntervals.length, combinedItems); | ||
// removing duplicate timestamps in an interval | ||
const updatedItemsUniqueByTimestamp = uniqByKeepLast(updatedItems, 'x'); | ||
return { | ||
intervals: updatedIntervals, | ||
items: updatedItems, | ||
items: updatedItemsUniqueByTimestamp, | ||
}; | ||
}; |
@@ -43,2 +43,3 @@ import { AggregateType } from '@aws-sdk/client-iotsitewise'; | ||
}) => RequestInformationAndRange[]; | ||
export declare const dataPointCompare: <T extends Primitive = number>(a: DataPoint<T>, b: DataPoint<T>) => number; | ||
export declare const EMPTY_CACHE: IntervalStructure<DataPoint<Primitive>>; | ||
@@ -45,0 +46,0 @@ /** |
@@ -145,3 +145,3 @@ import { MINUTE_IN_MS, SECOND_IN_MS, parseDuration } from '../../../common/time'; | ||
}; | ||
const dataPointCompare = (a, b) => { | ||
export const dataPointCompare = (a, b) => { | ||
const aTime = a.x; | ||
@@ -148,0 +148,0 @@ const bTime = b.x; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "9.1.0", | ||
"version": "9.2.0", | ||
"description": "IoT Application Kit core", | ||
@@ -63,8 +63,8 @@ "main": "./dist/cjs/index.js", | ||
"devDependencies": { | ||
"@iot-app-kit/jest-config": "9.1.0", | ||
"@iot-app-kit/ts-config": "9.1.0", | ||
"@iot-app-kit/jest-config": "9.2.0", | ||
"@iot-app-kit/ts-config": "9.2.0", | ||
"@types/d3-array": "^3.0.5", | ||
"@types/jest": "^29.4.0", | ||
"@types/uuid": "^9.0.2", | ||
"eslint-config-iot-app-kit": "9.1.0", | ||
"eslint-config-iot-app-kit": "9.2.0", | ||
"flush-promises": "^1.0.2", | ||
@@ -71,0 +71,0 @@ "jest": "^29.5.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
345598
5060