libshv-js 3.6.4 → 3.6.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/package.json +1 -1
- package/src/cpon.ts +12 -3
- package/src/ws-client.ts +1 -1
package/package.json
CHANGED
package/src/cpon.ts
CHANGED
|
@@ -674,7 +674,7 @@ class CponWriter {
|
|
|
674
674
|
ctx: PackContext;
|
|
675
675
|
nestLevel = 0;
|
|
676
676
|
|
|
677
|
-
constructor(private readonly indentString?: string) {
|
|
677
|
+
constructor(private readonly indentString?: string, private oneLiners: OneLiners = OneLiners.Yes) {
|
|
678
678
|
this.ctx = new PackContext();
|
|
679
679
|
}
|
|
680
680
|
|
|
@@ -949,6 +949,10 @@ class CponWriter {
|
|
|
949
949
|
}
|
|
950
950
|
|
|
951
951
|
private isOneLiner(value: MetaMap | ShvMap | IMap | List) {
|
|
952
|
+
if (this.oneLiners === OneLiners.No) {
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
|
|
952
956
|
const keyThreshold = Array.isArray(value) ? 10 : 5;
|
|
953
957
|
|
|
954
958
|
if (Array.isArray(value)) {
|
|
@@ -971,8 +975,13 @@ class CponWriter {
|
|
|
971
975
|
}
|
|
972
976
|
}
|
|
973
977
|
|
|
974
|
-
|
|
975
|
-
|
|
978
|
+
export enum OneLiners {
|
|
979
|
+
Yes,
|
|
980
|
+
No,
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
const toCpon = (value: RpcValue, indentString?: string, oneLiners: OneLiners = OneLiners.Yes) => {
|
|
984
|
+
const wr = new CponWriter(indentString, oneLiners);
|
|
976
985
|
wr.write(value);
|
|
977
986
|
return new TextDecoder().decode(wr.ctx.buffer());
|
|
978
987
|
};
|
package/src/ws-client.ts
CHANGED
|
@@ -387,7 +387,7 @@ class WsClient {
|
|
|
387
387
|
const makeLoginParams = (loginMap: ShvMap) => makeMap({
|
|
388
388
|
login: loginMap,
|
|
389
389
|
options: makeMap({
|
|
390
|
-
device: options.mountPoint === 'string' ? makeMap({mountPoint: options.mountPoint}) : undefined,
|
|
390
|
+
device: typeof options.mountPoint === 'string' ? makeMap({mountPoint: options.mountPoint}) : undefined,
|
|
391
391
|
}),
|
|
392
392
|
});
|
|
393
393
|
|