UNPKG

@jeswr/prefixcc

Version:

A utility library to lookup prefixes and uris on prefixcc

30 lines (29 loc) 1.48 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchContext = exports.fetchJson = void 0; // TODO: Use universal fetch here const cross_fetch_1 = require("cross-fetch"); function fetchJson(url, options) { var _a; return __awaiter(this, void 0, void 0, function* () { // Select the correct fetch function const fetchFn = (_a = options === null || options === void 0 ? void 0 : options.fetch) !== null && _a !== void 0 ? _a : cross_fetch_1.fetch; return (yield fetchFn(url)).json(); }); } exports.fetchJson = fetchJson; function fetchContext(url, options) { return __awaiter(this, void 0, void 0, function* () { return (yield fetchJson(url, options))['@context']; }); } exports.fetchContext = fetchContext;