Skip to content

Commit

Permalink
Merge pull request #27 from trexnix/flatten
Browse files Browse the repository at this point in the history
Added flatten
  • Loading branch information
kolodny committed Jun 21, 2015
2 parents 6f34ea9 + 2fd8ec7 commit f6f8780
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions flatten/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Here's the basic usage of the file that you'll be creating:

```js
var flatten = require('./') // <- this is the file you make;

var arr = [1, [2], [3, 4, [5]]];

flatten(arr);
// => [1, 2, 3, 4, 5];

```
6 changes: 6 additions & 0 deletions flatten/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"scripts": {
"test": "node ../node_modules/mocha/bin/mocha"
}
}
14 changes: 14 additions & 0 deletions flatten/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var assert = require('assert');
var flatten = require('./');

describe('flatten', function() {
var arr = [1, [2], [3, 4, [5]]];

it('will return another array', function() {
assert.notEqual(flatten(arr), arr);
});

it('will flatten an array', function() {
assert.deepEqual(flatten(arr), [1, 2, 3, 4, 5]);
});
});

0 comments on commit f6f8780

Please sign in to comment.