Skip to content

Commit

Permalink
🚧 progress: Import existing source. Test API.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 27, 2021
1 parent 5f1d7a0 commit 5cb3c27
Show file tree
Hide file tree
Showing 5 changed files with 10,014 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@babel/preset-env": "7.13.15",
"@babel/register": "7.13.14",
"@commitlint/cli": "12.1.1",
"@iterable-iterator/range": "^0.0.1",
"@js-library/commitlint-config": "0.0.4",
"ava": "3.15.0",
"babel-plugin-transform-remove-console": "6.9.4",
Expand Down
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
const answer = 42;
export default answer;
/**
* Returns an array containing all elements of the input iterable.
*
* @example
* // return [0,1,2]
* list( range( 3 ) ) ;
*
* @function
* @param {Iterable} iterable The input Iterable.
* @returns {Array} The output Array.
*
*/
export const list = Array.from;
5 changes: 0 additions & 5 deletions test/src/api.js

This file was deleted.

29 changes: 29 additions & 0 deletions test/src/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import test from 'ava';

import {range} from '@iterable-iterator/range';

import {list} from '../../src/index.js';

test('range(0)', (t) => {
t.deepEqual(list(range(0)), []);
});

test('range(5)', (t) => {
t.deepEqual(list(range(5)), [0, 1, 2, 3, 4]);
});

test('""', (t) => {
t.deepEqual(list(''), []);
});

test('"ABC"', (t) => {
t.deepEqual(list('ABC'), ['A', 'B', 'C']);
});

test('[]', (t) => {
t.deepEqual(list([]), []);
});

test('[{}, undefined, null]', (t) => {
t.deepEqual(list([{}, undefined, null]), [{}, undefined, null]);
});
Loading

0 comments on commit 5cb3c27

Please sign in to comment.