Coder Social home page Coder Social logo

viperet / xml-zero.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from holloway/xml-zero.js

0.0 0.0 0.0 326 KB

Friendly and forgiving HTML5/XML5 parser that supports React JSX, and uses zero-copy techniques

License: GNU General Public License v3.0

JavaScript 99.85% HTML 0.15%

xml-zero.js's Introduction

xml-zero.js

Friendly and forgiving HTML5/XML5 parser that supports React JSX, and uses zero-copy techniques to allow parsing large files efficiently.

Most markup parsers convert a string of markup into a nested map(hash/dict) of keys and values, with each of these allocated as separate variables in memory. This means that a 10MB XML file may balloon to 100MB of memory.

A different technique would be to retain the original string and generate an index of string offsets. Because these offsets are just numbers they can be packed more efficiently (a tutorial on zero-copy approaches).

This software is beta and it doesn't yet work

Features

  • Fault tolerant like HTML5/XML5.
    • Valueless-attributes like HTML5 / XML5 eg <input multiple type=file>
    • Attribute values may be quoted (E.g. <tag "some key"=false/> ) or not
    • React JSX attributes and in text (not executed of course, but they're parsed as distinct node types).
    • Multiple root nodes. Doesn't care about well-formedness. GIGO.
  • Minimising memory use through Zero-Copy techniques.
  • Tiny, no dependencies, and can run in Web Workers (e.g. doesn't use DOM APIs).
  • Safer by removing SGML cruft.
    No support for external DTD resolution, or nested entity expansion. Only default entities in XML, NCRs, and HTML5 named entities are supported.
  • Lots of tests.

Out of scope

  • Complete W3C DOM (at least for now) although we will follow their API naming conventions where reasonable.
  • HTML5 implied tags (e.g. won't automatically create tags such as <html>, <head>, <tbody>, ...etc).

Install

npm install xml-zero-lexer

npm install xml-zero-beautify

npm install whats-the-damage

(more packages to come, but i'm making it modular)

Progress

  • Lexer (2.6KB no dependencies, minified and gzipped)
  • Beautifier (4KB all dependencies, minified and gzipped)
  • What's The Damage benchmarker that measures time/memory/CPU of scripts
  • A W3C DOM-like API
  • Editable XML (by way of making new strings and leaving the original untouched, so it's still immutable)

References

xml-zero.js's People

Contributors

holloway avatar viperet avatar

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.