doitfast is a collection of functions that can help you do it FAST .
getIntervalsBetweenShifts :
given the start & end time in 24Hr format this function will return an array of the times in between with interval of of 30 minutes as a default but it can be changes keeping in mind this format "hh:mm" & smaller than the difference between the shift duration
getIntervalsBetweenShifts(startTime,endTime,interval,isItToday?)
import { getIntervalsBetweenShifts, isItToday } from "doitfast";
let shifts = getIntervalsBetweenShifts("09:00", "17:00","00:30", isItToday(new Date()));
//isItToday is a function returns a boolean indicates if the input date is tody or not
// using today as a paramenter will remove the intervals before now,you can use any day instead of new Date() or you can simply input true/false
arrangDays :
simple function accepts an array of dates and arrange them accending or decending
import { arrangeDays } from "doitfast";
let arrangedDays = arrangeDays([
"5/22/2012",
"5/21/2012",
"5/20/2012",
new Date(),"accending"
]);
appendItem :
simple function to append values to keys helpful when sending api requests that upload images
import { appendItem } from "doitfast";
let data=formData()
let values={
name:"Max",
age:28,
//profile_photo:File i.e the uploaded file
}
Object.keys(values).forEach((key) => {
appendItem(data, key, values[key]);
});
calcDiscount is to caculate total price of a product depending on the quantity if more than one the price will be caculated for the discountPrice
calcDiscount (basePrice, discountPrice, quantity, minCharge)
import { calcDiscount } from "doitfast";
let totalPrice = calcDiscount(100, 50, 2, 10);
getCommonInArrays:
this simple function returns the common between any number of arrays
import { getCommonInArrays } from "doitfast";
let arr1=[1,2],
arr2=[2,3],
arr3=[5,6,2,3,1,7,5];
const common=getCommonInArrays(arr1,arr2,arr3) // 2
the package will be updated regularly