lwmqn-util
Advanced tools
Comparing version 0.0.8 to 0.1.0
44
index.js
'use strict'; | ||
var lwm2mid = require('lwm2m-id'); | ||
@@ -18,6 +17,6 @@ | ||
var ut = { | ||
getCmd: lwm2mid.getCmd, | ||
getOid: lwm2mid.getOid, | ||
getRid: lwm2mid.getRid, | ||
getRspCode: lwm2mid.getRspCode, | ||
getCmd: null, // define below | ||
getOid: null, // define below | ||
getRid: null, // define below | ||
getRspCode: null, // define below | ||
getSpecificResrcChar: lwm2mid.getRdef | ||
@@ -29,2 +28,7 @@ }; | ||
/*************************************************************************************************/ | ||
ut.getCmd = function (id) { | ||
var cmdItem = lwm2mid.getCmd(id); | ||
return cmdItem ? { key: cmdItem.key, value: cmdItem.value } : undefined; | ||
}; | ||
ut.cmdNum = function (id) { | ||
@@ -40,5 +44,10 @@ var cmdNum = ut.getCmd(id); | ||
ut.getOid = function (oid) { | ||
var oidItem = lwm2mid.getOid(oid); | ||
return oidItem ? { key: oidItem.key, value: oidItem.value } : undefined; | ||
}; | ||
ut.oidKey = function (oid) { | ||
var oidItem = lwm2mid.getOid(oid); | ||
return oidItem ? oidItem.key : oid; // if undefined, return itself | ||
return oidItem ? oidItem.key : oid.toString(); // if undefined, return itself | ||
}; | ||
@@ -53,11 +62,18 @@ | ||
ut.getRid = function (oid, rid) { | ||
var ridItem = lwm2mid.getRid(oid, rid); | ||
return ridItem ? { key: ridItem.key, value: ridItem.value } : undefined; | ||
}; | ||
ut.ridKey = function (oid, rid) { | ||
var ridItem; | ||
if (typeof rid === 'undefined') | ||
ridItem = lwm2mid.getRid(oid); // here, oid is rid | ||
else | ||
if (typeof rid === 'undefined') { | ||
rid = oid; | ||
ridItem = lwm2mid.getRid(rid); // here, oid is rid | ||
} else { | ||
ridItem = lwm2mid.getRid(oid, rid); | ||
} | ||
return ridItem ? ridItem.key : rid; // if undefined, return itself | ||
return ridItem ? ridItem.key : rid.toString(); // if undefined, return itself | ||
}; | ||
@@ -75,2 +91,7 @@ | ||
ut.getRspCode = function (code) { | ||
var rspItem = lwm2mid.getRspCode(code); | ||
return rspItem ? { key: rspItem.key, value: rspItem.value } : undefined; | ||
}; | ||
ut.rspCodeKey = function (code) { | ||
@@ -190,2 +211,3 @@ var k = ut.getRspCode(code); | ||
if (typeof str !== 'string') | ||
@@ -197,3 +219,3 @@ throw new TypeError('Input str should be a string.'); | ||
} catch (e) { | ||
return; | ||
return str; | ||
} | ||
@@ -200,0 +222,0 @@ return obj; |
{ | ||
"name": "lwmqn-util", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"description": "Utility for LWMQN MQTT-Shepherd Server and MQTT-Node Client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -467,6 +467,6 @@ # lwmqn-util | ||
```js | ||
ut.dotPath('dev.0.sensor.value'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.dotPath('.dev.0.sensor.value'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.dotPath('/dev.0.sensor/value/'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.dotPath('/dev/0/sensor/value/'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.pathItems('dev.0.sensor.value'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.pathItems('.dev.0.sensor.value'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.pathItems('/dev.0.sensor/value/'); // [ 'dev', '0', 'sensor', 'value' ] | ||
ut.pathItems('/dev/0/sensor/value/'); // [ 'dev', '0', 'sensor', 'value' ] | ||
``` | ||
@@ -495,4 +495,4 @@ ******************************************** | ||
a1: { | ||
a11: 1 | ||
a12: 'hi' | ||
a11: 1, | ||
a12: 'hi', | ||
}, | ||
@@ -499,0 +499,0 @@ a2: 'foo' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
89633
9
1140
0