-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e3ba6e
commit 5b1e75e
Showing
10 changed files
with
186 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# Directories # | ||
############### | ||
build/ | ||
reports/ | ||
dist/ | ||
|
||
# Node.js # | ||
########### | ||
/node_modules/ | ||
|
||
# Git # | ||
####### | ||
.git* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,5 +47,6 @@ Desktop.ini | |
# Utilities # | ||
############# | ||
.jshintrc | ||
.jshintignore | ||
.travis.yml | ||
.editorconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,57 @@ | ||
/** | ||
* | ||
* COMPUTE: nanmin | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the minimum value of an array ignoring non-numeric values. | ||
* | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2014. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. [email protected]. 2014. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var isArray = require( 'validate.io-array' ), | ||
isFunction = require( 'validate.io-function' ), | ||
isNumber = require( 'validate.io-number' ); | ||
|
||
// NANMIN // | ||
|
||
/** | ||
* FUNCTION: nanmin( arr ) | ||
* FUNCTION: nanmin( arr[, accessor] ) | ||
* Computes the minimum value of an array ignoring any non-numeric values. | ||
* | ||
* @param {Array} arr - array of values | ||
* @returns {Number} min value | ||
* @param {Number[]|Array} arr - array of values | ||
* @param {Function} [accessor] - accessor function for accessing array values | ||
* @returns {Number|Null} min value or null | ||
*/ | ||
function nanmin( arr ) { | ||
if ( !Array.isArray( arr ) ) { | ||
throw new TypeError( 'nanmin()::invalid input argument. Must provide an array.' ); | ||
function nanmin( arr, clbk ) { | ||
if ( !isArray( arr ) ) { | ||
throw new TypeError( 'nanmin()::invalid input argument. Must provide an array. Value: `' + arr + '`.' ); | ||
} | ||
if ( arguments.length > 1 && !isFunction( clbk ) ) { | ||
throw new TypeError( 'nanmin()::invalid input argument. Accessor must be a function. Value: `' + clbk + '`.' ); | ||
} | ||
|
||
var len = arr.length, | ||
min = null, | ||
val; | ||
val, | ||
i; | ||
|
||
if ( !len ) { | ||
return null; | ||
} | ||
|
||
for ( var i = 0; i < len; i++ ) { | ||
val = arr[ i ]; | ||
if ( typeof val !== 'number' || val !== val ) { | ||
continue; | ||
if ( clbk ) { | ||
for ( i = 0; i < len; i++ ) { | ||
val = clbk( arr[ i ], i); | ||
if ( !isNumber( val ) ) { | ||
continue; | ||
} | ||
if ( min === null || val < min ) { | ||
min = val; | ||
} | ||
} | ||
if ( min === null || val < min ) { | ||
min = val; | ||
} else { | ||
for ( i = 0; i < len; i++ ) { | ||
val = arr[ i ]; | ||
if ( !isNumber( val ) ) { | ||
continue; | ||
} | ||
if ( min === null || val < min ) { | ||
min = val; | ||
} | ||
} | ||
} | ||
return min; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,10 @@ | |
{ | ||
"name": "Athan Reines", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Philipp Burckhardt", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"scripts": { | ||
|
@@ -39,17 +43,16 @@ | |
"bugs": { | ||
"url": "https://github.com/compute-io/nanmin/issues" | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"validate.io-array": "^1.0.5", | ||
"validate.io-function": "^1.0.2", | ||
"validate.io-number": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "1.x.x", | ||
"mocha": "1.x.x", | ||
"chai": "2.x.x", | ||
"mocha": "2.x.x", | ||
"coveralls": "^2.11.1", | ||
"istanbul": "^0.3.0" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
] | ||
"licenses": "MIT" | ||
} |
Oops, something went wrong.