From 985a935588f187a9c92a50f2560d78f2e0c1f472 Mon Sep 17 00:00:00 2001 From: Planeshifter Date: Fri, 20 Mar 2015 18:11:55 -0400 Subject: [PATCH 1/3] [UPDATE] dotfiles, README.md --- .gitattributes | 1 + .jshintignore | 14 ++++++++++++++ .npmignore | 1 + .travis.yml | 11 +++++++++-- Makefile | 25 +++++++++++++++++++------ README.md | 11 ++++------- package.json | 6 ++++++ test/test.js | 1 + 8 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 .gitattributes create mode 100644 .jshintignore diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000..3163c22 --- /dev/null +++ b/.jshintignore @@ -0,0 +1,14 @@ + +# Directories # +############### +build/ +reports/ +dist/ + +# Node.js # +########### +/node_modules/ + +# Git # +####### +.git* diff --git a/.npmignore b/.npmignore index 7de8cda..9db298d 100644 --- a/.npmignore +++ b/.npmignore @@ -47,5 +47,6 @@ Desktop.ini # Utilities # ############# .jshintrc +.jshintignore .travis.yml .editorconfig diff --git a/.travis.yml b/.travis.yml index 7c16620..29cff27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,12 @@ language: node_js node_js: - - "0.10" + - '0.12' + - '0.11' + - '0.10' + - '0.8' + - 'iojs' +before_install: + - npm update -g npm after_script: - - npm run coveralls \ No newline at end of file + - npm run coveralls + diff --git a/Makefile b/Makefile index f5648d1..8f4ec98 100644 --- a/Makefile +++ b/Makefile @@ -8,22 +8,18 @@ NODE_ENV ?= test # NOTES # -NOTES ?= 'TODO|FIXME' +NOTES ?= 'TODO|FIXME|WARNING|HACK|NOTE' # MOCHA # -# Specify the test framework bin locations: MOCHA ?= ./node_modules/.bin/mocha _MOCHA ?= ./node_modules/.bin/_mocha - -# Specify the mocha reporter: MOCHA_REPORTER ?= spec # ISTANBUL # -# Istanbul configuration: ISTANBUL ?= ./node_modules/.bin/istanbul ISTANBUL_OUT ?= ./reports/coverage ISTANBUL_REPORT ?= lcov @@ -31,6 +27,12 @@ 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 # @@ -100,6 +102,18 @@ view-istanbul-report: +# LINT # + +.PHONY: lint lint-jshint + +lint: lint-jshint + +lint-jshint: node_modules + $(JSHINT) \ + --reporter $(JSHINT_REPORTER) \ + ./ + + # NODE # # Installing node_modules: @@ -117,7 +131,6 @@ clean-node: # CLEAN # - .PHONY: clean clean: diff --git a/README.md b/README.md index 581542c..5beab79 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ For use in the browser, use [browserify](https://github.com/substack/node-browse ## Usage -To use the module, - ``` javascript var linspace = require( 'compute-linspace' ); ``` @@ -93,7 +91,7 @@ $ node ./examples/index.js ### Unit -Unit tests use the [Mocha](http://visionmedia.github.io/mocha) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory: +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 @@ -116,16 +114,15 @@ Istanbul creates a `./reports/coverage` directory. To access an HTML version of $ make view-cov ``` - +--- ## License -[MIT license](http://opensource.org/licenses/MIT). +[MIT license](http://opensource.org/licenses/MIT). ---- ## Copyright -Copyright © 2014. Athan Reines. +Copyright © 2014-2015. Athan Reines. [npm-image]: http://img.shields.io/npm/v/compute-linspace.svg diff --git a/package.json b/package.json index b54861f..90f0f4c 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,10 @@ { "name": "Athan Reines", "email": "kgryte@gmail.com" + }, + { + "name": "Philipp Burckhardt", + "email": "pburckhardt@outlook.com" } ], "scripts": { @@ -45,6 +49,8 @@ "compute-roundn": "^1.0.3", "coveralls": "^2.11.1", "istanbul": "^0.3.0", + "jshint": "^2.6.3", + "jshint-stylish": "^1.0.1", "mocha": "1.x.x" }, "licenses": [ diff --git a/test/test.js b/test/test.js index e6e2c7e..7c1c3c3 100644 --- a/test/test.js +++ b/test/test.js @@ -1,3 +1,4 @@ +/* global require, describe, it */ 'use strict'; // MODULES // From 798ece48e8b76554304f7e4f79a5e72f356fa617 Mon Sep 17 00:00:00 2001 From: Planeshifter Date: Fri, 20 Mar 2015 18:40:48 -0400 Subject: [PATCH 2/3] [UPDATE] error msg returns value --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index ecbc07b..3c315be 100644 --- a/lib/index.js +++ b/lib/index.js @@ -18,7 +18,7 @@ * LICENSE: * MIT * -* Copyright (c) 2014. Athan Reines. +* Copyright (c) 2014-2015. Athan Reines. * * * AUTHOR: @@ -51,16 +51,16 @@ function linspace( x1, x2, len ) { d; if ( typeof x1 !== 'number' || x1 !== x1 ) { - throw new TypeError( 'linspace()::invalid input argument. Start must be numeric.' ); + throw new TypeError( 'linspace()::invalid input argument. Start must be numeric. Value: `' + x1 + '`.' ); } if ( typeof x2 !== 'number' || x2 !== x2 ) { - throw new TypeError( 'linspace()::invalid input argument. Stop must be numeric.' ); + throw new TypeError( 'linspace()::invalid input argument. Stop must be numeric. Value: `' + x2 + '`.' ); } if ( arguments.length < 3 ) { len = 100; } else { if ( !isInteger( len ) || len < 0 ) { - throw new TypeError( 'linspace()::invalid input argument. Length must be a positive integer.' ); + throw new TypeError( 'linspace()::invalid input argument. Length must be a positive integer. Value: `' + len + '`.' ); } if ( len === 0 ) { return []; From 66d3620532104241392adde8ac12ace3274bf807 Mon Sep 17 00:00:00 2001 From: Planeshifter Date: Fri, 20 Mar 2015 18:58:46 -0400 Subject: [PATCH 3/3] [UPDATE] use validate modules --- README.md | 2 +- lib/index.js | 10 +++++----- package.json | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5beab79..d0a423c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -linspace +Linspace === [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url] diff --git a/lib/index.js b/lib/index.js index 3c315be..6fa6405 100644 --- a/lib/index.js +++ b/lib/index.js @@ -30,8 +30,8 @@ // MODULES // -var isInteger = require( 'validate.io-integer' ); - +var isNumber = require( 'validate.io-number-primitive' ), + isNonNegativeInteger = require( 'validate.io-nonnegative-integer' ); // LINSPACE // @@ -50,16 +50,16 @@ function linspace( x1, x2, len ) { tmp, d; - if ( typeof x1 !== 'number' || x1 !== x1 ) { + if ( !isNumber( x1 ) ) { throw new TypeError( 'linspace()::invalid input argument. Start must be numeric. Value: `' + x1 + '`.' ); } - if ( typeof x2 !== 'number' || x2 !== x2 ) { + if ( !isNumber( x2 ) ) { throw new TypeError( 'linspace()::invalid input argument. Stop must be numeric. Value: `' + x2 + '`.' ); } if ( arguments.length < 3 ) { len = 100; } else { - if ( !isInteger( len ) || len < 0 ) { + if ( !isNonNegativeInteger( len ) ) { throw new TypeError( 'linspace()::invalid input argument. Length must be a positive integer. Value: `' + len + '`.' ); } if ( len === 0 ) { diff --git a/package.json b/package.json index 90f0f4c..140dcd2 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "url": "https://github.com/compute-io/linspace/issues" }, "dependencies": { - "validate.io-integer": "^1.0.1" + "validate.io-nonnegative-integer": "^1.0.0", + "validate.io-number-primitive": "^1.0.0" }, "devDependencies": { "chai": "1.x.x",