maniartech / internetobject-js Goto Github PK
View Code? Open in Web Editor NEWOfficial JavaScript and TypeScript parser for Internet Object
Home Page: https://www.internetobject.org
License: ISC License
Official JavaScript and TypeScript parser for Internet Object
Home Page: https://www.internetobject.org
License: ISC License
const io = new InternetObject({ name: "Spiderman", age: 25 }, "name, age")
const ioString = io.toString() // Without schema
const ioStringWithSchema = io.toString(true) // With schema
// Print ineternet object strings.
console.log(ioString) // Without schema
console.log(ioStringWithSchema) // With schema
Without schema prints following output.
Spiderman, 25
With schema prints following output.
name, age
---
Spiderman, 25
The website https://internetobject.org/ doesn't work. The docs work fine though: https://docs.internetobject.org/.
Add support for following string subtypes
Remove all error todos and provide better error handling!
Currently a TypeDef
class can't handle multiple related types! Change it so that it allows you to do that.
Instead of:
TypedefRegistry.register(new NumberDef())
It should be:
TypedefRegistry.register("number", new NumberDef())
TypedefRegistry.register("integer", new NumberDef("integer"))
TypedefRegistry.register("int32", new NumberDef("int32"))
TypedefRegistry.register("int16", new NumberDef("int16"))
TypedefRegistry.register("byte", new NumberDef("byte"))
TypedefRegistry.register("float", new NumberDef("float"))
When processed, Parser.toSchema method should return compiled schema with following structure
Source schema string...
name:{ string, max_length: 20 }, age?:number, address?:{ building:{ max_length: 100}, street?, city }
Should be compiled into...
const compiled = {
name: {
index: 0,
type: "string",
max_length: 20,
optional: false
},
age: {
index: 1,
type: "number",
optional: true
},
address: {
index: 2,
type: "object",
optional: true,
schema: {
building: {
index: 1,
type: "string",
max_length: 100
}
}
}
}
Converts tokens One, Two, Three, { A, B, C}, [T, F]
into the following hierarchy
{
type: 'object',
values: [
'One', 'Two', 'Three', {
type: 'object',
values: ['A', 'B', 'C']
}, {
type: 'array',
values: ['T', 'F']
}
]
}
The raw strings do not escape characters other than quote "
. It is useful for referencing complex string mixed of various symbols such as regular expression patterns, passwords, file path etc.
The pattern in the following schema definition is quite readable due to the virtue of raw string format.
name, age, phone:{
string, pattern: @"^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$"
}
Escaping the raw string!
@"This is a raw string with the escaped quotation "" mark!"
It renders the following output.
This is a raw string with the escaped quotation " mark!
Add following number subtypes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.