-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #342 from swrlab/dev/string-utils-update
Add more string utils
- Loading branch information
Showing
15 changed files
with
239 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
// import packages | ||
const getObjectLength = require('../../utils/strings/getObjectLength') | ||
const isArray = require('../../utils/strings/isArray') | ||
const isEmptyArray = require('../../utils/strings/isEmptyArray') | ||
const isEmptyObject = require('../../utils/strings/isEmptyObject') | ||
const isIncluded = require('../../utils/strings/isIncluded') | ||
const isNull = require('../../utils/strings/isNull') | ||
const isObject = require('../../utils/strings/isObject') | ||
const isUndefined = require('../../utils/strings/isUndefined') | ||
const notEmptyArray = require('../../utils/strings/notEmptyArray') | ||
const notEmptyObject = require('../../utils/strings/notEmptyObject') | ||
const notNullOrUndefined = require('../../utils/strings/notNullOrUndefined') | ||
const removeDoubleSpaces = require('../../utils/strings/removeDoubleSpaces') | ||
const toHex = require('../../utils/strings/toHex') | ||
|
||
// export packages | ||
module.exports = { | ||
getObjectLength, | ||
isArray, | ||
isEmptyArray, | ||
isEmptyObject, | ||
isIncluded, | ||
isNull, | ||
isObject, | ||
isUndefined, | ||
notEmptyArray, | ||
notEmptyObject, | ||
notNullOrUndefined, | ||
removeDoubleSpaces, | ||
toHex, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// get the length (count of keys) of an object | ||
module.exports = (value) => value && Object.keys(value).length |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
const notNullOrUndefined = require('./notNullOrUndefined') | ||
|
||
// check if a variable is really an array | ||
module.exports = (value) => !!(value instanceof Array) | ||
module.exports = (value) => notNullOrUndefined(value) && value instanceof Array |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const isArray = require('./isArray') | ||
|
||
// check if a variable is an empty array | ||
module.exports = (value) => isArray(value) && value.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const isObject = require('./isObject') | ||
const getObjectLength = require('./getObjectLength') | ||
|
||
// check if a variable is an empty object | ||
module.exports = (value) => isObject(value) && getObjectLength(value) === 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// check if a variable is null | ||
module.exports = (value) => value === null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// import utils | ||
const isArray = require('./isArray') | ||
const notNullOrUndefined = require('./notNullOrUndefined') | ||
|
||
// check if a variable is really an object | ||
module.exports = (value) => value instanceof Object && !isArray(value) | ||
module.exports = (value) => notNullOrUndefined(value) && value instanceof Object && !isArray(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// check if a variable is undefined | ||
module.exports = (value) => value === undefined |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const isArray = require('./isArray') | ||
|
||
// check if a variable is an empty array | ||
module.exports = (value) => isArray(value) && value.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const isObject = require('./isObject') | ||
const getObjectLength = require('./getObjectLength') | ||
|
||
// check if a variable is an empty object | ||
module.exports = (value) => isObject(value) && getObjectLength(value) > 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const isNull = require('./isNull') | ||
const isUndefined = require('./isUndefined') | ||
|
||
// check if a variable is neither null nor undefined | ||
module.exports = (value) => !isNull(value) && !isUndefined(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