1.1.1 • Published 5 months ago

fast-sjis-encoder v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

fast-sjis-encoder

Fast Shift-JIS(MS932) encoder - About 2x faster than iconv-lite

Installation

npm install fast-sjis-encoder

Usage

Browser

<script src="https://cdn.jsdelivr.net/npm/fast-sjis-encoder"></script>

ES Modules

import sjis from 'fast-sjis-encoder';

CommonJS

const sjis = require('fast-sjis-encoder');

Encode string to Shift-JIS byte array

const bytes = sjis('Hello 世界');
console.log(bytes); // Uint8Array(10) [72, 101, 108, 108, 111, 32, 144, 162, 138, 91]

Benchmark

Comparison with iconv-lite (operations per second)

charsfast-sjis-encodericonv-litefaster
301,491,271789,4461.89x
300471,622222,1282.12x
300061,77124,7082.50x

About 2x faster than iconv-lite.

Decoder?

const text = new TextDecoder('shift-jis').decode(bytes);
console.log(text); // "Hello 世界"

License

MIT

1.1.1

5 months ago

1.1.0

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago