Socket
Book a DemoInstallSign in
Socket

@baethon/extract-jsonld

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baethon/extract-jsonld

Simple utility for extracting JSON-LD data from given URL

2.0.0
latest
npmnpm
Version published
Maintainers
2
Created
Source

extract-jsonld.js

Simple utility for extracting JSON-LD data from given URL

Usage

// extract :: String -> Future e Object
const extract = require('@baethon/extract-jsonld')

// start extraction
extract('http://some.site/with-embeded-jsonld').fork(
  console.warn,
  jsonld => {}
)

// or convert Future to promise
const jsonld = await extract('http://some.site/with-embeded-jsonld').promise()

How it works

The idea is simple: load JSDOM document find the right script and JSON.parse its contents.

Whole thing is wrapped inside Future monad. So the process will start after calling fork() or promise() methods.

Script will fail when:

  • fails to load JSDOM
  • fails to find script tag
  • fails to parse contents of the script

Keywords

jsdom

FAQs

Package last updated on 08 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.