diff --git a/snippets/nodeListToArray.md b/snippets/nodeListToArray.md new file mode 100644 index 000000000..d5c8713d1 --- /dev/null +++ b/snippets/nodeListToArray.md @@ -0,0 +1,13 @@ +### nodeListToArray + +Converts a `NodeList` to an array. + +Use `Array.prototype.slice()` and `Function.prototype.call()` to convert a `NodeList` to an array. + +```js +const nodeListToArray = nodeList => Array.prototype.slice.call(nodeList); +``` + +```js +nodeListToArray(document.childNodes); // [ , html ] +``` diff --git a/tag_database b/tag_database index aff132d1e..2fe2eb8f2 100644 --- a/tag_database +++ b/tag_database @@ -168,6 +168,7 @@ minN:array,math mostPerformant:utility,function negate:function nest:object +nodeListToArray:browser,array none:array,function nthArg:utility,function nthElement:array diff --git a/test/nodeListToArray/nodeListToArray.js b/test/nodeListToArray/nodeListToArray.js new file mode 100644 index 000000000..916fc58e7 --- /dev/null +++ b/test/nodeListToArray/nodeListToArray.js @@ -0,0 +1,2 @@ +const nodeListToArray = nodeList => Array.prototype.slice.call(nodeList); +module.exports = nodeListToArray; \ No newline at end of file diff --git a/test/nodeListToArray/nodeListToArray.test.js b/test/nodeListToArray/nodeListToArray.test.js new file mode 100644 index 000000000..12d99435c --- /dev/null +++ b/test/nodeListToArray/nodeListToArray.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const nodeListToArray = require('./nodeListToArray.js'); + +test('Testing nodeListToArray', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof nodeListToArray === 'function', 'nodeListToArray is a Function'); + //t.deepEqual(nodeListToArray(args..), 'Expected'); + //t.equal(nodeListToArray(args..), 'Expected'); + //t.false(nodeListToArray(args..), 'Expected'); + //t.throws(nodeListToArray(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/testlog b/test/testlog index 73ddfd3e1..835cebe19 100644 --- a/test/testlog +++ b/test/testlog @@ -1,4 +1,4 @@ -Test log for: Sun May 06 2018 17:55:09 GMT+0300 (GTB Daylight Time) +Test log for: Sun May 06 2018 18:11:06 GMT+0300 (GTB Daylight Time) > 30-seconds-of-code@0.0.3 test H:\My Files\git Repositories\30-seconds-of-code > tape test/**/*.test.js | tap-spec @@ -1135,6 +1135,10 @@ Test log for: Sun May 06 2018 17:55:09 GMT+0300 (GTB Daylight Time) √ nest is a Function + Testing nodeListToArray + + √ nodeListToArray is a Function + Testing none √ none is a Function @@ -2002,16 +2006,16 @@ Test log for: Sun May 06 2018 17:55:09 GMT+0300 (GTB Daylight Time) Testing zipWith √ zipWith is a Function - √ Runs the function provided √ Sends a GET request + √ Runs the function provided √ Runs promises in series √ Sends a POST request √ Works as expecting, passing arguments properly √ Works with multiple promises - total: 1018 - passing: 1018 - duration: 2.7s + total: 1019 + passing: 1019 + duration: 2.5s