@vbarbarosh/node-helpers 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Vladimir Barbarosh <vladimir.barbarosh@gmail.com>",
3
3
  "license": "MIT",
4
4
  "name": "@vbarbarosh/node-helpers",
5
- "version": "1.1.3",
5
+ "version": "1.1.4",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "files": [
8
8
  "src"
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shuffles an array using Durstenfeld shuffle algorithm.
3
+ *
4
+ * Note: This function performs shuffle in-place. In order
5
+ * to get a shuffled copy use call slice before calling, e.g.
6
+ * array_shuffle(items.slice()).
7
+ *
8
+ * @param array
9
+ * @returns array
10
+ * @link https://stackoverflow.com/a/6274381/1478566
11
+ * @link https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
12
+ */
13
+ function array_shuffle(array)
14
+ {
15
+ for (let i = array.length; --i > 0; ) {
16
+ const j = Math.floor(Math.random() * (i + 1));
17
+ const x = array[i];
18
+ array[i] = array[j];
19
+ array[j] = x;
20
+ }
21
+ return array;
22
+ }
23
+
24
+ export default array_shuffle;
@@ -3,7 +3,7 @@ import fs_size from './fs_size';
3
3
  import http from 'http';
4
4
  import https from 'https';
5
5
 
6
- async function http_put_file(url, file, options)
6
+ async function http_put_file(url, file, options = {})
7
7
  {
8
8
  // <?xml version="1.0" encoding="UTF-8"?>
9
9
  // <Error>