@awesomeness-js/utils 1.0.4 → 1.0.6

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/index.js CHANGED
@@ -4,17 +4,35 @@
4
4
  * Do not edit manually.
5
5
  */
6
6
  import _build from './src/build.js';
7
+ import _convertBytes from './src/convertBytes.js';
8
+ import _each from './src/each.js';
9
+ import _eachAsync from './src/eachAsync.js';
10
+ import _getAllFiles from './src/getAllFiles.js';
11
+ import _md5 from './src/md5.js';
12
+ import _toPennies from './src/toPennies.js';
7
13
 
8
14
  export { _build as build };
15
+ export { _convertBytes as convertBytes };
16
+ export { _each as each };
17
+ export { _eachAsync as eachAsync };
18
+ export { _getAllFiles as getAllFiles };
19
+ export { _md5 as md5 };
20
+ export { _toPennies as toPennies };
9
21
 
10
22
  export default {
11
- /**
12
- * Generates a output file that consolidates all src functions.
13
- *
14
- * @param {Object} [options] - The options for generating the output file.
15
- * @param {string} [options.src='./src'] - The source directory.
16
- * @param {array} [options.dest=['./', 'index.js']] - The destination file.
17
- * @returns {bool} - Returns true if the output file is generated successfully.
23
+ /**
24
+ * Generates a output file that consolidates all src functions.
25
+ *
26
+ * @param {Object} [options] - The options for generating the output file.
27
+ * @param {string} [options.src='./src'] - The source directory.
28
+ * @param {array} [options.dest=['./', 'index.js']] - The destination file.
29
+ * @returns {bool} - Returns true if the output file is generated successfully.
18
30
  */
19
- build: _build
31
+ build: _build,
32
+ convertBytes: _convertBytes,
33
+ each: _each,
34
+ eachAsync: _eachAsync,
35
+ getAllFiles: _getAllFiles,
36
+ md5: _md5,
37
+ toPennies: _toPennies
20
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomeness-js/utils",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Awesomeness - Utils",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,24 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ function getAllFiles(dirPath = './', arrayOfFiles = []){
5
+
6
+ const items = fs.readdirSync(dirPath);
7
+
8
+ items.forEach((item) => {
9
+ const fullPath = path.resolve(dirPath, item);
10
+
11
+ if (fs.statSync(fullPath).isDirectory()) {
12
+ // Recurse into the directory
13
+ getAllFiles(fullPath, arrayOfFiles);
14
+ } else {
15
+ // Add only files
16
+ arrayOfFiles.push(fullPath);
17
+ }
18
+ });
19
+
20
+ return arrayOfFiles;
21
+
22
+ };
23
+
24
+ export default getAllFiles;
package/src/md5.js ADDED
@@ -0,0 +1,5 @@
1
+ import { createHash } from 'crypto';
2
+ function md5(data) {
3
+ return createHash('md5').update(data).digest('hex');
4
+ }
5
+ export default md5;
package/test.js ADDED
@@ -0,0 +1,7 @@
1
+ import utils from './index.js';
2
+
3
+ let fileList = utils.getAllFiles('./src');
4
+ console.log(fileList);
5
+
6
+ let md5Test = utils.md5('test');
7
+ console.log(md5Test);