From 1a72099970502a63bd06d1b6870f3b40bd580a33 Mon Sep 17 00:00:00 2001 From: joelbandi Date: Tue, 2 Aug 2016 17:07:38 -0700 Subject: [PATCH] Keyvalue.js --- src/js/iotjs/orig/keyvalue.js | 65 +++++++++++++++ src/js/iotjs/orig/lastmessage.js | 8 +- src/js/iotjs/src/iotstring.js | 137 +++++++++++++++++-------------- src/js/iotjs/src/keyvalue.js | 99 ++++++++++++++++++++++ 4 files changed, 244 insertions(+), 65 deletions(-) create mode 100644 src/js/iotjs/orig/keyvalue.js create mode 100644 src/js/iotjs/src/keyvalue.js diff --git a/src/js/iotjs/orig/keyvalue.js b/src/js/iotjs/orig/keyvalue.js new file mode 100644 index 0000000..375b29d --- /dev/null +++ b/src/js/iotjs/orig/keyvalue.js @@ -0,0 +1,65 @@ +class KeyValue extends Entry{ + constructor(slot,_key,_value){ + if(!(slot instanceof Slot && _key instanceof IoTString && _value instanceof IoTString)){ + throw new Error('Argument error '); + } + super(slot); + this.key = _key; + this.value = _value; + } + getKey(){ + return this.key; + } + getValue(){ + return this.value; + } + decode(slot,bb){ + if(!(slot instanceof Slot && bb instanceof ByteBuffer)){ + throw new Error('Argument error'); + } + var keylength = bb.getByte(); + var valuelength = bb.getByte(); + var key = new Uint8Array(keylength); + var value = new Uint8Array(valuelength); + var keystring = ''; + for(var i =0 ;i