@kosatyi/ejs 0.0.54 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.element = {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ var isUndefined = function isUndefined(v) {
8
+ return typeof v === 'undefined';
9
+ };
10
+
11
+ Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
12
+ var symbolEntities = {
13
+ "'": "'",
14
+ '\\': '\\',
15
+ '\r': 'r',
16
+ '\n': 'n',
17
+ '\t': 't',
18
+ "\u2028": 'u2028',
19
+ "\u2029": 'u2029'
20
+ };
21
+ var htmlEntities = {
22
+ '&': '&',
23
+ '<': '&lt;',
24
+ '>': '&gt;',
25
+ '"': '&quot;',
26
+ "'": '&#x27;'
27
+ };
28
+ var regexKeys = function regexKeys(obj) {
29
+ return new RegExp(['[', Object.keys(obj).join(''), ']'].join(''), 'g');
30
+ };
31
+ var htmlEntitiesMatch = regexKeys(htmlEntities);
32
+ regexKeys(symbolEntities);
33
+ var entities = function entities() {
34
+ var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
35
+ return ('' + string).replace(htmlEntitiesMatch, function (match) {
36
+ return htmlEntities[match];
37
+ });
38
+ };
39
+ var safeValue = function safeValue(value, escape, check) {
40
+ return (check = value) == null ? '' : escape ? entities(check) : check;
41
+ };
42
+ var each = function each(object, callback) {
43
+ var prop;
44
+ for (prop in object) {
45
+ if (hasProp(object, prop)) {
46
+ callback(object[prop], prop, object);
47
+ }
48
+ }
49
+ };
50
+ var map = function map(object, callback, context) {
51
+ var result = [];
52
+ each(object, function (value, key, object) {
53
+ var item = callback(value, key, object);
54
+ if (isUndefined(item) === false) {
55
+ result.push(item);
56
+ }
57
+ });
58
+ return result;
59
+ };
60
+ var hasProp = function hasProp(object, prop) {
61
+ return object && object.hasOwnProperty(prop);
62
+ };
63
+
64
+ var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
65
+ var space = ' ';
66
+ var quote = '"';
67
+ var equal = '=';
68
+ var slash = '/';
69
+ var lt = '<';
70
+ var gt = '>';
71
+ var element = function element(tag, attrs, content) {
72
+ var result = [];
73
+ var hasClosedTag = selfClosed.indexOf(tag) === -1;
74
+ var attributes = map(attrs, function (value, key) {
75
+ if (value !== null && value !== undefined) {
76
+ return [entities(key), [quote, entities(value), quote].join('')].join(equal);
77
+ }
78
+ }).join(space);
79
+ result.push([lt, tag, space, attributes, gt].join(''));
80
+ if (content) {
81
+ result.push(content instanceof Array ? content.join('') : content);
82
+ }
83
+ if (hasClosedTag) {
84
+ result.push([lt, slash, tag, gt].join(''));
85
+ }
86
+ return result.join('');
87
+ };
88
+
89
+ exports.element = element;
90
+ exports.safeValue = safeValue;
91
+
92
+ }));
@@ -0,0 +1 @@
1
+ !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).element={})}(this,(function(n){"use strict";Object.prototype.toString.call("undefined"!=typeof process?process:0);var e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},t=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},o=t(e);t({"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"});var r=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(o,(function(n){return e[n]}))},i=function(n,e,t){var o=[];return function(n,e){var t;for(t in n)u(n,t)&&e(n[t],t,n)}(n,(function(n,t,r){var i=e(n,t,r);!1==(void 0===i)&&o.push(i)})),o},u=function(n,e){return n&&n.hasOwnProperty(e)},f=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],c=" ",a='"',s="/",p="<",l=">";n.element=function(n,e,t){var o=[],u=-1===f.indexOf(n),d=i(e,(function(n,e){if(null!=n)return[r(e),[a,r(n),a].join("")].join("=")})).join(c);return o.push([p,n,c,d,l].join("")),t&&o.push(t instanceof Array?t.join(""):t),u&&o.push([p,s,n,l].join("")),o.join("")},n.safeValue=function(n,e,t){return null==(t=n)?"":e?r(t):t}}));