1.3.3 • Published 2 years ago

useful-library v1.3.3

Weekly downloads
37
License
MIT
Repository
github
Last release
2 years ago

containsOnly()

/**
 * Return true if an array contains only certain elements.
 *
 * @param  {object} arr An array object to check
 * @param  {function} func A function that performs the check
 */

dateAsISO()

/**
 * Returns the date portion of Date, e.g. "2022-06-12"
 *
 * @param  {Date} date
 */

first()

/**
 * Return the first element of an array.
 *
 * @param  {object} arr
 */

formatDay()

/**
 * Return day formatted as DD.
 *
 * @param  {object} day Date object.
 */

formatMonth()

/**
 * Return MM indexed from 1 as string.
 *
 * @param  {object} month Date object.
 */

formatString()

/**
 * Return a formatted string.
 *
 * @param  {object} configObj Three properties are mandatory:
 *  string       - an input string;
 *  positions    - an array of numbers that represent indices;
 *  insertedChar - a characted to insert at positions
 */

getConnectionString()

/**
 * Return connection string for MSSQL DB.
 *
 * @param  {object} infoObj Object with user, password, server, and database
 *  properties.
 */

getEnv()

/**
 * Return value from an env variable.
 *
 * @param  {string} envVarName Env variable name.
 */

getEnvWithoutLang()

/**
 * Return environment part of a string ('dev-cz' => 'dev').
 *
 * @param  {string} envVarName Env variable name.
 */

getLang()

/**
 * Return language part of a string ('dev-cz' => 'cz').
 *
 * @param  {string} envVarName Env variable name.
 */

isEqual()

/**
 * Return true if given arrays are equal, e.i. have the same members in the
 * same order.
 *
 * @param  {object} arr
 * @param  {object} arr1
 */

isStrictlyEqual()

/**
 * Return true if given arrays are strictly equal, e.i. have the same members
 * in the same order.
 * @param  {object} arr
 * @param  {object} arr1
 */

last()

/**
 * Return the last element of an array.
 *
 * @param  {object} arr
 */

loadJsonFile()

/**
 * Synchronously reads and parses a JSON file.
 *
 * @param  {string} filename
 * @return {object} Parsed JSON file as an object literal.
 */

loadYamlFile()

/**
 * Synchronously reads and parses a YAML file.
 *
 * @param  {string} filename
 * @return {object} Parsed YAML file as an object literal.
 */

max()

/**
 * Return maximum value from an array.
 *
 * @param  {object} arr
 */

merge()

/**
 * Merge two objects.
 *
 * @param  {object} obj
 * @param  {object} obj1
 */

min()

/**
 * Return minimum value from an array.
 *
 * @param  {object} arr
 */

nth()

/**
 * Return nth element of an array.
 *
 * @param  {object} arr
 * @param  {number} nthEl Default to 0.
 * @param  {number} indexStyle Indexing, either start with 0 or 1. Default to 0.
 */

pastYyyyMmDd()

/**
 * Return past date in YYYY{{separator}}MM{{separator}}DD.
 *
 * @param  {string} separator Default '/'.
 * @param  {number} daysAgo Default 1.
 */

randInt()

/**
 * Return a random integer between min and max inclusive.
 *
 * @param  {number} min
 * @param  {number} max
 */

randomEmail()

/**
 * Generate random email. If len is 0, the part before '@' will be
 * missing. If domainStr is '', no domain will be included.
 *
 * @param  {number} len Default 10.
 * @param  {string} domainStr Default USEFUL_DEFAULT_DOMAIN env variable
 *  or "inveo.cz".
 */

randomNumberString()

/**
 * Generate random number string. If alphabetString is not passed,
 * only [0-9] is a considered alphabet.
 *
 * @param  {number} len Default 10.
 * @param  {string} alphabetString Default [0-9].
 */

randomString()

/**
 * Generate random string. If alphabetString is not passed,
 * only [a-zA-Z] is a considered alphabet.
 *
 * @param  {number} len Default 10.
 * @param  {string} alphabetString Default [a-zA-Z].
 */

sortAsc()

/**
 * Return a sorted (asc) array clone.
 *
 * Sorting does not happen in place. Numeric sorting is performed.
 *
 * @param  {object} arr
 */

sortDesc()

/**
 * Return a sorted (desc) array clone.
 *
 * Sorting does not happen in place. Numeric sorting is performed.
 *
 * @param  {object} arr
 */

unix()

/**
 * Return unit timestamp.
 *
 */

yyyyMmDd()

/**
 * Return current date in YYYY{{separator}}MM{{separator}}DD.
 *
 * @param  {string} separator Default '/'.
 */
1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.3.3

2 years ago

1.2.4

2 years ago

1.3.2

2 years ago

1.2.3

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago