Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
14 changes: 14 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Directories #
###############
build/
reports/
dist/

# Node.js #
###########
/node_modules/

# Git #
#######
.git*
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ Desktop.ini
# Utilities #
#############
.jshintrc
.jshintignore
.travis.yml
.editorconfig
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

25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,31 @@ 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
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 #

Expand Down Expand Up @@ -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:
Expand All @@ -117,7 +131,6 @@ clean-node:


# CLEAN #

.PHONY: clean

clean:
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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]

Expand All @@ -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' );
```
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* LICENSE:
* MIT
*
* Copyright (c) 2014. Athan Reines.
* Copyright (c) 2014-2015. Athan Reines.
*
*
* AUTHOR:
Expand All @@ -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 //

Expand All @@ -50,17 +50,17 @@ function linspace( x1, x2, len ) {
tmp,
d;

if ( typeof x1 !== 'number' || x1 !== x1 ) {
throw new TypeError( 'linspace()::invalid input argument. Start must be numeric.' );
if ( !isNumber( x1 ) ) {
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.' );
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 ) {
throw new TypeError( 'linspace()::invalid input argument. Length must be a positive integer.' );
if ( !isNonNegativeInteger( len ) ) {
throw new TypeError( 'linspace()::invalid input argument. Length must be a positive integer. Value: `' + len + '`.' );
}
if ( len === 0 ) {
return [];
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
{
"name": "Athan Reines",
"email": "[email protected]"
},
{
"name": "Philipp Burckhardt",
"email": "[email protected]"
}
],
"scripts": {
Expand Down Expand Up @@ -38,13 +42,16 @@
"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",
"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": [
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global require, describe, it */
'use strict';

// MODULES //
Expand Down