A collection of Javascript utilities that we use internally.
yarn add js-simple-utils
import { convertObjectToArray } from 'js-simple-utils';
const array = convertObjectToArray({ foo: { name: 'bar' } });
- addZeroPadding - Takes a number/string and adds 0 padding if necessary and returns a string
- cleanObject - Remove all falsy fields from an object
- cloneObject - Returns a copy of an object
- convertObjectToArray - Converts an object into an array, keeping the key (as id)
- countKeys - Counts an objects keys (nesting included)
- createUID - Creates a unique id
- firstCharToUpperCase - Converts the first character of a string to uppercase
- getDistanceBetweenCoordinates - Gets the distance between two sets of coordinates
- getElapsedDays - Get the amount of days that have elapsed since a timestamp
- getElapsedHours - Get the amount of hours (rounded) that have elapsed since a timestamp
- getHoursMinutes - Get the hours and minutes in the format HH:MM from a timestamp
- getPercentage - Takes two numbers and returns the percentage representation of them rounded
- getPrettyDate - Get date in a pretty format from a timestamp
- getRandomInt - Returns a random integer
- isEmptyObject - Checks if an object is empty and returns true or false
- reorderArrayItems - Reorders an item in an array
- sortArrayOfObjectsByKey - Sorts an array of objects by key with optional reverse order functionality
- stringToTitleCase - Convert a string to Title Case
- validateCellNumber - Validate South African cell phone numbers
- validateEmail - Validate email addresses
- validateIDNumber - Validate South African ID numbers
- Clone the project:
git clone https://github.com/AuxStudio/js-simple-utils
- Do some work.
- Create a PR.
- Run tests to make sure that they're passing.
yarn test
- Login to npm
npm login
- Run the publish script.
npm publish
- Fix export (use one object for both)