asset-depreciation-calculator
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
export declare type Result = { | ||
declare type DepreciationResult = { | ||
year: number; | ||
@@ -9,3 +9,8 @@ depreciationMonths: number; | ||
}; | ||
declare const calculateDepreciation: (purchaseAmount: number, purchaseDate: string, totalDepreciationYears: number) => Result[]; | ||
declare type DepreciationInputs = { | ||
purchaseAmount: number; | ||
purchaseDate: Date; | ||
totalDepreciationYears: number; | ||
}; | ||
declare const calculateDepreciation: ({ purchaseAmount, purchaseDate, totalDepreciationYears, }: DepreciationInputs) => DepreciationResult[]; | ||
export default calculateDepreciation; |
@@ -10,7 +10,2 @@ "use strict"; | ||
}; | ||
const assertPurchaseDate = (dateString) => { | ||
if (isNaN(new Date(dateString).valueOf())) { | ||
throw new TypeError('`purchaseDate` is invalid.'); | ||
} | ||
}; | ||
const assertDepreciationYears = (years) => { | ||
@@ -33,5 +28,4 @@ if (years < 1) { | ||
}; | ||
const calculateDepreciation = (purchaseAmount, purchaseDate, totalDepreciationYears) => { | ||
const calculateDepreciation = ({ purchaseAmount, purchaseDate, totalDepreciationYears, }) => { | ||
assertPurchaseAmount(purchaseAmount); | ||
assertPurchaseDate(purchaseDate); | ||
assertDepreciationYears(totalDepreciationYears); | ||
@@ -38,0 +32,0 @@ const purchaseMonth = new Date(purchaseDate).getMonth() + 1; |
{ | ||
"name": "asset-depreciation-calculator", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Asset Depreciation Calculator", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -16,7 +16,7 @@ # asset-depreciation-calculator | ||
calculateDepreciation( | ||
20000, | ||
"2016-08-01", | ||
5, | ||
) | ||
calculateDepreciation({ | ||
purchaseAmount: 20000, | ||
purchaseDate: new Date("2016-08-01"), | ||
totalDepreciationYears: 5, | ||
}) | ||
// => [{ | ||
@@ -69,3 +69,3 @@ // year: 2016, | ||
### calculateDepreciation(purchaseAmount, purchaseDate, totalDepreciationYears) | ||
### calculateDepreciation({ purchaseAmount, purchaseDate, totalDepreciationYears }) | ||
@@ -78,3 +78,3 @@ #### purchaseAmount | ||
Type: `string` - should be a correct date string. For example: "2016-08-01" | ||
Type: `Date` | ||
@@ -81,0 +81,0 @@ #### totalDepreciationYears |
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
9670
84