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

escape-html-template-tag

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escape-html-template-tag - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

7

dist/index.cjs.d.ts

@@ -1,6 +0,1 @@

import escapeHtml, { join, safe } from './index';
declare const _default: typeof escapeHtml & {
join: typeof join;
safe: typeof safe;
};
export default _default;
export { default } from './index';

8

dist/index.d.ts

@@ -11,3 +11,7 @@ export declare function join(array: any, separator: any): HtmlSafeString;

}
export default function escapeHtml(parts: any, ...subs: any[]): HtmlSafeString;
export {};
declare function escapeHtml(parts: any, ...subs: any[]): HtmlSafeString;
declare const _default: typeof escapeHtml & {
join: typeof join;
safe: typeof safe;
};
export default _default;

@@ -1,75 +0,2 @@

var ENTITIES = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
};
var ENT_REGEX = new RegExp(Object.keys(ENTITIES).join('|'), 'g');
function join(array, separator) {
if (separator === undefined || separator === null) {
separator = ',';
}
if (array.length <= 0) {
return new HtmlSafeString([''], []);
}
return new HtmlSafeString([''].concat(Array(array.length - 1).fill(separator), ['']), array);
}
function safe(value) {
return new HtmlSafeString([String(value)], []);
}
var HtmlSafeString = /*#__PURE__*/function () {
function HtmlSafeString(parts, subs) {
this._parts = parts;
this._subs = subs;
}
var _proto = HtmlSafeString.prototype;
_proto._escapeHtml = function _escapeHtml(unsafe) {
if (unsafe instanceof HtmlSafeString) {
return unsafe;
}
if (Array.isArray(unsafe)) {
return join(unsafe, '');
}
return String(unsafe).replace(ENT_REGEX, function (_char) {
return ENTITIES[_char];
});
};
_proto.toString = function toString() {
var _this = this;
return this._parts.reduce(function (result, part, i) {
var sub = _this._subs[i - 1];
return result + _this._escapeHtml(sub) + part;
});
};
_proto.inspect = function inspect() {
return this.constructor.name + " '" + this.toString() + "'";
};
return HtmlSafeString;
}();
function escapeHtml(parts) {
return new HtmlSafeString(parts, [].slice.call(arguments, 1));
}
var index_cjs = Object.assign(escapeHtml, {
join: join,
safe: safe
});
module.exports = index_cjs;
var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},t=new RegExp(Object.keys(n).join("|"),"g");function r(n,t){return null==t&&(t=","),n.length<=0?new e([""],[]):new e([""].concat(Array(n.length-1).fill(t),[""]),n)}var e=function(){function e(n,t){this._parts=n,this._subs=t}var i=e.prototype;return i._escapeHtml=function(i){return i instanceof e?i:Array.isArray(i)?r(i,""):String(i).replace(t,function(t){return n[t]})},i.toString=function(){var n=this;return this._parts.reduce(function(t,r,e){return t+n._escapeHtml(n._subs[e-1])+r})},i.inspect=function(){return this.constructor.name+" '"+this.toString()+"'"},e}(),i=Object.assign(function(n){return new e(n,[].slice.call(arguments,1))},{join:r,safe:function(n){return new e([String(n)],[])}});module.exports=i;
//# sourceMappingURL=index.js.map

@@ -1,82 +0,2 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.escapeHtmlTemplateTag = factory());
}(this, (function () {
var ENTITIES = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
};
var ENT_REGEX = new RegExp(Object.keys(ENTITIES).join('|'), 'g');
function join(array, separator) {
if (separator === undefined || separator === null) {
separator = ',';
}
if (array.length <= 0) {
return new HtmlSafeString([''], []);
}
return new HtmlSafeString([''].concat(Array(array.length - 1).fill(separator), ['']), array);
}
function safe(value) {
return new HtmlSafeString([String(value)], []);
}
var HtmlSafeString = /*#__PURE__*/function () {
function HtmlSafeString(parts, subs) {
this._parts = parts;
this._subs = subs;
}
var _proto = HtmlSafeString.prototype;
_proto._escapeHtml = function _escapeHtml(unsafe) {
if (unsafe instanceof HtmlSafeString) {
return unsafe;
}
if (Array.isArray(unsafe)) {
return join(unsafe, '');
}
return String(unsafe).replace(ENT_REGEX, function (_char) {
return ENTITIES[_char];
});
};
_proto.toString = function toString() {
var _this = this;
return this._parts.reduce(function (result, part, i) {
var sub = _this._subs[i - 1];
return result + _this._escapeHtml(sub) + part;
});
};
_proto.inspect = function inspect() {
return this.constructor.name + " '" + this.toString() + "'";
};
return HtmlSafeString;
}();
function escapeHtml(parts) {
return new HtmlSafeString(parts, [].slice.call(arguments, 1));
}
var index_cjs = Object.assign(escapeHtml, {
join: join,
safe: safe
});
return index_cjs;
})));
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n||self).escapeHtmlTemplateTag=t()}(this,function(){var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},t=new RegExp(Object.keys(n).join("|"),"g");function e(n,t){return null==t&&(t=","),n.length<=0?new r([""],[]):new r([""].concat(Array(n.length-1).fill(t),[""]),n)}var r=function(){function r(n,t){this._parts=n,this._subs=t}var i=r.prototype;return i._escapeHtml=function(i){return i instanceof r?i:Array.isArray(i)?e(i,""):String(i).replace(t,function(t){return n[t]})},i.toString=function(){var n=this;return this._parts.reduce(function(t,e,r){return t+n._escapeHtml(n._subs[r-1])+e})},i.inspect=function(){return this.constructor.name+" '"+this.toString()+"'"},r}();return Object.assign(function(n){return new r(n,[].slice.call(arguments,1))},{join:e,safe:function(n){return new r([String(n)],[])}})});
//# sourceMappingURL=index.umd.js.map
{
"name": "escape-html-template-tag",
"version": "2.0.2",
"version": "2.0.3",
"description": "Tag literal strings with this function to html escape interpolated values",
"source": "src/index.ts",
"main": "dist/index.js",
"exports": "./dist/index.modern.mjs",
"exports": {
"require": "./dist/index.js",
"default": "./dist/index.modern.mjs"
},
"module": "dist/index.module.mjs",

@@ -13,3 +16,3 @@ "unpkg": "dist/index.umd.js",

"test": "standard && node test/index.test.js",
"prepublish": "rm -rf dist && microbundle --no-compress -f cjs,umd src/index.cjs.ts && microbundle -f es,modern src/index.ts && mv dist/index.modern.js dist/index.modern.mjs && mv dist/index.modern.js.map dist/index.modern.mjs.map"
"prepublish": "rm -rf dist && microbundle -f cjs,umd src/index.cjs.ts && microbundle -f es,modern src/index.ts && mv dist/index.modern.js dist/index.modern.mjs && mv dist/index.modern.js.map dist/index.modern.mjs.map"
},

@@ -16,0 +19,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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