New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

typeof-sjsonc

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeof-sjsonc

[在线体验地址](https://wulunyi.github.io/typeof-sjsonc-web/build/index.html)

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

typeof-sjsoncnpm version

在线体验地址

将 similar jsonc 转换为 TypeScript 的 interface

{
    // 123
    "a": 123,
    /** true */
    b: true,
    c: [{d: 'test'}]
}
export interface Root {
    /** 123 */
    a: number;
    /** true */
    b: boolean;
    c: Array<{
        d: string;
    }>;
}

Usage

npm

npm i typeof-sjsonc --save

yarn

yarn add typeof-sjsonc --save

use

import { typeofSjsonc } from 'typeof-sjsonc';

typeofSjsonc(
    '//123\n{a: {//111\naa/**22*/: 123, /**eee*/ b: true,/**bbb*/ // aaa \n}, b: [123,true, {//111\naa/**22*/: 123, /**eee*/ b: true,/**bbb*/ // aaa \n}]} \n/**12*/{c: 123}',
    'aaa'
);

Result

/** 123 */
export interface Aaa {
    a: {
        /**
         * 111
         * 22
         * eee
         */
        aa: number;
        /**
         * bbb
         * aaa
         */
        b: boolean;
    };
    b: Array<
        | number
        | boolean
        | {
              /**
               * 111
               * 22
               * eee
               */
              aa: number;
              /**
               * bbb
               * aaa
               */
              b: boolean;
          }
    >;
}

/** 12 */
export interface Aaa1 {
    c: number;
}

API

typeofSjsonc(jsonc: string, name?: string, options?: {disallowComments?: boolean})

  • jsonc: 待抓换的字符串
  • name: interface 的名字,默认为 root
  • options: 配置项
    • disallowComments: 不产出注释,默认为 false
    • separate: 是否将子结构分割出单独的 interface,默认值 false
    • prifix: 是否添加前缀,例如添加 I

License

MIT

FAQs

Package last updated on 22 Jul 2023

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