Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

utf8-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

utf8-encoding - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

8

package.json
{
"name": "utf8-encoding",
"description": "utf8 encoder/decoder of whatwg Encoding Living Standard https://encoding.spec.whatwg.org/",
"version": "0.0.9",
"version": "0.1.0",
"author": "Jxck",

@@ -42,8 +42,8 @@ "bugs": {

"bower": "bower install",
"clean": "\\rm -f *.js",
"postinstall": "mv node_modules/obtain-unicode/obtain-unicode.d.ts types/",
"clean": "\\rm -f *.js npm-debug.log",
"type": "cp node_modules/obtain-unicode/obtain-unicode.d.ts types/",
"prepublish": "npm run tsc",
"test": "npm run tsc && node test/test.js && \\rm -f npm-debug.log && echo open test/index.html in your browser",
"tsc": "tsc utf8-encoding.ts --target ES5 --module commonjs --noImplicitAny"
"tsc": "tsc utf8-encoding.ts --target ES5 --module commonjs"
}
}

@@ -7,6 +7,7 @@ var TextEncoder = TextEncoder || require('../utf8-encoding').TextEncoder;

console.log('.');
// console.log(actual, expected);
console.assert(actual === expected, '\nact: ' + actual + '\nexp: ' + expected);
}
(function example() {
function example() {
var encoder = new TextEncoder();

@@ -18,8 +19,10 @@ var decoder = new TextDecoder();

// "beer!🍻
})();
};
(function test() {
var encoder = new TextEncoder();
var decoder = new TextDecoder();
function test(textencoder, textdecoder) {
var encoder = new textencoder();
var decoder = new textdecoder();
[
[ "", [ ]],
[ "aAzZ09", [ 97, 65, 122, 90, 48, 57 ]],

@@ -46,2 +49,24 @@ [ "~`!@", [ 126, 96, 33, 64 ]],

});
};
function compat() {
// unspecified in spec ?
// assert(decoder.decode([]), _decoder.decode([]));
// assert(decoder.decode(null), _decoder.decode(null));
// assert(decoder.decode(undefined), _decoder.decode(undefined));
};
(function TestEncoding() {
try {
example();
test(TextEncoder, TextDecoder);
if (typeof nativeTextEncoder !== 'undefined'
&& typeof nativeTextDecoder !== 'undefined') {
test(nativeTextEncoder, nativeTextDecoder);
compat();
}
} catch(err) {
console.error(err);
}
})();

@@ -7,2 +7,11 @@ /// <reference path="types/webidl.d.ts" />

}
// save platform implementation if exists
var nativeTextEncoder;
if (typeof this.TextEncoder !== "undefined") {
nativeTextEncoder = this.TextEncoder;
}
var nativeTextDecoder;
if (typeof this.TextDecoder !== "undefined") {
nativeTextDecoder = this.TextDecoder;
}
var UTF8Encoder;

@@ -232,3 +241,3 @@ (function (UTF8Encoder) {

// step 2-2
if (["utf-8", "utf8"].indexOf(this._encoding) > -1 && this.ignoreBOMFlag === false && this.bomSeenFlag === false) {
if (["utf-8", "utf8"].indexOf(this._encoding) !== -1 && this.ignoreBOMFlag === false && this.bomSeenFlag === false) {
// step 2-2-1

@@ -390,3 +399,3 @@ if (token === 0xFEFF) {

})(UTF8Encoder || (UTF8Encoder = {}));
this.TextEncoder = this.TextEncoder || UTF8Encoder.TextEncoder;
this.TextDecoder = this.TextDecoder || UTF8Encoder.TextDecoder;
this.TextEncoder = nativeTextEncoder || UTF8Encoder.TextEncoder;
this.TextDecoder = nativeTextDecoder || UTF8Encoder.TextDecoder;

@@ -30,2 +30,13 @@ /// <reference path="types/webidl.d.ts" />

// save platform implementation if exists
var nativeTextEncoder;
if (typeof this.TextEncoder !== "undefined") {
nativeTextEncoder = this.TextEncoder;
}
var nativeTextDecoder;
if (typeof this.TextDecoder !== "undefined") {
nativeTextDecoder = this.TextDecoder;
}
module UTF8Encoder {

@@ -316,3 +327,3 @@ "use strict";

// step 2-2
if (["utf-8", "utf8"].indexOf(this._encoding) > -1
if (["utf-8", "utf8"].indexOf(this._encoding) !== -1
&& this.ignoreBOMFlag === false

@@ -510,3 +521,3 @@ && this.bomSeenFlag === false) {

this.TextEncoder = this.TextEncoder || UTF8Encoder.TextEncoder;
this.TextDecoder = this.TextDecoder || UTF8Encoder.TextDecoder;
this.TextEncoder = nativeTextEncoder || UTF8Encoder.TextEncoder;
this.TextDecoder = nativeTextDecoder || UTF8Encoder.TextDecoder;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc