Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
- npm run coveralls

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
SOFTWARE.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 #

Expand Down Expand Up @@ -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 #
Expand All @@ -114,7 +121,6 @@ lint-jshint: node_modules
./



# NODE #

# Installing node_modules:
Expand All @@ -132,7 +138,6 @@ clean-node:


# CLEAN #

.PHONY: clean

clean:
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
```
Expand Down Expand Up @@ -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
Expand Down
36 changes: 4 additions & 32 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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 //
Expand All @@ -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,
Expand All @@ -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 ) {
Expand Down
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
{
"name": "Athan Reines",
"email": "kgryte@gmail.com"
},
{
"name": "Philipp Burckhardt",
"email": "pburckhardt@outlook.com"
}
],
"scripts": {
Expand Down Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down