@ts-common/json
Advanced tools
Comparing version 0.0.21 to 0.1.0
@@ -15,10 +15,10 @@ import { MutableStringMap, StringMap } from "@ts-common/string-map"; | ||
export interface Visitor<T> { | ||
asNull(): T; | ||
asBoolean(value: boolean): T; | ||
asString(value: string): T; | ||
asNumber(value: number): T; | ||
asArray(value: JsonArray): T; | ||
asObject(value: JsonObject): T; | ||
readonly asNull: () => T; | ||
readonly asBoolean: (value: boolean) => T; | ||
readonly asString: (value: string) => T; | ||
readonly asNumber: (value: number) => T; | ||
readonly asArray: (value: JsonArray) => T; | ||
readonly asObject: (value: JsonObject) => T; | ||
} | ||
export declare function visit<T>(value: Json, visitor: Visitor<T>): T; | ||
export declare const visit: <T>(value: Json, visitor: Visitor<T>) => T; | ||
export declare const parse: (str: string) => Json; | ||
@@ -25,0 +25,0 @@ export declare const stringify: (json: Json) => string; |
15
index.js
@@ -5,13 +5,10 @@ "use strict"; | ||
const _ = tslib_1.__importStar(require("@ts-common/iterator")); | ||
function visit(value, visitor) { | ||
return value === null ? visitor.asNull() : | ||
typeof value === "boolean" ? visitor.asBoolean(value) : | ||
typeof value === "string" ? visitor.asString(value) : | ||
typeof value === "number" ? visitor.asNumber(value) : | ||
_.isArray(value) ? visitor.asArray(value) : | ||
visitor.asObject(value); | ||
} | ||
exports.visit = visit; | ||
exports.visit = (value, visitor) => value === null ? visitor.asNull() : | ||
typeof value === "boolean" ? visitor.asBoolean(value) : | ||
typeof value === "string" ? visitor.asString(value) : | ||
typeof value === "number" ? visitor.asNumber(value) : | ||
_.isArray(value) ? visitor.asArray(value) : | ||
visitor.asObject(value); | ||
exports.parse = JSON.parse; | ||
exports.stringify = JSON.stringify; | ||
exports.isPrimitive = (value) => value === null || typeof value !== "object"; |
{ | ||
"name": "@ts-common/json", | ||
"version": "0.0.21", | ||
"version": "0.1.0", | ||
"description": "JSON Data Type", | ||
@@ -27,8 +27,8 @@ "main": "index.js", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.3" | ||
"typescript": "^3.1.6" | ||
}, | ||
"dependencies": { | ||
"@ts-common/iterator": "^0.0.39", | ||
"@ts-common/string-map": "^0.1.1" | ||
"@ts-common/iterator": "^0.1.0", | ||
"@ts-common/string-map": "^0.2.0" | ||
} | ||
} |
@@ -1,1 +0,3 @@ | ||
# JSON Data Type | ||
# JSON Data Type | ||
[![Build Status](https://dev.azure.com/ts-common/ts-common/_apis/build/status/ts-common.json)](https://dev.azure.com/ts-common/ts-common/_build/latest?definitionId=9) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
14442
40
+ Added@ts-common/iterator@0.1.50.2.0(transitive)
+ Added@ts-common/string-map@0.2.6(transitive)
+ Added@ts-common/tuple@0.0.6(transitive)
- Removed@ts-common/iterator@0.0.380.0.39(transitive)
- Removed@ts-common/string-map@0.1.1(transitive)
- Removed@ts-common/tuple@0.0.0(transitive)
Updated@ts-common/iterator@^0.1.0
Updated@ts-common/string-map@^0.2.0