@wizhut_tech/wizjs 0.0.7 → 0.0.9

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.
@@ -0,0 +1,3 @@
1
+ # Lang / files
2
+
3
+ * **loadFully(filename)**: loads a *file*, fully and returns it as text. If an error occurs return null
@@ -1,2 +1,3 @@
1
1
  # Lang / Arrays
2
2
 
3
+ * *compact(arg)*: removes *null* and *undefined* values from an array, returns always an array. If the *arg* is invalid, it returns an empty array.
package/index.js CHANGED
@@ -3,9 +3,13 @@ const checks = require('./src/lang/checks.js');
3
3
  const numbers = require('./src/math/numbers.js');
4
4
  const functools = require('./src/lang/functools.js');
5
5
  const arrays = require('./src/lang/arrays.js');
6
+ const files = require('./src/io/files.js');
6
7
 
7
8
 
8
9
  module.exports = {
10
+ io: {
11
+ files: files,
12
+ },
9
13
  lang: {
10
14
  arrays: arrays,
11
15
  singleton: singleton,
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@wizhut_tech/wizjs",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "main": "index.js",
5
5
  "devDependencies": {
6
- "tap": "21.0.2"
6
+ "tap": "21.1.0"
7
7
  },
8
8
  "description": "Simple but useful hacks for everyday javascript programming",
9
9
  "scripts": {
package/readme.md CHANGED
@@ -8,6 +8,9 @@ Use by importing:
8
8
 
9
9
  ```
10
10
  {
11
+ io: {
12
+ files: [functions]
13
+ },
11
14
  lang: {
12
15
  arrays: [functions],
13
16
  checks: [functions],
@@ -20,6 +23,14 @@ Use by importing:
20
23
  }
21
24
  ```
22
25
 
26
+ You can also import individual functions like the following:
27
+
28
+ `const { lang: { checks : { isNil } } } = require('@wizhut_tech/wizjs');`
29
+
30
+ ### I/O
31
+
32
+ * **Files** utility functions ... [[docs](docs/io_files.md)]
33
+
23
34
  ### Language
24
35
 
25
36
  * **Arrays** utility functions ... [[docs](docs/lang_arrays.md)]
@@ -0,0 +1,15 @@
1
+ const fs = require('fs').promises;
2
+
3
+
4
+ async function loadFully(filename) {
5
+ try {
6
+ const data = await fs.readFile(filename, 'utf8');
7
+ } catch (err) {
8
+ return null;
9
+ }
10
+ }
11
+
12
+
13
+ module.exports = {
14
+ loadFully
15
+ };