Coder Social home page Coder Social logo

maniartech / internetobject-js Goto Github PK

View Code? Open in Web Editor NEW
44.0 44.0 7.0 1.31 MB

Official JavaScript and TypeScript parser for Internet Object

Home Page: https://www.internetobject.org

License: ISC License

TypeScript 99.93% JavaScript 0.07%
api http internet internet-object internetobject json parser rest rest-api rpc

internetobject-js's People

Contributors

aamironline avatar dependabot[bot] avatar kabironline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

internetobject-js's Issues

Load JavaScript pure objects into Internet Object

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

Improve TypeRegistry workflow so that single typedef can handle multiple types.

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"))

Add facility to compile schema

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
      }
    }
  }
}

Add support for raw string

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.