pax_global_header00006660000000000000000000000064124724636140014523gustar00rootroot0000000000000052 comment=480731b649ebb39742fef10f53c1262e654ccb52 integer-1.0.5/000077500000000000000000000000001247246361400131635ustar00rootroot00000000000000integer-1.0.5/.editorconfig000066400000000000000000000002511247246361400156360ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = falseinteger-1.0.5/.gitattributes000066400000000000000000000000141247246361400160510ustar00rootroot00000000000000* text=auto integer-1.0.5/.gitignore000066400000000000000000000013071247246361400151540ustar00rootroot00000000000000 # Directories # ############### reports/ build/ # Compiled source # ################### *.com *.class *.dll *.exe *.o *.so # Packages # ############ # it's better to unpack these files and commit the raw source # git has its own built in compression methods *.7z *.dmg *.gz *.iso *.jar *.rar *.tar *.zip # Logs and databases # ###################### *.log *.sql *.sqlite # OS generated files # ###################### .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes Icon? ehthumbs.db Thumbs.db Desktop.ini # Temporary files # ################### *~ # Node.js # ########### /node_modules/ # Matlab # ########## # Windows default autosave extension *.asv # Compiled MEX binaries (all platforms) *.mex* integer-1.0.5/.jshintignore000066400000000000000000000001661247246361400156720ustar00rootroot00000000000000 # Directories # ############### build/ reports/ dist/ # Node.js # ########### /node_modules/ # Git # ####### .git* integer-1.0.5/.jshintrc000066400000000000000000000023501247246361400150100ustar00rootroot00000000000000{ "bitwise": false, "camelcase": false, "curly": true, "eqeqeq": true, "es3": false, "forin": true, "freeze": true, "immed": true, "indent": 4, "latedef": "nofunc", "newcap": true, "noarg": true, "noempty": false, "nonbsp": true, "nonew": true, "plusplus": false, "quotmark": "single", "undef": true, "unused": true, "strict": true, "maxparams": 10, "maxdepth": 5, "maxstatements": 100, "maxcomplexity": false, "maxlen": 1000, "asi": false, "boss": false, "debug": false, "eqnull": false, "esnext": false, "evil": false, "expr": false, "funcscope": false, "globalstrict": false, "iterator": false, "lastsemic": false, "laxbreak": false, "laxcomma": false, "loopfunc": false, "maxerr": 1000, "moz": false, "multistr": false, "notypeof": false, "proto": false, "scripturl": false, "shadow": false, "sub": true, "supernew": false, "validthis": false, "noyield": false, "browser": true, "browserify": true, "couch": false, "devel": true, "dojo": false, "jasmine": false, "jquery": false, "mocha": true, "mootools": false, "node": true, "nonstandard": false, "prototypejs": false, "qunit": false, "rhino": false, "shelljs": false, "worker": false, "wsh": false, "yui": false, "globals": {} } integer-1.0.5/.npmignore000066400000000000000000000007621247246361400151670ustar00rootroot00000000000000 # Files # ######### Makefile README.md TODO.md # Directories # ############### build/ docs/ examples/ reports/ support/ test/ benchmark/ # Node.js # ########### .npmignore /node_modules/ # Logs # ######## *.log # OS generated files # ###################### .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes Icon? ehthumbs.db Thumbs.db Desktop.ini # Temporary files # ################### *~ # Git # ####### .git* # Utilities # ############# .jshintrc .jshintignore .travis.yml .editorconfig integer-1.0.5/.travis.yml000066400000000000000000000001111247246361400152650ustar00rootroot00000000000000language: node_js node_js: - "0.10" after_script: - npm run coverallsinteger-1.0.5/LICENSE000066400000000000000000000020671247246361400141750ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Athan Reines. 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.integer-1.0.5/Makefile000066400000000000000000000033701247246361400146260ustar00rootroot00000000000000 ############# # VARIABLES # # Set the node.js environment to test: NODE_ENV ?= test # NOTES # NOTES ?= 'TODO|FIXME|WARNING|HACK|NOTE' # MOCHA # MOCHA ?= ./node_modules/.bin/mocha _MOCHA ?= ./node_modules/.bin/_mocha MOCHA_REPORTER ?= spec # ISTANBUL # ISTANBUL ?= ./node_modules/.bin/istanbul ISTANBUL_OUT ?= ./reports/coverage ISTANBUL_REPORT ?= lcov ISTANBUL_LCOV_INFO_PATH ?= $(ISTANBUL_OUT)/lcov.info ISTANBUL_HTML_REPORT_PATH ?= $(ISTANBUL_OUT)/lcov-report/index.html # JSHINT # JSHINT ?= ./node_modules/.bin/jshint JSHINT_REPORTER ?= ./node_modules/jshint-stylish/stylish.js # FILES # # Source files: SOURCES ?= lib/*.js # Test files: TESTS ?= test/*.js ########### # TARGETS # # NOTES # .PHONY: notes notes: grep -Ern $(NOTES) $(SOURCES) $(TESTS) # UNIT TESTS # .PHONY: test test-mocha test: test-mocha test-mocha: node_modules NODE_ENV=$(NODE_ENV) \ NODE_PATH=$(NODE_PATH_TEST) \ $(MOCHA) \ --reporter $(MOCHA_REPORTER) \ $(TESTS) # CODE COVERAGE # .PHONY: test-cov test-istanbul-mocha test-cov: test-istanbul-mocha test-istanbul-mocha: node_modules NODE_ENV=$(NODE_ENV) \ NODE_PATH=$(NODE_PATH_TEST) \ $(ISTANBUL) cover \ --dir $(ISTANBUL_OUT) \ --report $(ISTANBUL_REPORT) \ $(_MOCHA) -- \ --reporter $(MOCHA_REPORTER) \ $(TESTS) # COVERAGE REPORT # .PHONY: view-cov view-istanbul-report view-cov: view-istanbul-report view-istanbul-report: open $(ISTANBUL_HTML_REPORT_PATH) # LINT # .PHONY: lint lint-jshint lint: lint-jshint lint-jshint: node_modules $(JSHINT) \ --reporter $(JSHINT_REPORTER) \ ./ # NODE # # Installing node_modules: .PHONY: install install: npm install # Clean node: .PHONY: clean-node clean-node: rm -rf node_modules # CLEAN # .PHONY: clean clean: rm -rf build integer-1.0.5/README.md000066400000000000000000000053701247246361400144470ustar00rootroot00000000000000Integer === [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url] > Validates if a value is an integer. ## Installation ``` bash $ npm install validate.io-integer ``` For use in the browser, use [browserify](https://github.com/substack/node-browserify). ## Usage ``` javascript var isInteger = require( 'validate.io-integer' ); ``` #### isInteger( value ) Validates if a value is an `integer`. ``` javascript var value = 5; var bool = isInteger( value ); // returns true ``` __Note__: this method validates that a value is `numeric` __before__ determining if the `value` is an `integer`. For non-numeric values, the method returns `false`. ## Examples ``` javascript var bool; bool = isInteger( 5 ); // returns true bool = isInteger( 0 ); // returns true bool = isInteger( 5.256 ); // returns false bool = isInteger( 1/0 ); // returns false ``` To run the example code from the top-level application directory, ``` bash $ node ./examples/index.js ``` ## Tests ### Unit Unit tests use the [Mocha](http://mochajs.org) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory: ``` bash $ make test ``` All new feature development should have corresponding unit tests to validate correct functionality. ### Test Coverage This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory: ``` bash $ make test-cov ``` Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report, ``` bash $ make view-cov ``` --- ## License [MIT license](http://opensource.org/licenses/MIT). ## Copyright Copyright © 2014. Athan Reines. [npm-image]: http://img.shields.io/npm/v/validate.io-integer.svg [npm-url]: https://npmjs.org/package/validate.io-integer [travis-image]: http://img.shields.io/travis/validate-io/integer/master.svg [travis-url]: https://travis-ci.org/validate-io/integer [coveralls-image]: https://img.shields.io/coveralls/validate-io/integer/master.svg [coveralls-url]: https://coveralls.io/r/validate-io/integer?branch=master [dependencies-image]: http://img.shields.io/david/validate-io/integer.svg [dependencies-url]: https://david-dm.org/validate-io/integer [dev-dependencies-image]: http://img.shields.io/david/dev/validate-io/integer.svg [dev-dependencies-url]: https://david-dm.org/dev/validate-io/integer [github-issues-image]: http://img.shields.io/github/issues/validate-io/integer.svg [github-issues-url]: https://github.com/validate-io/integer/issues integer-1.0.5/TODO.md000066400000000000000000000000141247246361400142450ustar00rootroot00000000000000TODO ==== integer-1.0.5/examples/000077500000000000000000000000001247246361400150015ustar00rootroot00000000000000integer-1.0.5/examples/index.js000066400000000000000000000003761247246361400164540ustar00rootroot00000000000000'use strict'; var isInteger = require( './../lib' ); console.log( isInteger( 5 ) ); // returns true console.log( isInteger( 0 ) ); // returns true console.log( isInteger( 5.256 ) ); // returns false console.log( isInteger( 1/0 ) ); // returns false integer-1.0.5/lib/000077500000000000000000000000001247246361400137315ustar00rootroot00000000000000integer-1.0.5/lib/index.js000066400000000000000000000012561247246361400154020ustar00rootroot00000000000000/** * * VALIDATE: integer * * * DESCRIPTION: * - Validates if a value is an integer. * * * NOTES: * [1] * * * TODO: * [1] * * * LICENSE: * MIT * * Copyright (c) 2014. Athan Reines. * * * AUTHOR: * Athan Reines. kgryte@gmail.com. 2014. * */ 'use strict'; // MODULES // var isNumber = require( 'validate.io-number' ); // ISINTEGER // /** * FUNCTION: isInteger( value ) * Validates if a value is an integer. * * @param {Number} value - value to be validated * @returns {Boolean} boolean indicating whether value is an integer */ function isInteger( value ) { return isNumber( value ) && value%1 === 0; } // end FUNCTION isInteger() // EXPORTS // module.exports = isInteger; integer-1.0.5/package.json000066400000000000000000000026671247246361400154640ustar00rootroot00000000000000{ "name": "validate.io-integer", "version": "1.0.5", "description": "Validates if a value is an integer.", "author": { "name": "Athan Reines", "email": "kgryte@gmail.com" }, "contributors": [ { "name": "Athan Reines", "email": "kgryte@gmail.com" } ], "scripts": { "test": "./node_modules/.bin/mocha", "test-cov": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec", "coveralls": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls" }, "main": "./lib", "repository": { "type": "git", "url": "git://github.com/validate-io/integer.git" }, "keywords": [ "validate.io", "validate", "validation", "validator", "number", "numeric", "integer", "is", "isinteger", "type", "check" ], "bugs": { "url": "https://github.com/validate-io/integer/issues" }, "dependencies": { "validate.io-number": "^1.0.3" }, "devDependencies": { "chai": "1.x.x", "mocha": "1.x.x", "coveralls": "^2.11.1", "istanbul": "^0.3.0", "jshint": "^2.5.10", "jshint-stylish": "^1.0.0" }, "licenses": [ { "type": "MIT", "url": "http://www.opensource.org/licenses/MIT" } ] } integer-1.0.5/test/000077500000000000000000000000001247246361400141425ustar00rootroot00000000000000integer-1.0.5/test/test.js000066400000000000000000000016261247246361400154640ustar00rootroot00000000000000/* global require, describe, it */ 'use strict'; // MODULES // var // Expectation library: chai = require( 'chai' ), // Module to be tested: isInteger = require( './../lib' ); // VARIABLES // var expect = chai.expect, assert = chai.assert; // TESTS // describe( 'validate.io-integer', function tests() { it( 'should export a function', function test() { expect( isInteger ).to.be.a( 'function' ); }); it( 'should positively validate', function test() { assert.ok( isInteger( 5 ) ); assert.ok( isInteger( 0 ) ); assert.ok( isInteger( -5 ) ); assert.ok( isInteger( new Number( 5 ) ) ); }); it( 'should negatively validate', function test() { var values = [ 5.5, true, 1/0, Number.NEGATIVE_INFINITY, [], '5', function(){}, null, {}, NaN, undefined ]; for ( var i = 0; i < values.length; i++ ) { assert.ok( !isInteger( values[i] ) ); } }); });