iotdb-structured

1.0.8 • Public • Published

iotdb-structured

Helpers for dealing with schema.org-like structured data

functions

For all the examples, let's see you have a data structure that looks like this

{
    "@context": "https://schema.org",
    "schema:weight": {
        "@type": "schema:StructuredValue",
        "schema:value": 15,
        "schema:unitCode": "unit:Gram"
    },
    "schema:priceSpecification": [
        {
            "@type": "schema:PriceSpecification",
            "schema:value": 15.15,
            "schema:priceCurrency": "USD",
        },
        {
            "@type": "schema:PriceSpecification",
            "schema:value": 21.01,
            "schema:priceCurrency": "USD",
        }
    ]
}

weight

These are for links similar to schema:weight.

Get weight in Grams (the default)

const structured = require("iotdb-structured")

const g = structured.weight.total(data["schema:weight"])

Get weight in pounds

See iotdb-uom-qudt for units available. Not that many right now, but we can add more. The semantic vocabulary is from QUDT

const structured = require("iotdb-structured")

const lbs = structured.weight.total(data["schema:weight"], {
    unitCode: "unit:PoundMass"
})

prices

These are for links similar to schema:priceSpecification.

Get prices

const d = structured.priceSpecification.totals(data["schema:priceSpecification"])

The result d will look like:

{
    "USD": 36.16
}

Readme

Keywords

none

Package Sidebar

Install

npm i iotdb-structured

Weekly Downloads

20

Version

1.0.8

License

Apache-2.0

Unpacked Size

27.7 kB

Total Files

9

Last publish

Collaborators

  • dpjanes