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/LICENSE b/LICENSE index 2fe3939..93cf2ea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Athan Reines. +Copyright (c) 2014-2015 The Compute.io Authors. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ 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. \ No newline at end of file +SOFTWARE. diff --git a/Makefile b/Makefile index d8fb6dd..3234fbb 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,14 @@ # Set the node.js environment to test: NODE_ENV ?= test +# Kernel name: +KERNEL ?= $(shell uname -s) + +ifeq ($(KERNEL), Darwin) + OPEN ?= open +else + OPEN ?= xdg-open +endif # NOTES # @@ -98,8 +106,7 @@ test-istanbul-mocha: node_modules view-cov: view-istanbul-report view-istanbul-report: - open $(ISTANBUL_HTML_REPORT_PATH) - + $(OPEN) $(ISTANBUL_HTML_REPORT_PATH) # LINT # @@ -114,7 +121,6 @@ lint-jshint: node_modules ./ - # NODE # # Installing node_modules: @@ -132,7 +138,6 @@ clean-node: # CLEAN # - .PHONY: clean clean: diff --git a/README.md b/README.md index d289d44..cc07961 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 incrmstdev = require( 'compute-incrmstdev' ); ``` @@ -121,15 +119,15 @@ $ 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. The Compute.io Authors. [npm-image]: http://img.shields.io/npm/v/compute-incrmstdev.svg diff --git a/lib/index.js b/lib/index.js index f723c8f..2c95fdf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,36 +1,8 @@ -/** -* -* COMPUTE: incrmstdev -* -* -* DESCRIPTION: -* - Provides a method to compute a moving sample standard deviation incrementally. -* -* -* NOTES: -* [1] -* -* -* TODO: -* [1] -* -* -* LICENSE: -* MIT -* -* Copyright (c) 2014. Athan Reines. -* -* -* AUTHOR: -* Athan Reines. kgryte@gmail.com. 2014. -* -*/ - 'use strict'; // MODULES // -var isInteger = require( 'validate.io-integer' ); +var isPositiveInteger = require( 'validate.io-positive-integer' ); // INCREMENTAL MOVING SAMPLE STANDARD DEVIATION // @@ -43,8 +15,8 @@ var isInteger = require( 'validate.io-integer' ); * @returns {Function} method to compute a moving sample standard deviation incrementally */ function incrmstdev( W ) { - if ( !isInteger( W ) || W < 1 ) { - throw new TypeError( 'incrmstdev()::invalid input argument. Window size must be a positive integer.' ); + if ( !isPositiveInteger( W ) ) { + throw new TypeError( 'incrmstdev()::invalid input argument. Window size must be a positive integer. Value: `' + W + '`.' ); } var arr = new Array( W ), n = W - 1, @@ -61,7 +33,7 @@ function incrmstdev( W ) { * If a `value` is provided, updates and returns the updated sample standard deviation. If no `value` is provided, returns the current sample standard deviation. * * @param {Number} [value] - value used to update the moving sample standard deviation - * @returns {Number} sample standard deviation + * @returns {Number|Null} sample standard deviation or null */ return function incrmstdev( x ) { if ( !arguments.length ) { diff --git a/package.json b/package.json index e4eaa02..1fb37ba 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": { @@ -44,20 +48,15 @@ "url": "https://github.com/compute-io/incrmstdev/issues" }, "dependencies": { - "validate.io-integer": "^1.0.2" + "validate.io-positive-integer": "^1.0.0" }, "devDependencies": { - "chai": "1.x.x", - "mocha": "1.x.x", + "chai": "2.x.x", "coveralls": "^2.11.1", "istanbul": "^0.3.0", "jshint": "2.x.x", - "jshint-stylish": "^1.0.0" + "jshint-stylish": "^1.0.0", + "mocha": "2.x.x" }, - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" - } - ] + "license": "MIT" } diff --git a/test/test.js b/test/test.js index 6f51be3..3aabf82 100644 --- a/test/test.js +++ b/test/test.js @@ -24,11 +24,12 @@ describe( 'compute-incrmstdev', function tests() { expect( incrmstdev ).to.be.a( 'function' ); }); - it( 'should throw an error if not provided an integer', function test() { + it( 'should throw an error if not provided a positive integer', function test() { var values = [ '5', -5, 0, + Math.PI, true, null, undefined,