kolbeinsson-utility

1.1.7 • Public • Published

What is it

Utility package that gives you access to a vast array of utility functions

Getting started

yarn add --dev kolbeinsson-utility

Example use

import { arraySize } from 'kolbeinsson-utility';
 
console.log(arraySize(["One", "Two", "Three"])); 
 
// output --> 2
 
 
 
 
 
/*
    Other examples:
 
 
    // Dates
    getCurrentTime();
    getCurrentTimeISOStandart();
    parseDateToTime(new Date(96, 2, 2, 2, 2, 2));
    parseDateToDate(new Date(96, 2, 2, 2, 2, 2));
    getMonthFromDate(getCurrentTime());
    getYearFromDate(getCurrentTime());
    getDayFromDate(getCurrentTime());
    getHoursFromDate(getCurrentTime());
    dateToLocaleString(new Date(92,2,2,2,2,2), 'en-US');
    getForeignLocaleTimeNow('en-US');
    
    // Arrays
    arraySize(["One", "Two", "Three"]);
    arrayfind(["One", "Two", "Three"], "Three");
    arrayAdd(["One", "Two", "Three"], "Adding");
    arrayEmpty([]);
    arrayEmpty(["One", "Two", "Three"]);
    arraySize(["One", "Two"]);
    filterNumbersArray(["1", 2, 3, 4]);
    filterStringArray(["1", 2, 3, 4]);
    objectValuesToArray({ name: 'John Doe', year: '1992' });
    objectKeysToArray({ name: 'John Doe', year: '1992' });
    flattenArray(["one", "two", ["three", "four", ["five", "six"]]]);
    removeValueFromArray(["one", "two", "three", "four", "five", "six"], "six");
    removeIndexFromArray(["one", "two", "three", "four", "five", "six"], 5);
    
    // Map
    createMapFromObjectArray([{ keyOne: 'First', KeyTwo: 'Second', KeyThree: 1, keyFour: true }]);
 
    // Objects
    mapObjectKeys({ name: 'John Doe', year: '1992' });
    mapObjectValues({ name: 'John Doe', year: '1992' });
    objectTypeCheck({ name: 'John Doe', year: '1992' });
 
    // Strings
    searchStr("this", "String does actually contain this and should return true at this point.");
    trimStr("Here is a term you should notice       ");
    trimStr("             Here is a term you should notice. Congratulations. Dont thank me.      ");
    stringTypeCheck("Strring");
 
    // Numbers
    numberTypeCheck(234);
    numberPositive(234);
*/
 

Package Sidebar

Install

npm i kolbeinsson-utility

Weekly Downloads

1

Version

1.1.7

License

ISC

Unpacked Size

15.3 kB

Total Files

5

Last publish

Collaborators

  • kolbeinsson88