From b3ea19dec1c2a25a2d97f5061d69aa60e3913ef5 Mon Sep 17 00:00:00 2001
From: Marin Karamihalev <marin.karamihalev@iopsys.eu>
Date: Thu, 8 Apr 2021 14:36:06 +0200
Subject: [PATCH] commands/set: fixed allowPartial bug

---
 package.json        | 2 +-
 src/commands/set.ts | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index acf247c..0fff63c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "usp-js",
-  "version": "0.1.14",
+  "version": "0.1.15",
   "description": "Helper library for easy usp communication using mqtt over tcp or ws.",
   "main": "build/src/index.js",
   "scripts": {
diff --git a/src/commands/set.ts b/src/commands/set.ts
index 290d614..365db83 100644
--- a/src/commands/set.ts
+++ b/src/commands/set.ts
@@ -9,8 +9,8 @@ const isObject = (v) =>
   typeof v === "object" && v.required !== undefined && v.value !== undefined;
 
 const encode: EncodeFn = ({ value, path: initialPath }) => {
-  const allowPartial = value && value.allowPartial;
   const isObj = typeof value === "object";
+  const allowPartial = isObj && value.allowPartial !== undefined ? value.allowPartial : false;
   const attr = initialPath.split(".").pop() || "";
   const pairs = isObj
     ? Object.entries(value as any[]).map(([k, v]) =>
-- 
GitLab