Socket
Socket
Sign inDemoInstall

@homebound/activesupport

Package Overview
Dependencies
Maintainers
39
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@homebound/activesupport - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2

28

dist/index.d.ts

@@ -179,2 +179,28 @@ type KeysOfType<T, TProp> = {

/**
* @name subBusinessDays
* @category Day Helpers
* @summary Substract the specified number of business days (mon - fri) to the given date.
*
* @description
* Substract the specified number of business days (mon - fri) to the given date, ignoring weekends.
*
* @param {Date|Number} date - the date to be changed
* @param {Number} amount - the amount of business days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param {Object} [options] - an object with options.
* @param {Number[]} [options.businessDays=[1, 2, 3, 4, 5]] - the business days. default is Monday to Friday.
* @param {Record<string, boolean>} [options.exceptions={}] - exceptions to the business days. Map of date string (with format "MM/DD/YY") to boolean.
* @returns {Date} the new date with the business days subtracted
* @throws {TypeError} 2 arguments required
* @throws {RangeError} businessDays cannot include numbers greater than 6
*
* @example
* // Substract 10 business days from 1 September 2014:
* const result = subBusinessDays(new Date(2014, 8, 1), 10)
* //=> Mon Aug 18 2014 00:00:00 (skipped weekend days)
*/
declare function subBusinessDays(dirtyDate: Date | number, dirtyAmount: number, dirtyOptions?: {
businessDays?: number[];
exceptions?: Record<string, boolean>;
}): Date;
/**
* @name differenceInBusinessDays

@@ -257,2 +283,2 @@ * @category Day Helpers

export { KeysOfType, Sortable, addBusinessDays, differenceInBusinessDays };
export { KeysOfType, Sortable, addBusinessDays, differenceInBusinessDays, subBusinessDays };

@@ -24,3 +24,4 @@ "use strict";

addBusinessDays: () => addBusinessDays,
differenceInBusinessDays: () => differenceInBusinessDays
differenceInBusinessDays: () => differenceInBusinessDays,
subBusinessDays: () => subBusinessDays
});

@@ -304,2 +305,11 @@ module.exports = __toCommonJS(src_exports);

}
function subBusinessDays(dirtyDate, dirtyAmount, dirtyOptions) {
const options = dirtyOptions || {};
const businessDays = options.businessDays || [1, 2, 3, 4, 5];
const exceptions = options.exceptions || {};
if (businessDays?.filter((number) => number > 6).length > 0) {
throw new RangeError("business days must be between 0 and 6");
}
return addBusinessDays(dirtyDate, -dirtyAmount, { businessDays, exceptions });
}
function differenceInBusinessDays(dirtyDateLeft, dirtyDateRight, dirtyOptions) {

@@ -398,4 +408,5 @@ const options = dirtyOptions || {};

addBusinessDays,
differenceInBusinessDays
differenceInBusinessDays,
subBusinessDays
});
//# sourceMappingURL=index.js.map

2

package.json
{
"name": "@homebound/activesupport",
"version": "1.7.1",
"version": "1.7.2",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "module": "./dist/index.mjs",

@@ -118,3 +118,3 @@ import { addDays, differenceInCalendarDays, format, isAfter, isBefore, isSameDay, isValid, toDate } from "date-fns";

*/
export default function subBusinessDays(
export function subBusinessDays(
dirtyDate: Date | number,

@@ -121,0 +121,0 @@ dirtyAmount: number,

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