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

ipld-schema-describer

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipld-schema-describer

IPLD Schema Describer

  • 3.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ipld-schema-describer

Describe JavaScript object forms using IPLD Schemas.

Example

import { describe } from 'ipld-schema-describer'
import schemaPrint from 'ipld-schema/print.js'

const obj = {
  foo: [1, 'one', true],
  bar: [1, 2, 3, 4],
  baz: 'baz'
}

const { schema, root } = describe(obj)
console.log(schemaPrint(schema))
console.log('\nRoot:', root)

Prints:

type Struct_1 struct {
  f0 Int
  f1 String
  f2 Bool
} representation tuple

type List_1 [Int]

type Struct_2 struct {
  foo Struct_1
  bar List_1
  baz String
}

Root: Struct_2

Limitations

Objects must conform to the IPLD Data Model, so undefined is not supported and complex objects such as Date, RegExp and others should be avoided. Circular references are also not supported.

The resulting IPLD Schema is only able to describe the raw representation layout. IPLD Schemas are capable of describing complex shapes that cannot be inferred without additional information. Unions and Enums in particular are not able to be inferred. The Schema output from this library can be used as the basis of the formation of a more correct and concice Schema for any data layout. Read more in the IPLD Schemas documentation.

Copyright 2020 Rod Vagg

Licensed under Apache 2.0 (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)

Keywords

FAQs

Package last updated on 15 Aug 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

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