1.0.0 • Published 1 year ago
@jhedblom/javascript-utilities v1.0.0
JavaScript Utilities
A library of utilities for String, Array, Number and Date classes.
version: 1.0.0
How to install:
npm install @jhedblom/javascript-utilities --save
How to use:
require("@jhedblom/javascript-utilities");
Run test:
npm test
String methods
// Capitalize the first letter of one word.
String.capitalizeFirstLetter();
// Capitalize the first letter of each word.
String.titleize();
// Checks if string is empty.
String.isEmpty();
// Finds string and extracts it.
String.extractWord(str);
// Print to console.
String.print(num);
Array methods
// Multiply each element
Array.times(num);
// Sums the total value
Array.sum();
// Finds element and removes it
Array.removeItem(element);
// Returns the last element
Array.last();
// Return the smallet element
Array.min();
// Return the biggest element
Array.max();
// Return a shuffle copy
Array.shuffle();
// Sorts elements alphabeticall
Array.sortAlphabeticall();
// Print to console.
Array.print(num);
Number methods
// Check if number is even
Number.isEven();
// Check if number is odd
Number.isOdd();
Date methods
// Returns the current date (year-month-day)
Date.getCurrentDate();
// Returns the current weekday
Date.getCurrentWeekday();
// Returns the current month
Date.getCurrentMonth();
// Returns the weekday from date input
Date.whatWeekday();
// Returns the month from date input
Date.whatMonth();
1.0.0
1 year ago