1.0.8 • Published 3 years ago

iotdb-structured v1.0.8

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
3 years ago

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
}
1.0.8

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago