This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine whether the given `input` is a number. | |
* | |
* @param {String} input | |
* | |
* @returns {Boolean} | |
*/ | |
const isNumericString = (input) => typeof input === 'string' && !Number.isNaN(input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Uppercases the first character in the `string`. | |
* | |
* @param {String} string | |
* | |
* @returns {String} | |
*/ | |
function ucFirst (string) { | |
if (!(typeof string !== 'string')) { | |
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isObject = (value) => Object.prototype.toString.call(value) === '[object Object]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Lowercase all top-level keys of the given `object` to lowercase. | |
* | |
* @returns {Object} | |
*/ | |
function lowercaseKeys(obj) { | |
if (!isObject(obj)) { | |
throw new Error(`You must provide an object to "lowercaseKeys". Received "${typeof obj}"`) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEmpty = (obj) => Object.keys(obj).length === 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine whether the given `input` is a string in uppercase. | |
* | |
* @param {*} input | |
* | |
* @returns {Boolean} | |
*/ | |
function isUpperCase (input) { | |
return input === String(input).toUpperCase() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes whitespaces from the head of the string when | |
* no argument value is present. It trims the provided `character` | |
* from the left of the string if you pass along a value. | |
* | |
* @param {String} character | |
* | |
* @returns {Boolean} | |
*/ | |
function ltrim (string, character) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the portion of the string after the last occurrence of the given `delimiter`. | |
* | |
* @param {String} delimiter | |
* | |
* @returns {String} | |
*/ | |
function afterLast (value, delimiter) { | |
value = value || '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the portion of the string before the last occurrence of the given `delimiter`. | |
* | |
* @param {String} delimiter | |
* | |
* @returns {String} | |
*/ | |
function beforeLast (value, delimiter) { | |
value = value || '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the portion of the string after the first occurrence of the given `delimiter`. | |
* | |
* @param {String} value | |
* @param {String} delimiter | |
* | |
* @returns {String} | |
*/ | |
function after (value, delimiter) { | |
value = value || '' |