1.0.5-LTS-d • Published 3 months ago

node-helper-function v1.0.5-LTS-d

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Node Helper Function

Introducing "Node Helper Function" – Your Ultimate Developer Companion!

Node Helper Function is a versatile npm package designed to empower developers by simplifying complex tasks and enhancing productivity. Packed with a robust collection of meticulously crafted helper functions, Node Helper Function streamlines various functionalities, enabling developers to achieve more with less effort. No matter the node version of your project it works with all.

Click here to give any suggestions or report an issue

NOTE: This package has been depricated and is moved to new npm package node-simplify

Getting started

Installation

npm i node-helper-function

Date Helper function

The "DateHelper" function is a versatile utility that streamlines working with dates in programming. It provides an array of formatting, comparison, and manipulation. By simplifying complex temporal operations, this function enhances efficiency and accuracy in date-related programming tasks.

Options:
ParameterRequiredDefault
Date ObjectYesCurrent date time
Format StringYesy-m-d H:i:s
Available format charecter:
Format CharacterDescriptionExample returned values
Day------
dDay of the month, 2 digits with leading zeros01 to 31
DA textual representation of a day, three lettersMon through Sun
jDay of the month without leading zeros1 to 31
l (lowercase 'L')A full textual representation of the day of the weekSunday through Saturday
Month------
FA full textual representation of a month, such as January or MarchJanuary through December
mNumeric representation of a month, with leading zeros01 through 12
MA short textual representation of a month, three lettersJan through Dec
nNumeric representation of a month, without leading zeros1 through 12
Year------
YA full numeric representation of a year, at least 4 digits, with - for years BCE.Examples: 2022, 2023
yA two digit representation of a yearExamples: 99 or 03
Time------
aLowercase Ante meridiem and Post meridiemam or pm
AUppercase Ante meridiem and Post meridiemAM or PM
g12-hour format of an hour without leading zeros1 through 12
G24-hour format of an hour without leading zeros0 through 23
h12-hour format of an hour with leading zeros01 through 12
H24-hour format of an hour with leading zeros00 through 23
iMinutes with leading zeros00 to 59
sSeconds with leading zeros00 through 59

Example:
import DateHelper from 'node-helper-function/Helper/DateHelper';
<!-- OR -->
import { DateHelper } from 'node-helper-function';

DateHelper(new Date(), 'Y-m-d H:i:s'); // 2023-08-15 15:25:00

Convert Time To 12 Hour format

The "ConvertTimeTo12HourFormat" function is a useful tool for transforming a given time value from the standard 24-hour format to the more familiar 12-hour format. This function takes a time input and returns the corresponding time in the AM/PM notation, making it easier for users to interpret and display time in a more user-friendly manner.

Options:
ParameterRequired
Time StringYes
Example:
import ConvertTimeTo12Hour from 'node-helper-function/Helper/ConvertTimeTo12Hour';
<!-- OR -->
import { ConvertTimeTo12Hour } from 'node-helper-function';

ConvertTimeTo12Hour('13:30'); // 01:30 PM
ConvertTimeTo12Hour('15:30'); // 03:30 PM

Generate Hours

The "GenerateHours" function is a practical tool designed to create a range or list of hours based on specific criteria. This function enables the automated generation of hour values, which can be useful in scenarios like scheduling, time-based calculations, or data visualization. By utilizing the "GenerateHours" function, developers can save time and effort when creating hour sequences for various programming tasks.

Options:
ParameterRequiredDefault
Time IntervalYes10
Example:
import GenerateHours from 'node-helper-function/Helper/GenerateHours';
<!-- OR -->
import { GenerateHours } from 'node-helper-function';

GenerateHours(10); // ['00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30', '01:40', ...]

File to base64 string

The "GetBase64" function is a convenient utility that converts a given data input, such as files into its corresponding Base64 encoded format. This function is valuable for scenarios involving data transmission, storage, or manipulation, as Base64 encoding ensures data integrity and compatibility across different systems. By utilizing the "GetBase64" function, developers can seamlessly incorporate Base64 encoding into their applications, facilitating smooth data handling processes.

Options:
ParameterRequired
File ObjectYes
Example:
import GetBase64 from 'node-helper-function/Helper/GetBase64';
<!-- OR -->
import { GetBase64 } from 'node-helper-function';
const handleFileChange = (event) => {
    const file = event.target.files[0];
    const base64Data = await GetBase64(file);
}; // data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==

Calculate distance in KM with latitude and longitude

The "GetDistanceFromLatLonInKm" function is a practical tool for calculating the distance between two geographical points on the Earth's surface using their latitude and longitude coordinates. By providing these coordinates as inputs, the function returns the distance between the points in kilometers. This function is particularly useful in applications involving location-based services, mapping, and navigation, where accurate distance calculations are essential for making informed decisions.

Options:
ParameterRequired
Starting LatitudeYes
Starting LongitudeYes
Ending LatitudeYes
Ending LongitudeYes
Example:
    import GetDistanceFromLatLonInKm from 'node-helper-function/Helper/GetDistanceFromLatLonInKm';
    <!-- OR -->
    import { GetDistanceFromLatLonInKm } from 'node-helper-function';

    GetDistanceFromLatLonInKm('24.8607', '67.0011', '24.8607', '67.0012') // 0.01

Get Last N Years

The "GetLastNYears" function is a useful utility designed to retrieve a list of the most recent "N" years, based on the current date. This function allows you to specify the number of years you're interested in, and it generates a collection of year values that represent the past "N" years. This function is valuable for tasks like data filtering, trend analysis, or generating dynamic date ranges in applications where working with recent years is relevant.

Options:
ParameterRequiredDefault Value
NumberYes10
Example:
    import GetLastNYears from 'node-helper-function/Helper/GetLastNYears';
    <!-- OR -->
    import { GetLastNYears } from 'node-helper-function';

    GetLastNYears(10) // [2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014]
1.0.5-LTS-d

3 months ago

1.0.5-LTS

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago