Git Product home page Git Product logo

magic-string-rs's Introduction


magic-string-rs

CI crates NPM version

100% API compatible (port) MagicString by Rich-Harris implementation for Node and modern browsers, also, for rust, of course.


🔧 Installation

Rust

Add it as a dependency in a Cargo project.

# Cargo.toml

[dependency]
magic_string = "x.x.x"

Node

$ npm install @napi-rs/magic-string

Benchmark

Running "toString" suite...
Progress: 100%

  MagicString:
    226 614 ops/s, ±0.08%   | slowest, 42.65% slower

  MagicStringRust:
    395 166 ops/s, ±1.83%   | fastest

Finished 2 cases!
  Fastest: MagicStringRust
  Slowest: MagicString
  
Running "generateDecodedMap" suite...
Progress: 100%

  MagicString:
    173 590 ops/s, ±0.55%   | slowest, 18.84% slower

  MagicStringRust:
    213 893 ops/s, ±0.75%   | fastest

Finished 2 cases!
  Fastest: MagicStringRust
  Slowest: MagicString
  
Running "generateMap.toString" suite...
Progress: 100%

  MagicString:
    141 658 ops/s, ±0.53%   | slowest, 31.48% slower

  MagicStringRust:
    206 744 ops/s, ±0.64%   | fastest

Finished 2 cases!
  Fastest: MagicStringRust
  Slowest: MagicString

Supported APIs

  • generateMap
  • generateDecodedMap
  • toString
  • prepend
  • append
  • prependLeft
  • prependRight
  • appendLeft
  • appendRight
  • overwrite
  • trim
  • trimStart
  • trimEnd
  • trimLines
  • isEmpty
  • move
  • indent
  • addSourcemapLocation
  • clone
  • remove
  • slice
  • snip

Credits

The original project magic-string is really awesome, you should check it out and we made this project even furthur for better performance.

License

MIT

magic-string-rs's People

Contributors

h-a-n-a avatar brooooooklyn avatar

Watchers

James Cloos 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.