You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

encoding

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

test.js

37

index.js

@@ -10,3 +10,12 @@ var Iconv, iconvLite = require("iconv-lite");;

function convert(str, to, from){
/**
* Convert encoding of an UTF-8 string or a buffer
*
* @param {String|Buffer} str String to be converted
* @param {String} to Encoding to be converted to
* @param {String} [from="UTF-8"] Encoding to be converted from
* @param {Boolean} useLite If set to ture, force to use iconvLite
* @return {Buffer} Encoded string
*/
function convert(str, to, from, useLite){
from = checkEncoding(from || "UTF-8");

@@ -25,7 +34,5 @@ to = checkEncoding(to || "UTF-8");

}else{
if(Iconv){
console.log(1);
if(Iconv && !useLite){
result = convertIconv(str, to, from);
}else{
console.log(2);
result = convertIconvLite(str, to, from);

@@ -42,2 +49,10 @@ }

/**
* Convert encoding of astring with node-iconv (if available)
*
* @param {String|Buffer} str String to be converted
* @param {String} to Encoding to be converted to
* @param {String} [from="UTF-8"] Encoding to be converted from
* @return {Buffer} Encoded string
*/
function convertIconv(str, to, from){

@@ -50,2 +65,10 @@ var response;

/**
* Convert encoding of astring with iconv-lite (if node-iconv is not available)
*
* @param {String|Buffer} str String to be converted
* @param {String} to Encoding to be converted to
* @param {String} [from="UTF-8"] Encoding to be converted from
* @return {Buffer} Encoded string
*/
function convertIconvLite(str, to, from){

@@ -61,2 +84,8 @@ if(to == "UTF-8"){

/**
* Converts charset name if needed
*
* @param {String} name Character set
* @return {String} Character set name
*/
function checkEncoding(name){

@@ -63,0 +92,0 @@ name = (name || "").toString().trim().

7

package.json
{
"name": "encoding",
"version": "0.1.1",
"version": "0.1.2",
"description": "Remove accents from international characters",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "nodeunit test.js"
},

@@ -17,3 +17,6 @@ "repository": "git://github.com/andris9/encoding.git",

"iconv": "*"
},
"devDependencies":{
"nodeunit": "*"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc