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

bundlemon-utils

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bundlemon-utils - npm Package Compare versions

Comparing version 0.2.0-rc.1 to 0.2.0-rc.2

17

lib/cjs/diffReport/index.js

@@ -33,14 +33,7 @@ "use strict";

const diffPercent = utils_1.getPercentageDiff((_c = currBranchFile === null || currBranchFile === void 0 ? void 0 : currBranchFile.size) !== null && _c !== void 0 ? _c : 0, (_d = baseBranchFile === null || baseBranchFile === void 0 ? void 0 : baseBranchFile.size) !== null && _d !== void 0 ? _d : 0);
let change = consts_1.DiffChange.NoChange;
if (currBranchFile && baseBranchFile) {
if (diffBytes) {
change = consts_1.DiffChange.Update;
}
}
else if (currBranchFile) {
change = consts_1.DiffChange.Add;
}
else if (baseBranchFile) {
change = consts_1.DiffChange.Remove;
}
const change = utils_1.calcChange({
isExistsInCurrBranch: !!currBranchFile,
isExistsInBaseBranch: !!baseBranchFile,
diffBytes,
});
const statusObj = utils_1.getStatusObject({ currBranchFile, change, diffPercent });

@@ -47,0 +40,0 @@ if (statusObj.status === consts_1.Status.Fail) {

import { DiffChange } from '../consts';
import type { FileDetails, FileStatusObject } from '../types';
export declare function getPercentageDiff(a: number, b: number): number;
interface CalcChangeParams {
isExistsInCurrBranch: boolean;
isExistsInBaseBranch: boolean;
diffBytes: number;
}
export declare function calcChange({ isExistsInCurrBranch, isExistsInBaseBranch, diffBytes }: CalcChangeParams): DiffChange;
interface GetStatusParams {

@@ -5,0 +11,0 @@ currBranchFile?: FileDetails;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStatusObject = exports.getPercentageDiff = void 0;
exports.getStatusObject = exports.calcChange = exports.getPercentageDiff = void 0;
const consts_1 = require("../consts");

@@ -14,2 +14,18 @@ function roundDecimals(num, decimals) {

exports.getPercentageDiff = getPercentageDiff;
function calcChange({ isExistsInCurrBranch, isExistsInBaseBranch, diffBytes }) {
if (isExistsInCurrBranch && isExistsInBaseBranch) {
// return update only if the change is greater than 10 bytes
if (Math.abs(diffBytes) > 10) {
return consts_1.DiffChange.Update;
}
else {
return consts_1.DiffChange.NoChange;
}
}
if (isExistsInCurrBranch) {
return consts_1.DiffChange.Add;
}
return consts_1.DiffChange.Remove;
}
exports.calcChange = calcChange;
function getStatusObject({ currBranchFile, change, diffPercent }) {

@@ -16,0 +32,0 @@ const failReasons = [];

@@ -1,3 +0,3 @@

import { DiffChange, Status } from '../consts';
import { getPercentageDiff, getStatusObject } from './utils';
import { Status } from '../consts';
import { calcChange, getPercentageDiff, getStatusObject } from './utils';
export function calcDiffFiles(currFiles, baseFiles = []) {

@@ -30,14 +30,7 @@ const filesMap = new Map();

const diffPercent = getPercentageDiff((_c = currBranchFile === null || currBranchFile === void 0 ? void 0 : currBranchFile.size) !== null && _c !== void 0 ? _c : 0, (_d = baseBranchFile === null || baseBranchFile === void 0 ? void 0 : baseBranchFile.size) !== null && _d !== void 0 ? _d : 0);
let change = DiffChange.NoChange;
if (currBranchFile && baseBranchFile) {
if (diffBytes) {
change = DiffChange.Update;
}
}
else if (currBranchFile) {
change = DiffChange.Add;
}
else if (baseBranchFile) {
change = DiffChange.Remove;
}
const change = calcChange({
isExistsInCurrBranch: !!currBranchFile,
isExistsInBaseBranch: !!baseBranchFile,
diffBytes,
});
const statusObj = getStatusObject({ currBranchFile, change, diffPercent });

@@ -44,0 +37,0 @@ if (statusObj.status === Status.Fail) {

import { DiffChange } from '../consts';
import type { FileDetails, FileStatusObject } from '../types';
export declare function getPercentageDiff(a: number, b: number): number;
interface CalcChangeParams {
isExistsInCurrBranch: boolean;
isExistsInBaseBranch: boolean;
diffBytes: number;
}
export declare function calcChange({ isExistsInCurrBranch, isExistsInBaseBranch, diffBytes }: CalcChangeParams): DiffChange;
interface GetStatusParams {

@@ -5,0 +11,0 @@ currBranchFile?: FileDetails;

@@ -10,2 +10,17 @@ import { DiffChange, Status, FailReason } from '../consts';

}
export function calcChange({ isExistsInCurrBranch, isExistsInBaseBranch, diffBytes }) {
if (isExistsInCurrBranch && isExistsInBaseBranch) {
// return update only if the change is greater than 10 bytes
if (Math.abs(diffBytes) > 10) {
return DiffChange.Update;
}
else {
return DiffChange.NoChange;
}
}
if (isExistsInCurrBranch) {
return DiffChange.Add;
}
return DiffChange.Remove;
}
export function getStatusObject({ currBranchFile, change, diffPercent }) {

@@ -12,0 +27,0 @@ const failReasons = [];

{
"name": "bundlemon-utils",
"version": "0.2.0-rc.1",
"version": "0.2.0-rc.2",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

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