npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nv-buf-utf8

v1.0.7

Published

nv-buf-utf8 =============== - nv-buf-utf8 - a utf8 step-decoder, input one-byte each time. return-code-point-if-success , return-undefined-if-in-waiting-more-bytes

Downloads

9

Readme

nv-buf-utf8

  • nv-buf-utf8
  • a utf8 step-decoder, input one-byte each time. return-code-point-if-success , return-undefined-if-in-waiting-more-bytes
  • support two-modes: auto-recover AND throw-error
  • can observe state : [ 'INIT', 'U1', 'U2', 'U3', 'U4', 'ERROR' ]
  • its for remote decode , normally USELESS

install

  • npm install nv-buf-utf8

usage

     const {decd} = require("nv-buf-utf8");
     const {Mach} = decd.mach;
     

example

            var mach = new Mach()

            var buf = Buffer.from("我你");
            /*
            > "我".codePointAt(0)
            25105
            > "你".codePointAt(0)
            20320
            > 
            */

            > mach.input(buf[0])
            undefined
            > mach.input(buf[1])
            undefined
            > mach
            Mach(7) [{"cursor":5,"state":"U3","data":[230,136],"err_byte":0}] [
                5, 19, 0, 230,
              136,  0, 0
            ]
            > mach.input(buf[2])
            25105
            > 
            > mach
            Mach(7) [{"cursor":3,"state":"INIT","data":[],"err_byte":0}] [
              3, 16, 0, 0,
              0,  0, 0
            ]
            > 
            > mach.input(buf[3])
            undefined
            > mach.input(buf[4])
            undefined
            > mach.input(buf[5])
            20320
            > 
            > mach.input(buf[0])
            undefined
            > mach
            Mach(7) [{"cursor":4,"state":"U3","data":[230],"err_byte":0}] [
              4, 19, 0, 230,
              0,  0, 0
            ]
            > mach.lefted_
            [ 230 ]
            > mach.input(buf[1])
            undefined
            > mach.lefted_
            [ 230, 136 ]
            > mach.input(buf[2])
            25105
            > mach.lefted_
            []
            > 

METHODS

decode

            decd.mach.mach.cursor_                  decd.mach.mach.dict
            decd.mach.mach.disable_auto_recover     decd.mach.mach.enable_auto_recover      decd.mach.mach.err_byte_
            decd.mach.mach.input                    decd.mach.mach.is_auto_recover_enabled  decd.mach.mach.is_err
            decd.mach.mach.is_init                  decd.mach.mach.is_u2                    decd.mach.mach.is_u3
            decd.mach.mach.is_u4                    decd.mach.mach.lefted_                  decd.mach.mach.reset
            decd.mach.mach.state_code_              decd.mach.mach.state_name_



             mach: {
                STATES: [ 'INIT', 'U1', 'U2', 'U3', 'U4', 'ERROR' ],
                ERRORS: {
                  in_error_must_reset: 'in_error_must_reset',
                  fst_byte_invalid: 'first byte must be <0xxxxxxx> OR <110xxxxx> OR <1110xxxx> OR <11110xxx>',
                  follow_byte_invalid: 'follow byte must be <10xxxxxx>'
                },
                Mach: [class Mach extends Uint8Array] { ALGN_OFFSET: 3 },
                auto_recover_mach: Mach(7) [{"cursor":3,"state":"INIT","data":[],"err_byte":0}] [
                  3, 16, 0, 0,
                  0,  0, 0
                ],
                mach: Mach(7) [{"cursor":3,"state":"INIT","data":[],"err_byte":0}] [
                  3, 0, 0, 0,
                  0, 0, 0
                ]
              }

API

decode

            > decd.def
            {
              is_u1_head: [Function: is_u1_head],
              is_u2_head: [Function: is_u2_head],
              is_u3_head: [Function: is_u3_head],
              is_u4_head: [Function: is_u4_head],
              is_follow: [Function: is_follow],
              u2_to_code: [Function: u2_to_code],
              u3_to_code: [Function: u3_to_code],
              u4_to_code: [Function: u4_to_code],
              barr_to_code: [Function: barr_to_code]
            }
            >  

LICENSE

  • ISC