Helper is a collection of utility functions for common tasks such as string manipulation, array/object merging, and date/time formatting. It can be used in both Node.js and browser environments.
You can install the library via npm:
npm install github:tam11a/helper
Reverses the given string.
In TypeScript:
import * as helper from "helper";
console.log(helper.stringHelpers.reverse("hello")); // Output: 'olleh'
In JavaScript:
const helper = require("helper");
console.log(helper.stringHelpers.reverse("hello")); // Output: 'olleh'
Counts the number of occurrences of a substring within a string.
import * as helper from "helper";
console.log(helper.stringHelpers.count_substring("hello world hello", "hello")); // Output: 2
Deeply merges two objects.
import * as helper from "helper";
const obj1 = { a: { b: 1 }, c: 2 };
const obj2 = { a: { d: 3 }, e: 4 };
console.log(helper.arrayObjectHelpers.deep_merge(obj1, obj2)); // Output: { a: { b: 1, d: 3 }, c: 2, e: 4 }
Formats a given date object and converts it to the specified timezone.
import * as helper from "helper";
const date = new Date();
console.log(helper.dateTimeHelpers.format(date, "America/New_York")); // Output: '3/11/2024, 2:30:00 PM'