Giter Site home page Giter Site logo

sejong's Introduction

Sejong Buffer

Crate NPM API MIT licensed

Sejong Buffer is a buffer that receives ASCII bytes from standard English keyboard and sends out UTF-32 Hangul string. This buffer allows deletion by Jamo.

This rust library can be compiled as a WASM library or as part of another rust program.

USE

To use as an NPM package

Do NOT run in a node app, this package can only run in browser

Install: npm install sejong-buffer

In apps that built with webpack:

import('sejong-buffer').then(buffer => {
    buffer.put('d');
    buffer.put('k');
    buffer.put('s');
    buffer.put('s');
    buffer.put('u');
    buffer.put('d');

    console.assert(buffer.to_string() === '안녕');

    buffer.put('s');
    console.assert(buffer.to_string() === '안녕ㄴ');

    buffer.pop();
    console.assert(buffer.out() === '안녕');
    console.assert(buffer.out() === '');
});

To use in Rust program

Install: cargo install sejong

use sejong::{Buffer, Byte};
let mut buf = Buffer::default();
buf.put(Byte::NG as u8);
buf.put(Byte::A as u8);
buf.put(Byte::N as u8);
buf.put(Byte::N as u8);
buf.put(Byte::YEO as u8);
buf.put(Byte::NG as u8);

assert_eq!(buf.to_string(), "안녕");

buf.put(Byte::N as u8);
assert_eq!(buf.to_string(), "안녕ㄴ");

buf.pop();
assert_eq!(buf.out(), "안녕");
assert_eq!(buf.out(), "");

BUILD

WASM

  1. Install wasm-pack: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
  2. Build the wasm npm package: wasm-pack build --release -- --features wasm

rust lib

No additional step. Just use as regular rust library.

sejong's People

Contributors

funfoolsuzi avatar

Stargazers

cppxor2arr avatar

Watchers

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