@stackfactor/client-api 1.0.9 → 1.0.10

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/lib/users.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { axios } = require("./axios");
2
- import { removeNullProperties } from "../components/Utils";
2
+ const { removeNullProperties } = require("./utils");
3
3
 
4
4
  module.exports = {
5
5
  axios: axios,
package/lib/utils.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const utils = {
2
2
  /**
3
3
  * Convert object to array
4
+ * @param {Object} data
5
+ * @returns {Array}
4
6
  */
5
7
  objectToArray: (data) => {
6
8
  if (typeof data === "object") {
@@ -10,6 +12,7 @@ const utils = {
10
12
 
11
13
  /**
12
14
  * Returns the backend base API URL
15
+ * @returns {String}
13
16
  */
14
17
  getBaseUrl: () => {
15
18
  if (!process.env.NODE_ENV || process.env.NODE_ENV === "production") {
@@ -18,6 +21,24 @@ const utils = {
18
21
  return "http://localhost:3100/";
19
22
  }
20
23
  },
24
+
25
+ /**
26
+ * Remove null properties
27
+ * @param {Object} object
28
+ * @returns {Object}
29
+ */
30
+ removeNullProperties: (object) => {
31
+ Object.keys(object).forEach((key) => {
32
+ let value = object[key.toString()];
33
+ let hasProperties = value && Object.keys(value).length > 0;
34
+ if (value === null) {
35
+ delete object[key.toString()];
36
+ } else if (typeof value !== "string" && hasProperties) {
37
+ removeNullProperties(value);
38
+ }
39
+ });
40
+ return object;
41
+ },
21
42
  };
22
43
 
23
44
  module.exports = utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "main": "index.js",
6
6
  "exports": {