3.0.8 • Published 3 months ago

ipld-schema-describer v3.0.8

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
3 months ago

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.

License & Copyright

Copyright 2020 Rod Vagg

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

3.0.8

3 months ago

3.0.7

3 months ago

3.0.6

4 months ago

3.0.5

4 months ago

3.0.4

7 months ago

3.0.3

9 months ago

3.0.2

9 months ago

3.0.1

10 months ago

3.0.0

10 months ago

2.0.1

1 year ago

2.0.0

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.0

4 years ago