Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ts-common/json

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-common/json - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

35

index.d.ts

@@ -1,20 +0,17 @@

export declare namespace Json {
interface ObjectProperties {
readonly [name: string]: Unknown;
}
type Object = object & ObjectProperties;
interface ArrayProperties {
readonly [index: number]: Unknown;
}
type ArrayObject = any[] & ArrayProperties;
type Unknown = null | boolean | string | number | Object | ArrayObject;
interface Visitor<T> {
asNull(): T;
asBoolean(value: boolean): T;
asString(value: string): T;
asNumber(value: number): T;
asObject(value: Object): T;
asArray(value: ReadonlyArray<Unknown>): T;
}
function visit<T>(value: Unknown, visitor: Visitor<T>): T;
export interface ObjectProperties {
readonly [name: string]: Json | undefined;
}
export declare type Object = object & ObjectProperties;
export declare type ArrayObject = Array<any>;
export declare type Json = null | boolean | string | number | Object | ArrayObject;
export interface Visitor<T> {
asNull(): T;
asBoolean(value: boolean): T;
asString(value: string): T;
asNumber(value: number): T;
asObject(value: ObjectProperties): T;
asArray(value: ReadonlyArray<Json>): T;
}
export declare function visit<T>(value: Json, visitor: Visitor<T>): T;
export declare const parse: (str: string) => Json;
export declare const stringify: (json: Json) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Json;
(function (Json) {
function visit(value, visitor) {
if (value === null) {
return visitor.asNull();
}
if (typeof value === "boolean") {
return visitor.asBoolean(value);
}
if (typeof value === "string") {
return visitor.asString(value);
}
if (typeof value === "number") {
return visitor.asNumber(value);
}
if (value instanceof Array) {
return visitor.asArray(value);
}
return visitor.asObject(value);
function visit(value, visitor) {
if (value === null) {
return visitor.asNull();
}
Json.visit = visit;
})(Json = exports.Json || (exports.Json = {}));
if (typeof value === "boolean") {
return visitor.asBoolean(value);
}
if (typeof value === "string") {
return visitor.asString(value);
}
if (typeof value === "number") {
return visitor.asNumber(value);
}
if (value instanceof Array) {
return visitor.asArray(value);
}
return visitor.asObject(value);
}
exports.visit = visit;
exports.parse = JSON.parse;
exports.stringify = JSON.stringify;
{
"name": "@ts-common/json",
"version": "0.0.1",
"version": "0.0.2",
"description": "JSON Data Type",

@@ -8,3 +8,4 @@ "main": "index.js",

"tsc": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"prepack": "npm install & tsc"
},

@@ -11,0 +12,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc