Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
'Is' is a very small module that smoothes over some of the gotchas in JavaScript type checking. It behaves the way you (or rather, I) would expect type checking to work -- e.g., is.object() only works on objects that are neither arrays nor regular expressions. It also makes indexOf() easier to use, and provides search functions. Works in Node; should work in browser as well, exporting a variable 'is' into the global namespace.
is-helpers
is a very small CommonJS module that smoothes over some of the gotchas in JavaScript type checking. It behaves the way you (or rather, I) would expect type checking to work -- e.g., is.object()
only works on objects that are neither arrays nor regular expressions. It also makes indexOf()
easier to use, and provides search functions. Works in Node; should work in browser as well, exporting a variable is
into the global namespace.
None of these techniques are earth-shattering; most people will use these in their daily work. I just didn't want to have to remember all of these tricks.
Test coverage is as thorough as my imagination allows. I used Jasmine for unit testing.
All checking is strict, unless otherwise noted. Each function returns either true or false.
is.undefined( value )
is.null( value )
is.empty( value )
- checks for null or undefinedis.empty.array( value )
or is.emptyArray( value )
- must be an array-like object and have no itemsis.empty.arguments( value )
or is.emptyArguments( value )
- identical to aboveis.empty.object( value )
- must be an object and have no properties of its own; objects with properties in their prototype chains will also failis.null( value )
is.boolean( value )
is.nan( value )
- really not necessary, since it merely calls isNan()
. But I just included it to be thorough.is.infinite( value )
- opposite of isFinite()
. I didn't include an isFinite()
function because is.number()
performs this check.is.number( value )
- includes all the sensible numbers (e.g., not NaN
or Infinity
).is.integer( value )
- we all know JavaScript doesn't have integers or floats, so this fills half that gap.is.float( value )
- and this fills the other half of the gap.is.string( value )
is.object( value )
- anything considered to be an object, except null
, regular expressions, arrays, or array-like objects. Functions are considered objects, of course.is.array( value )
- any good old honest 'true' array.is.arrayLike( value )
- arrays and array-like objects.is.arguments( value )
- the arguments
array-like object.is.function( value )
is.regexp( value )
is.in( needle [, haystack] )
- takes a needle and performs a strict search on the haystack. If the haystack is not supplied, this
is assumed as the haystack. The haystack can be an object, array-like object, or string. In case of objects, only the self-owned, direct descendants are searched.is.in.array( needle [, haystack] )
or is.inArray( needle [, haystack] )
- works on array-like objects only.is.in.object( needle [, haystack] )
or is.inObject( needle [, haystack] )
- works only on haystacks that pass the is.object()
test.is.in.string( needle [, haystack] )
or is.inString( needle [, haystack] )
- string search; converts non-strings to strings.is.ownProperty( property [, object] )
- calls Object.prototype.hasOwnProperty()
on the object. If the object is not supplied, this
is assumed.is
Note: This is not the same as the is
by Enrico Marino, which is another interesting JavaScript type checking library. He uses some neat techniques, and also adds functions for comparison (e.g., is.gt()
, is.odd()
, is.divisibleBy()
) which I had no interest in. You can find his library at https://github.com/onirame/is
FAQs
'Is' is a very small module that smoothes over some of the gotchas in JavaScript type checking. It behaves the way you (or rather, I) would expect type checking to work -- e.g., is.object() only works on objects that are neither arrays nor regular expressions. It also makes indexOf() easier to use, and provides search functions. Works in Node; should work in browser as well, exporting a variable 'is' into the global namespace.
The npm package is-helpers receives a total of 0 weekly downloads. As such, is-helpers popularity was classified as not popular.
We found that is-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.