iotdb-links
v1.0.5
Published
Code for dealing with CoRE Link Format (RFC 6690) and similar
Downloads
32
Readme
iotdb-links
Code for dealing with CoRE Link Format (RFC 6690) and similar
See also
Although fully stand-alone, this module is part of the IOTDB project. Find out more about this here https://homestar.io/about.
Notes
- quoting functions are probably not 100% compliant, especially with unicode. Please help.
Functions
These are almost inverses of each other, except that 'parse()' can accept a wider range of values than 'produce()' will generate.
parse
Parse a Link Header
const value = '<tcp://mqtt.iotdb.org:1883>; rel="mqtt"; payload=PUT; topic="bedroom/light"'
const result = iotdb_link.parse(value)
const expect = {
'tcp://mqtt.iotdb.org:1883': {
rel: 'mqtt',
payload: 'PUT',
topic: 'bedroom/light'
}
}
You can also get a flattened version
const value = '<tcp://mqtt.iotdb.org:1883>; rel="mqtt"; payload=PUT; topic="bedroom/light"'
const result = iotdb_link.parse.flat(value)
const expect = {
url: 'tcp://mqtt.iotdb.org:1883',
rel: 'mqtt',
payload: 'PUT',
topic: 'bedroom/light'
}
produce
Produce a Link Header
const linkd = {
"/djkd" : {
"a": "1",
},
"/b/c": {
"c": "1",
"d": "2",
},
}
iotdb_link.produce(linkd, function(error, result) {
const expect = '</djkd>;a="1",</b/c>;c="1";d="2"'
})