Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
chore(pad-array): create initial structure
  • Loading branch information
maasencioh committed Sep 5, 2015
commit 71fa8578af4204308c56901a06579b46c7dcce4f
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.12"
- "iojs"
sudo: false
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.0.0 / HEAD
============

* first release
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# pad-array

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![David deps][david-image]][david-url]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove the david badge if the project doesn't have dependencies

[![npm download][download-image]][download-url]

Function to pads an array in Javascript

This code is based in the MATLAB's code [padarray](http://www.mathworks.com/help/images/ref/padarray.html)

## Installation

`npm install ml-pad-array`

## Methods

### pad-array(data, [options])

Pads the array `data` given the current `options`.

__Options__
* padsize:
* padval:
* direction:

## Test

```bash
$ npm install
$ npm test
```

## Authors

- [Miguel Asencio](https://github.com/maasencioh)

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/ml-pad-array.svg?style=flat-square
[npm-url]: https://npmjs.org/package/ml-pad-array
[travis-image]: https://img.shields.io/travis/mljs/pad-array/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/mljs/pad-array
[david-image]: https://img.shields.io/david/mljs/pad-array.svg?style=flat-square
[david-url]: https://david-dm.org/mljs/pad-array
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both lines can be removed

[download-image]: https://img.shields.io/npm/dm/ml-pad-array.svg?style=flat-square
[download-url]: https://npmjs.org/package/ml-pad-array
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "ml-pad-array",
"version": "0.0.0",
"description": "Function to pads an array in Javascript",
"main": "src/index.js",
"directories": {
"lib": "src",
"test": "test"
},
"scripts": {
"test": "mocha --require should --reporter mocha-better-spec-reporter --recursive"
},
"repository": {
"type": "git",
"url": "https://github.com/mljs/pad-array"
},
"keywords": [
"pad",
"array",
"utils"
],
"author": {
"name": "Miguel Asencio",
"mail": "maasencioh@gmail.com"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this field is supposed to be "email"

},
"license": "MIT",
"bugs": {
"url": "https://github.com/mljs/pad-array/issues"
},
"homepage": "https://github.com/mljs/pad-array",
"devDependencies": {
"mocha": "latest",
"mocha-better-spec-reporter": "latest",
"should": "latest"
}
}
22 changes: 22 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var defaultOptions = {
padsize: 1,
padval: 0,
direction: 'both'
};

/**
* Pads and array
* @param {Array <number>} data
* @param {object} options
*/
function padArray (data, options) {
options = options || {};
for (var o in defaultOptions)
if (!(options[o]))
options[o] = defaultOptions[o];
return data;
}

module.exports = padArray;
13 changes: 13 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

var padArray = require('..');

describe('Pad array test', function () {

it('Default test', function () {
var data = new Array(200);
for (var i = 0; i < data.length; i++)
data[i] = Math.sin(i);
var model = padArray(data);
});
});