@bbob/plugin-helper
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="2.0.1"></a> | ||
## [2.0.1](https://github.com/JiLiZART/bbob/compare/@bbob/plugin-helper@2.0.0...@bbob/plugin-helper@2.0.1) (2018-09-23) | ||
### Bug Fixes | ||
* **plugin-helper:** better handle content of TagNode ([505152b](https://github.com/JiLiZART/bbob/commit/505152b)) | ||
<a name="1.1.0"></a> | ||
@@ -8,0 +19,0 @@ # 1.1.0 (2018-08-09) |
@@ -1,69 +0,1 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.BbobPluginHelper = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
var N = '\n'; | ||
var isTagNode = function isTagNode(el) { | ||
return typeof el === 'object' && !!el.tag; | ||
}; | ||
var isStringNode = function isStringNode(el) { | ||
return typeof el === 'string'; | ||
}; | ||
var isEOL = function isEOL(el) { | ||
return el === N; | ||
}; | ||
var getNodeLength = function getNodeLength(node) { | ||
if (isTagNode(node)) { | ||
return node.content.reduce(function (count, contentNode) { | ||
return count + getNodeLength(contentNode); | ||
}, 0); | ||
} else if (isStringNode(node)) { | ||
return node.length; | ||
} | ||
return 0; | ||
}; | ||
var appendToNode = function appendToNode(node, value) { | ||
node.content.push(value); | ||
}; | ||
var escapeQuote = function escapeQuote(value) { | ||
return value.replace(/"/g, '"'); | ||
}; | ||
var attrValue = function attrValue(name, value) { | ||
var type = typeof value; | ||
var types = { | ||
boolean: function boolean() { | ||
return value ? '' + name : ''; | ||
}, | ||
number: function number() { | ||
return name + '="' + value + '"'; | ||
}, | ||
string: function string() { | ||
return name + '="' + escapeQuote(value) + '"'; | ||
}, | ||
object: function object() { | ||
return name + '="' + escapeQuote(JSON.stringify(value)) + '"'; | ||
} | ||
}; | ||
return types[type] ? types[type]() : ''; | ||
}; | ||
exports.attrValue = attrValue; | ||
exports.appendToNode = appendToNode; | ||
exports.getNodeLength = getNodeLength; | ||
exports.isTagNode = isTagNode; | ||
exports.isStringNode = isStringNode; | ||
exports.isEOL = isEOL; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.BbobPluginHelper={})}(this,function(n){"use strict";var e=function(n){return"object"==typeof n&&!!n.tag},o=function(n){return"string"==typeof n},r=function(n){return n.replace(/"/g,""")};n.attrValue=function(n,e){var t=typeof e,o={boolean:function(){return e?""+n:""},number:function(){return n+'="'+e+'"'},string:function(){return n+'="'+r(e)+'"'},object:function(){return n+'="'+r(JSON.stringify(e))+'"'}};return o[t]?o[t]():""},n.appendToNode=function(n,e){n.content.push(e)},n.getNodeLength=function t(n){return e(n)?n.content.reduce(function(n,e){return n+t(e)},0):o(n)?n.length:0},n.isTagNode=e,n.isStringNode=o,n.isEOL=function(n){return"\n"===n},Object.defineProperty(n,"__esModule",{value:!0})}); |
@@ -14,3 +14,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
this.attrs = attrs; | ||
this.content = content; | ||
this.content = [].concat(content); | ||
} | ||
@@ -17,0 +17,0 @@ |
@@ -20,3 +20,3 @@ 'use strict'; | ||
this.attrs = attrs; | ||
this.content = content; | ||
this.content = [].concat(content); | ||
} | ||
@@ -23,0 +23,0 @@ |
{ | ||
"name": "@bbob/plugin-helper", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Set of utils to help write plugins", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,3 +8,3 @@ import { OPEN_BRAKET, CLOSE_BRAKET, SLASH } from './char'; | ||
this.attrs = attrs; | ||
this.content = content; | ||
this.content = [].concat(content); | ||
} | ||
@@ -11,0 +11,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15520
385