Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lwmqn-util

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lwmqn-util - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

test/function.test.js

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'

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc