fast-text-encoding

WebJar for fast-text-encoding

License

License

Apache-2.0
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

fast-text-encoding
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

fast-text-encoding
WebJar for fast-text-encoding
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/samthor/fast-text-encoding

Download fast-text-encoding

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/fast-text-encoding/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>fast-text-encoding</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/fast-text-encoding/
implementation 'org.webjars.npm:fast-text-encoding:1.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/fast-text-encoding/
implementation ("org.webjars.npm:fast-text-encoding:1.0.3")
'org.webjars.npm:fast-text-encoding:jar:1.0.3'
<dependency org="org.webjars.npm" name="fast-text-encoding" rev="1.0.3">
  <artifact name="fast-text-encoding" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='fast-text-encoding', version='1.0.3')
)
libraryDependencies += "org.webjars.npm" % "fast-text-encoding" % "1.0.3"
[org.webjars.npm/fast-text-encoding "1.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Build

This is a fast polyfill for TextEncoder and TextDecoder, which let you encode and decode JavaScript strings into UTF-8 bytes.

It is fast partially as it does not support any encodings aside UTF-8 (and note that natively, only TextDecoder supports alternative encodings anyway). See some benchmarks.

Usage

Install as "fast-text-encoding" via your favourite package manager.

You only need this polyfill if you're supporting older browsers like IE, legacy Edge, ancient Chrome and Firefox, or Node before v11.

Browser

Include the minified code inside a script tag or as an ES6 Module for its side effects. It will create TextEncoder and TextDecoder if the symbols are missing on window or global.

<script src="node_modules/fast-text-encoding/text.min.js"></script>
<script type="module">
  import './node_modules/fast-text-encoding/text.min.js';
  import 'fast-text-encoding';  // or perhaps this
  // confidently do something with TextEncoder or TextDecoder \o/
</script>

⚠️ You'll probably want to depend on text.min.js, as it's compiled to ES5 for older environments.

Node

You only need this polyfill in Node before v11. However, you can use Buffer to provide the same functionality (but not conforming to any spec) in versions even older than that.

require('fast-text-encoding');  // just require me before use

const buffer = new TextEncoder().encode('Turn me into UTF-8!');
// buffer is now a Uint8Array of [84, 117, 114, 110, ...]

In Node v5.1 and above, this polyfill uses Buffer to implement TextDecoder.

Release

Compile code with Closure Compiler.

// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name text.min.js
// ==/ClosureCompiler==

// code here

Versions

Version
1.0.3
1.0.1
1.0.0