iotdb-links

1.0.5 • Public • Published

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"'
})

Package Sidebar

Install

npm i iotdb-links

Weekly Downloads

4

Version

1.0.5

License

Apache-2.0

Unpacked Size

21.6 kB

Total Files

7

Last publish

Collaborators

  • dpjanes