Skip to content

Commit

Permalink
Added Readme and License
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrabin committed Aug 18, 2012
1 parent 9dd50a7 commit 4812234
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE.txt
@@ -0,0 +1,20 @@
Copyright 2012 Scott Rabin (scottrabin@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
68 changes: 68 additions & 0 deletions README.md
@@ -0,0 +1,68 @@
is.js
=====

<table>
<tr>
<th colspan="2">Basic type checking</th>
</tr>
<tr>
<td><code>is.string(s)</code></td>
<td>Determines if the argument is a string</td>
</tr>
<tr>
<td><code>is.number(n)</code></td>
<td>Determines if the argument is a number</td>
</tr>
<tr>
<td><code>is.bool(b)</code></td>
<td>Determines if the argument is a boolean (true or false)</td>
</tr>
<tr>
<td><code>is.fn(f)</code></td>
<td>Determines if the argument is a function</td>
</tr>
<tr>
<td><code>is.array(a)</code></td>
<td>Determines if the argument is an array</td>
</tr>
<tr>
<td><code>is.object(o)</code></td>
<td>Determines if the argument is an object. Since nearly all Javascript types inherit from <code>Object</code>, this will most likely return <code>true</code> for anything but numbers, strings, booleans, and <code>null</code>/<code>undefined</code>. This function can be used to determine if arbitrary properties can be set on the given object.</td>
</tr>
<tr>
<td><code>is.element(e)</code></td>
<td>Determines if the argument is an HTMLElement. Does not return <code>true</code> for <code>window</code> or <code>document</code>.</td>
</tr>
<tr>
<th colspan="2">Specialized type checking</th>
</tr>
<tr>
<td><code>is.numeric(n)</code></td>
<td>Determines if the argument is a number-like value; numbers (i.e. values that return <code>true</code> from <code>is.number(n)</code>) will return true, as well as any string representation of a number. See <a href="http://scottrabin.com/is-js/test.html">the test page for <code>is.numeric</code> to see what strings are accepted as numeric.</td>
</tr>
<tr>
<td><code>is.hash(h)</code></td>
<td>Determines if the argument is a hash, or key/value pair object that is not an <code>Array</code>, <code>function</code>, or user-defined object.</td>
</tr>
<tr>
<th colspan="2">Collection properties</th>
</tr>
<tr>
<td><code>is.in(collection, value)</code></td>
<td>Determines if the specified <code>value</code> is contained within the given <code>collection</code>. If <code>collection</code> is an array, <code>is.in</code> will check to see if <code>value</code> is an element in the array. If <code>collection</code> is an object, <code>is.in</code> will check if any property directly on the object is equal to the specified <code>value</code>.</td>
</tr>
<tr>
<td><code>is.empty(collection)</code></td>
<td>Determines if the specified collection is empty, or is otherwise falsy. If <code>collection</code> is an array, <code>is.empty</code> checks that the array has no elements. If <code>collection</code> is an object, <code>is.empty</code> checks that the object has no properties declared directly on the object. If <code>collection</code> is neither an array or object, <code>is.empty</code> checks if the given value is falsy; this includes <code>null</code>, <code>false</code>, and empty strings.</td>
</tr>
</table>

Testing
-------

See the unit tests page at <a href="http://scottrabin.com/is-js/test.html">scottrabin.com/is-js/test.html</a>.

License
-------

is.js is released under the MIT License. See <a href="http://raw.github.com/scottrabin/is-js/master/MIT-LICENSE.txt">MIT-LICENSE.txt</a> for more details.

0 comments on commit 4812234

Please sign in to comment.