🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

text-encoding

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-encoding - npm Package Compare versions

Comparing version

to
0.5.0

LICENSE.md

@@ -0,1 +1,15 @@

// Copyright 2014 Joshua Bell. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var encoding = require("./lib/encoding.js");

@@ -2,0 +16,0 @@

2

package.json

@@ -7,3 +7,3 @@ {

],
"version": "0.1.0",
"version": "0.5.0",
"description": "Polyfill for the Encoding Living Standard's API.",

@@ -10,0 +10,0 @@ "main": "index.js",

@@ -13,3 +13,3 @@ text-encoding

Basic examples and unit tests are included.
Basic examples and tests are included.

@@ -78,5 +78,7 @@ ### Install ###

`encoding-indexes.js` file to be included. It is rather large
(541kB uncompressed, 186kB gzipped); portions may be deleted if
(596kB uncompressed, 188kB gzipped); portions may be deleted if
support for some encodings is not required.
### Non-Standard Behavior ###
As required by the specification, only encoding to **utf-8**,

@@ -88,3 +90,17 @@ **utf-16le** and **utf-16be** is supported. If you want to try it out, you can

```js
var uint8array = TextEncoder('windows-1252', { NONSTANDARD_allowLegacyEncoding: true }).encode(text);
var uint8array = new TextEncoder(
'windows-1252', { NONSTANDARD_allowLegacyEncoding: true }).encode(text);
```
But note that the above won't work if you're using the polyfill in a browser that
natively supports the TextEncoder API natively, since the polyfill won't be used!
You'd need to fork and modify the polyfill to... not be a polyfill.
To support the legacy encodings (which may be stateful), the TextEncoder `encode()`
method accepts an optional dictionary and `stream` option,
e.g. `encoder.encode(string, {stream: true});` This is not needed for the
stateless UTF encodings since the input is always in complete code points.
The polyfill also allows construction of encoder/decoder objects without the
`new` keyword. (This non-standard behavior is supported for constructing DOM
objects in Firefox but not other browsers.)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display