-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beta-v1.2.0' into master
- Loading branch information
Showing
8 changed files
with
64 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
const fs = require('fs') | ||
const util = require('util') | ||
const fs = require('fs') | ||
|
||
|
||
module.exports.requireJSON = async function requireJSON(filepath) { | ||
let data = await util.promisify(fs.readFile)(filepath, 'utf8') | ||
module.exports.requireJSON = async (filepath) => { | ||
const data = fs.promises.readFile(filepath, 'utf8') | ||
let object; | ||
try { | ||
object = JSON.parse(data) | ||
} catch (e) { | ||
e.filename = filepath | ||
console.error(e) | ||
throw e | ||
object = JSON.parse(await data) | ||
} catch (err) { | ||
err.filename = filepath | ||
console.error(err) | ||
throw err | ||
} | ||
return object | ||
} | ||
|
||
|
||
module.exports.requireJSONSync = function requireJSONSync(filepath) { | ||
let data = fs.readFileSync(filepath, 'utf8') | ||
module.exports.requireJSONSync = (filepath) => { | ||
const data = fs.readFileSync(filepath, 'utf8') | ||
let object; | ||
try { | ||
object = JSON.parse(data) | ||
} catch (e) { | ||
e.filename = filepath | ||
console.error(e) | ||
throw e | ||
} catch (err) { | ||
err.filename = filepath | ||
console.error(err) | ||
throw err | ||
} | ||
return object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
import { JSONValue, JSONObject, JSONArray, JSONPrimitive } from './json.d' | ||
import type {JSONObject, JSONPrimitive} from './json.d' | ||
|
||
|
||
/** | ||
* A single JSON-LD document. | ||
* @see https://github.com/json-ld/json-ld.org/blob/1.0/schemas/jsonld-schema.json | ||
*/ | ||
export interface JSONLDDocument extends JSONLDObject { | ||
'@context'?: Context[]|Context|null; | ||
'@graph'?: { [key: string]: JSONLDObject; }|JSONLDObject[]; | ||
[key: string]: (JSONLDObject|JSONPrimitive)[]|JSONLDObject|JSONPrimitive|undefined; | ||
'@context'?: Context[] | Context | null; | ||
'@graph'?: { | ||
[key: string]: JSONLDObject; | ||
} | JSONLDObject[]; | ||
[key: string]: (JSONLDObject | JSONPrimitive)[] | JSONLDObject | JSONPrimitive | undefined; | ||
} | ||
|
||
type Context = { | ||
[key: string]: { | ||
'@id': string; | ||
'@type': '@id'; | ||
}|{ | ||
'@reverse': string; | ||
}|string; | ||
}|string | ||
|
||
export interface JSONLDObject extends JSONObject { | ||
/** | ||
* @format uri | ||
*/ | ||
'@base'?: string|null; | ||
'@container'?: '@index'|'@list'|'@set'|null; | ||
'@base'?: string | null; | ||
'@container'?: '@index' | '@list' | '@set' | null; | ||
/** | ||
* @format uri | ||
*/ | ||
'@id'?: string; | ||
'@language'?: string|null; | ||
'@language'?: string | null; | ||
'@list'?: JSONLDObject[]; | ||
'@reverse'?: { [key: string]: JSONLDObject; }|string|null; | ||
'@reverse'?: { | ||
[key: string]: JSONLDObject; | ||
} | string | null; | ||
'@set'?: JSONLDObject[]; | ||
'@type'?: string[]|string|null; | ||
'@value'?: string|number|boolean|null; | ||
'@type'?: string[] | string | null; | ||
'@value'?: string | number | boolean | null; | ||
/** | ||
* @format uri | ||
*/ | ||
'@vocab'?: string|null; | ||
[key: string]: (JSONLDObject|JSONPrimitive)[]|JSONLDObject|JSONPrimitive|undefined; | ||
'@vocab'?: string | null; | ||
[key: string]: (JSONLDObject | JSONPrimitive)[] | JSONLDObject | JSONPrimitive | undefined; | ||
} | ||
|
||
type Context = { | ||
[key: string]: { | ||
'@id': string; | ||
'@type': '@id'; | ||
} | { | ||
'@reverse': string; | ||
} | string; | ||
} | string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// WARNING - this file is deprecated. you should import from `@types/json-schema` directly. | ||
|
||
|
||
import { JSONSchema7Definition, JSONSchema7 } from 'json-schema' | ||
import type {JSONSchema7Definition, JSONSchema7} from 'json-schema' | ||
|
||
export { | ||
JSONSchema7Definition, | ||
JSONSchema7, | ||
JSONSchema7Definition as JSONSchema, // WARNING{DEPRECATED} | ||
JSONSchema7 as JSONSchemaObject, // WARNING{DEPRECATED} | ||
JSONSchema7Definition as JSONSchema, // WARNING: DEPRECATED | ||
JSONSchema7 as JSONSchemaObject, // WARNING: DEPRECATED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
/** | ||
* Any JSON value. | ||
*/ | ||
export type JSONValue = JSONObject|JSONArray|JSONPrimitive | ||
export type JSONValue = JSONObject | JSONArray | JSONPrimitive | ||
|
||
/** | ||
* Any JSON object. | ||
*/ | ||
export interface JSONObject { | ||
[key: string]: JSONValue|undefined; | ||
[key: string]: JSONValue | undefined; | ||
} | ||
|
||
/** | ||
* Any JSON array. | ||
*/ | ||
export interface JSONArray extends Array<JSONValue> {} | ||
export type JSONArray = Array<JSONValue> | ||
|
||
/** | ||
* Any non-object, non-array JSON value. | ||
*/ | ||
export type JSONPrimitive = string|number|boolean|null | ||
export type JSONPrimitive = string | number | boolean | null |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters