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

@nodeswork/utils

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodeswork/utils - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

16

dist/metrics/operators.d.ts

@@ -13,2 +13,7 @@ import { MetricsData, MetricsDimensions, MetricsValue, Operator } from './def';

projectMetricsData(data: MetricsData, options: MetricsProjectOptions): MetricsData;
filterMetricsDatasByValue(data: MetricsData[], filter: MetricsDataValueFilter): MetricsData[];
getDimensions(data: MetricsData, strict?: boolean): MetricsDimensions[];
getMetricsNames(data: MetricsData, strict?: boolean): string[];
filterMetricsDatas(data: MetricsData[], filter: MetricsDataFilter): MetricsData[];
filterMetricsData(data: MetricsData, filter: MetricsDataFilter): MetricsData;
mergeMetricsDataByTimeGranularity(datas: MetricsData[], granularityInSecond: number): MetricsData[];

@@ -30,2 +35,13 @@ mergeMetricsDataBy(datas: MetricsData[], func: (data: MetricsData) => string): MetricsData[];

}
export interface MetricsDataFilter {
(dimension: MetricsDimensions, name: string, value: MetricsValue<any>, data?: MetricsData): boolean;
}
export interface MetricsDataValueFilter {
dimensions: Array<{
name: string;
selectValues: any[];
omitValues: any[];
}>;
metrics: string[];
}
export declare const operator: MetricsOperator;

@@ -115,2 +115,63 @@ "use strict";

}
filterMetricsDatasByValue(data, filter) {
return this.filterMetricsDatas(data, (dimensions, name, value) => {
if (filter.metrics.indexOf(name) === -1) {
return false;
}
for (const dFilter of filter.dimensions) {
if (dFilter.selectValues.length > 0 &&
dFilter.selectValues.indexOf(dimensions[dFilter.name]) === -1) {
return false;
}
if (dFilter.omitValues.length > 0 &&
dFilter.omitValues.indexOf(dimensions[dFilter.name]) >= 0) {
return false;
}
}
return true;
});
}
getDimensions(data, strict = false) {
if (!strict) {
return Object.values(data.dimensions);
}
else {
const metrics = this.getMetricsNames(data);
return _.chain(metrics)
.map((name) => Object.keys(data.metrics[name]))
.flatten()
.uniq()
.map((dhash) => data.dimensions[dhash])
.value();
}
}
getMetricsNames(data, strict = false) {
if (!strict) {
return Object.keys(data.metrics);
}
else {
return _.filter(Object.keys(data.metrics), (n) => Object.keys(data.metrics[n]).length > 0);
}
}
filterMetricsDatas(data, filter) {
return _.filter(data, (d) => {
d = this.filterMetricsData(d, filter);
return this.getMetricsNames(d, true).length > 0;
});
}
filterMetricsData(data, filter) {
const dimensions = {};
const metrics = _.mapObject(data.metrics, (metrics, name) => {
const result = {};
_.each(metrics, (value, dhash) => {
const d = data.dimensions[dhash];
if (filter(d, name, value, data)) {
result[dhash] = value;
dimensions[dhash] = d;
}
});
return result;
});
return _.extend({}, data, { dimensions, metrics });
}
mergeMetricsDataByTimeGranularity(datas, granularityInSecond) {

@@ -117,0 +178,0 @@ const granularity = granularityInSecond * 1000;

2

package.json
{
"name": "@nodeswork/utils",
"version": "0.1.7",
"version": "0.1.8",
"description": "Utilities used across nodeswork repos.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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