@bbob/plugin-helper
Advanced tools
Comparing version 2.5.8 to 2.6.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.6.0](https://github.com/JiLiZART/bbob/compare/v2.5.8...v2.6.0) (2020-12-10) | ||
### Features | ||
* **parser:** rewrite lexer to make it faster ([#50](https://github.com/JiLiZART/bbob/issues/50)) ([772d422](https://github.com/JiLiZART/bbob/commit/772d422d770b0f7716a86ac82c10eb3baaf77828)) | ||
## [2.5.8](https://github.com/JiLiZART/bbob/compare/v2.5.7...v2.5.8) (2020-07-08) | ||
@@ -8,0 +19,0 @@ |
@@ -21,2 +21,6 @@ (function (global, factory) { | ||
var keysReduce = function keysReduce(obj, reduce, def) { | ||
return Object.keys(obj).reduce(reduce, def); | ||
}; | ||
var getNodeLength = function getNodeLength(node) { | ||
@@ -89,7 +93,7 @@ if (isTagNode(node)) { | ||
// To avoid some malformed attributes | ||
if (typeof values === 'undefined') { | ||
if (values == null) { | ||
return ''; | ||
} | ||
return Object.keys(values).reduce(function (arr, key) { | ||
return keysReduce(values, function (arr, key) { | ||
return [].concat(arr, [attrValue(key, values[key])]); | ||
@@ -108,3 +112,3 @@ }, ['']).join(' '); | ||
var getUniqAttr = function getUniqAttr(attrs) { | ||
return Object.keys(attrs).reduce(function (res, key) { | ||
return keysReduce(attrs, function (res, key) { | ||
return attrs[key] === key ? attrs[key] : null; | ||
@@ -111,0 +115,0 @@ }, null); |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).BbobPluginHelper={})}(this,(function(e){"use strict";var n=function(e){return"object"==typeof e&&!!e.tag},t=function(e){return"string"==typeof e},r=function(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/(javascript):/gi,"$1%3A")},o=function(e,n){var t=typeof n,o={boolean:function(){return n?""+e:""},number:function(){return e+'="'+n+'"'},string:function(){return e+'="'+r(n)+'"'},object:function(){return e+'="'+r(JSON.stringify(n))+'"'}};return o[t]?o[t]():""};e.appendToNode=function(e,n){e.content.push(n)},e.attrValue=o,e.attrsToString=function(e){return void 0===e?"":Object.keys(e).reduce((function(n,t){return[].concat(n,[o(t,e[t])])}),[""]).join(" ")},e.escapeHTML=r,e.getNodeLength=function e(r){return n(r)?r.content.reduce((function(n,t){return n+e(t)}),0):t(r)?r.length:0},e.getUniqAttr=function(e){return Object.keys(e).reduce((function(n,t){return e[t]===t?e[t]:null}),null)},e.isEOL=function(e){return"\n"===e},e.isStringNode=t,e.isTagNode=n,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n=n||self).BbobPluginHelper={})}(this,(function(n){"use strict";var e=function(n){return"object"==typeof n&&!!n.tag},t=function(n){return"string"==typeof n},r=function(n,e,t){return Object.keys(n).reduce(e,t)},u=function(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/(javascript):/gi,"$1%3A")},o=function(n,e){var t=typeof e,r={boolean:function(){return e?""+n:""},number:function(){return n+'="'+e+'"'},string:function(){return n+'="'+u(e)+'"'},object:function(){return n+'="'+u(JSON.stringify(e))+'"'}};return r[t]?r[t]():""};n.appendToNode=function(n,e){n.content.push(e)},n.attrValue=o,n.attrsToString=function(n){return null==n?"":r(n,(function(e,t){return[].concat(e,[o(t,n[t])])}),[""]).join(" ")},n.escapeHTML=u,n.getNodeLength=function n(r){return e(r)?r.content.reduce((function(e,t){return e+n(t)}),0):t(r)?r.length:0},n.getUniqAttr=function(n){return r(n,(function(e,t){return n[t]===t?n[t]:null}),null)},n.isEOL=function(n){return"\n"===n},n.isStringNode=t,n.isTagNode=e,Object.defineProperty(n,"__esModule",{value:!0})})); |
@@ -20,2 +20,4 @@ "use strict"; | ||
var keysReduce = (obj, reduce, def) => Object.keys(obj).reduce(reduce, def); | ||
var getNodeLength = node => { | ||
@@ -84,7 +86,7 @@ if (isTagNode(node)) { | ||
// To avoid some malformed attributes | ||
if (typeof values === 'undefined') { | ||
if (values == null) { | ||
return ''; | ||
} | ||
return Object.keys(values).reduce((arr, key) => [...arr, attrValue(key, values[key])], ['']).join(' '); | ||
return keysReduce(values, (arr, key) => [...arr, attrValue(key, values[key])], ['']).join(' '); | ||
}; | ||
@@ -102,4 +104,4 @@ /** | ||
var getUniqAttr = attrs => Object.keys(attrs).reduce((res, key) => attrs[key] === key ? attrs[key] : null, null); | ||
var getUniqAttr = attrs => keysReduce(attrs, (res, key) => attrs[key] === key ? attrs[key] : null, null); | ||
exports.getUniqAttr = getUniqAttr; |
@@ -32,3 +32,3 @@ "use strict"; | ||
this.attrs = attrs; | ||
this.content = [].concat(content); | ||
this.content = Array.isArray(content) ? content : [content]; | ||
} | ||
@@ -35,0 +35,0 @@ |
@@ -26,2 +26,6 @@ "use strict"; | ||
var keysReduce = function keysReduce(obj, reduce, def) { | ||
return Object.keys(obj).reduce(reduce, def); | ||
}; | ||
var getNodeLength = function getNodeLength(node) { | ||
@@ -102,7 +106,7 @@ if (isTagNode(node)) { | ||
// To avoid some malformed attributes | ||
if (typeof values === 'undefined') { | ||
if (values == null) { | ||
return ''; | ||
} | ||
return Object.keys(values).reduce(function (arr, key) { | ||
return keysReduce(values, function (arr, key) { | ||
return [].concat(arr, [attrValue(key, values[key])]); | ||
@@ -123,3 +127,3 @@ }, ['']).join(' '); | ||
var getUniqAttr = function getUniqAttr(attrs) { | ||
return Object.keys(attrs).reduce(function (res, key) { | ||
return keysReduce(attrs, function (res, key) { | ||
return attrs[key] === key ? attrs[key] : null; | ||
@@ -126,0 +130,0 @@ }, null); |
@@ -38,3 +38,3 @@ "use strict"; | ||
this.attrs = attrs; | ||
this.content = [].concat(content); | ||
this.content = Array.isArray(content) ? content : [content]; | ||
} | ||
@@ -41,0 +41,0 @@ |
{ | ||
"name": "@bbob/plugin-helper", | ||
"version": "2.5.8", | ||
"version": "2.6.0", | ||
"description": "Set of utils to help write plugins for @bbob/core", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"path": "./dist/index.min.js", | ||
"maxSize": "580 B" | ||
"maxSize": "650 B" | ||
} | ||
@@ -58,3 +58,3 @@ ], | ||
], | ||
"gitHead": "2eb1fbcccf065a95df2c1a28020119582d4a64d1" | ||
"gitHead": "99f503df0cc35d33c9e57d49b6581631d49ab6c3" | ||
} |
@@ -7,2 +7,4 @@ import { N } from './char'; | ||
const keysReduce = (obj, reduce, def) => Object.keys(obj).reduce(reduce, def); | ||
const getNodeLength = (node) => { | ||
@@ -65,9 +67,11 @@ if (isTagNode(node)) { | ||
// To avoid some malformed attributes | ||
if (typeof values === 'undefined') { | ||
if (values == null) { | ||
return ''; | ||
} | ||
return Object.keys(values) | ||
.reduce((arr, key) => [...arr, attrValue(key, values[key])], ['']) | ||
.join(' '); | ||
return keysReduce( | ||
values, | ||
(arr, key) => [...arr, attrValue(key, values[key])], | ||
[''], | ||
).join(' '); | ||
}; | ||
@@ -82,5 +86,7 @@ | ||
*/ | ||
const getUniqAttr = (attrs) => Object | ||
.keys(attrs) | ||
.reduce((res, key) => (attrs[key] === key ? attrs[key] : null), null); | ||
const getUniqAttr = (attrs) => keysReduce( | ||
attrs, | ||
(res, key) => (attrs[key] === key ? attrs[key] : null), | ||
null, | ||
); | ||
@@ -87,0 +93,0 @@ export { |
@@ -27,3 +27,3 @@ import { OPEN_BRAKET, CLOSE_BRAKET, SLASH } from './char'; | ||
this.attrs = attrs; | ||
this.content = [].concat(content); | ||
this.content = Array.isArray(content) ? content : [content]; | ||
} | ||
@@ -30,0 +30,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
28704
648