Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
NPM Packages
js-type
Commits
072cdc6c
Commit
072cdc6c
authored
Feb 06, 2020
by
Milan Wikarski
Browse files
Divided is into is and force
parent
b33b349a
Changes
3
Hide whitespace changes
Inline
Side-by-side
index.js
View file @
072cdc6c
...
...
@@ -92,4 +92,9 @@ is.emptyString = _is.emptyString;
is
.
instance
=
_is
.
instance
;
module
.
exports
=
is
;
module
.
exports
=
{
is
,
force
:
{
array
:
require
(
'
./src/force-array
'
)
}
};
src/force-array.js
0 → 100644
View file @
072cdc6c
/**
* Returns val if val is array; [val] otherwise
*
* @param {*} val
* @returns {any[]}
*/
function
forceArray
(
val
)
{
if
(
!
Array
.
isArray
(
val
))
{
return
[
val
];
}
return
val
;
}
module
.
exports
=
forceArray
;
test/test.js
View file @
072cdc6c
const
is
=
require
(
'
../index
'
);
const
{
is
,
force
}
=
require
(
'
../index
'
);
// console.log([
// is.array(['foo', 'bar']),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment