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

entity-convert

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

entity-convert - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

57

entityconvert.js

@@ -1,24 +0,3 @@

function replacer(mode){
return function(char){
var index = char.charCodeAt(0);
if (index > 127){
return mode === 'css' ? ('\\00' + char.charCodeAt(0).toString(16)) : ('&#' + char.charCodeAt(0) + ';');
} else {
return char;
}
};
}
(function (root, factory) {
function replaceBy(mode){
return function(string){
var fn = replacer(mode);
string = string.split('');
for (var i = 0, len = string.length; i < len; i++){
string[i] = fn(string[i]);
}
return string.join('');
};
}
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

@@ -33,3 +12,36 @@ define(function(){

}
}(this, function(){
function eachChar(str, fn){
str = str.split('');
for (var i = 0, len = str.length; i < len; i++){
str[i] = fn(str[i]);
}
return str.join('');
}
function replacer(mode){
function getEnt(code){
return (
mode === 'css' ?
['\\00', code.toString(16)] :
['&#', code, ';']
).join('');
}
return function(character){
var index = character.charCodeAt(0);
return (index > 127) ? getEnt(index) : character;
};
}
function replaceBy(mode){
return function(string){
return eachChar(string, replacer(mode));
};
}
return {

@@ -39,2 +51,3 @@ css : replaceBy('css')

};
}));
{
"name": "entity-convert",
"version": "0.0.1",
"version": "0.0.2",
"description": "convert all special characters in a string to their corresponding HTML and CSS entities",

@@ -8,3 +8,3 @@ "main": "entityconvert.js",

"homepage": "https://github.com/m90/entity-convert",
"issues": "https://github.com/m90/entity-convert/issues",
"bugs": "https://github.com/m90/entity-convert/issues",
"keywords": [

@@ -11,0 +11,0 @@ "string",

# entityconvert.js
#### convert special characters in a string to their HTML or CSS charcode entities (useful for build tools et. al.)
The module works as AMD or CommonJS module and exports an Object containing to functions: `.html(str)` and `.css(str)`. In a non-AMD or CommonJS environment `window.entityconvert` will be exported.
The module works as AMD or CommonJS module and exports an Object containing two functions: `.html(str)` and `.css(str)`. In a non-AMD or CommonJS environment `window.entityconvert` will be exported.

@@ -6,0 +6,0 @@ AMD usage like:

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