New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rh-support/utils

Package Overview
Dependencies
Maintainers
9
Versions
339
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rh-support/utils - npm Package Compare versions

Comparing version 2.1.10 to 2.1.11-beta.0

1

lib/cjs/dateUtils.d.ts

@@ -14,3 +14,4 @@ import moment from 'moment-timezone';

export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
export {};
//# sourceMappingURL=dateUtils.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
exports.trafficSplit = exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
const moment_timezone_1 = __importDefault(require("moment-timezone"));

@@ -58,1 +58,25 @@ const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {

exports.addDaysToDate = addDaysToDate;
// split traffic based on time and weight
// for example, if testVariationWeight is 2 and the current time in milliseconds modulo 10 is less than 2,
// redirect to test version (20% of the time), else redirect to control version (80% of the time)
// @wieght: a number between 0 and 10
// @dateString: date string
const trafficSplit = (testVariationWeight, dateString) => {
if (testVariationWeight === 10)
return 'A'; // test
if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
return 'B'; // control
const date = new Date(dateString);
const milliseconds = date.getTime();
const totalWeight = 10;
// calculate the modulo based on the total weight
const moduloResult = milliseconds % totalWeight;
// redirect traffic based on the calculated modulo
if (moduloResult < testVariationWeight) {
return 'A';
}
else {
return 'B';
}
};
exports.trafficSplit = trafficSplit;

4

lib/cjs/hydraConfigUtils.d.ts

@@ -7,3 +7,5 @@ import { IMaintenance } from '@cee-eng/hydrajs/@types/models/maintenance';

FEATURE_FLAG = "FEATURE-FLAG",
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED"
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED",
STRING = "STRING",
NUMBER = "NUMBER"
}

@@ -10,0 +12,0 @@ declare function getConfigField(config: IMaintenance[], fieldName: string, fieldType?: PCM_CONFIG_FIELD_TYPE): any;

@@ -19,2 +19,4 @@ "use strict";

PCM_CONFIG_FIELD_TYPE["STRING_COMMA_SEPERATED"] = "STRING-COMMA-SEPERATED";
PCM_CONFIG_FIELD_TYPE["STRING"] = "STRING";
PCM_CONFIG_FIELD_TYPE["NUMBER"] = "NUMBER";
})(PCM_CONFIG_FIELD_TYPE = exports.PCM_CONFIG_FIELD_TYPE || (exports.PCM_CONFIG_FIELD_TYPE = {}));

@@ -25,2 +27,8 @@ function getConfigField(config, fieldName, fieldType = null) {

}, []);
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.STRING) {
return values[0];
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.NUMBER) {
return parseInt(values[0], 10);
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG) {

@@ -27,0 +35,0 @@ return values.length === 0 ? false : Boolean(parseInt(values[0]));

@@ -32,3 +32,5 @@ "use strict";

// when we are uploading a file before adding issue summary no highlighting doc is present hence passing an empty object
const highlightObj = highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {};
const highlightObj = highlighting
? highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {}
: {};
return Object.assign(Object.assign({}, doc), { abstract: (highlightObj.abstract && highlightObj.abstract[0]) || doc.abstract || '', publishedAbstract: (highlightObj.publishedAbstract && highlightObj.publishedAbstract[0]) || doc.publishedAbstract || '', issue: highlightObj.issue || doc.issue || [] });

@@ -35,0 +37,0 @@ });

@@ -39,2 +39,3 @@ import { ISearchSolrQuery } from '@cee-eng/hydrajs/@types/api/search';

'facet.mincount'?: string;
rerank?: boolean;
q?: string;

@@ -41,0 +42,0 @@ start?: number;

@@ -14,3 +14,4 @@ import moment from 'moment-timezone';

export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
export {};
//# sourceMappingURL=dateUtils.d.ts.map

@@ -43,1 +43,24 @@ import moment from 'moment-timezone';

};
// split traffic based on time and weight
// for example, if testVariationWeight is 2 and the current time in milliseconds modulo 10 is less than 2,
// redirect to test version (20% of the time), else redirect to control version (80% of the time)
// @wieght: a number between 0 and 10
// @dateString: date string
export const trafficSplit = (testVariationWeight, dateString) => {
if (testVariationWeight === 10)
return 'A'; // test
if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
return 'B'; // control
const date = new Date(dateString);
const milliseconds = date.getTime();
const totalWeight = 10;
// calculate the modulo based on the total weight
const moduloResult = milliseconds % totalWeight;
// redirect traffic based on the calculated modulo
if (moduloResult < testVariationWeight) {
return 'A';
}
else {
return 'B';
}
};

@@ -7,3 +7,5 @@ import { IMaintenance } from '@cee-eng/hydrajs/@types/models/maintenance';

FEATURE_FLAG = "FEATURE-FLAG",
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED"
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED",
STRING = "STRING",
NUMBER = "NUMBER"
}

@@ -10,0 +12,0 @@ declare function getConfigField(config: IMaintenance[], fieldName: string, fieldType?: PCM_CONFIG_FIELD_TYPE): any;

@@ -13,2 +13,4 @@ import concat from 'lodash/concat';

PCM_CONFIG_FIELD_TYPE["STRING_COMMA_SEPERATED"] = "STRING-COMMA-SEPERATED";
PCM_CONFIG_FIELD_TYPE["STRING"] = "STRING";
PCM_CONFIG_FIELD_TYPE["NUMBER"] = "NUMBER";
})(PCM_CONFIG_FIELD_TYPE || (PCM_CONFIG_FIELD_TYPE = {}));

@@ -19,2 +21,8 @@ function getConfigField(config, fieldName, fieldType = null) {

}, []);
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.STRING) {
return values[0];
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.NUMBER) {
return parseInt(values[0], 10);
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG) {

@@ -21,0 +29,0 @@ return values.length === 0 ? false : Boolean(parseInt(values[0]));

@@ -22,3 +22,5 @@ import DOMPurify from 'dompurify';

// when we are uploading a file before adding issue summary no highlighting doc is present hence passing an empty object
const highlightObj = highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {};
const highlightObj = highlighting
? highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {}
: {};
return Object.assign(Object.assign({}, doc), { abstract: (highlightObj.abstract && highlightObj.abstract[0]) || doc.abstract || '', publishedAbstract: (highlightObj.publishedAbstract && highlightObj.publishedAbstract[0]) || doc.publishedAbstract || '', issue: highlightObj.issue || doc.issue || [] });

@@ -25,0 +27,0 @@ });

@@ -39,2 +39,3 @@ import { ISearchSolrQuery } from '@cee-eng/hydrajs/@types/api/search';

'facet.mincount'?: string;
rerank?: boolean;
q?: string;

@@ -41,0 +42,0 @@ start?: number;

{
"name": "@rh-support/utils",
"version": "2.1.10",
"version": "2.1.11-beta.0",
"description": "> TODO: description",

@@ -48,3 +48,3 @@ "author": "Vikas Rathee <vrathee@redhat.com>",

"peerDependencies": {
"@cee-eng/hydrajs": "4.16.21",
"@cee-eng/hydrajs": "4.16.43",
"@cee-eng/ui-toolkit": "1.1.6",

@@ -63,3 +63,3 @@ "dompurify": "^2.2.6",

"dependencies": {
"@cee-eng/hydrajs": "4.16.21",
"@cee-eng/hydrajs": "4.16.43",
"@cee-eng/ui-toolkit": "1.1.6",

@@ -93,3 +93,3 @@ "@rh-support/types": "2.0.2",

],
"gitHead": "b06b0e176b4f9016ce2aed18be239150c05d65c6"
"gitHead": "3d67f1bfd743fabfd0a606cf56ea4bf48d91daa2"
}

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

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

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