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

@bbob/plugin-helper

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbob/plugin-helper - npm Package Compare versions

Comparing version 2.5.5 to 2.5.6

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

## [2.5.6](https://github.com/JiLiZART/bbob/compare/v2.5.5...v2.5.6) (2020-04-12)
### Bug Fixes
* **parser:** don't eat not allowed tags with params ([#58](https://github.com/JiLiZART/bbob/issues/58)) fixes [#54](https://github.com/JiLiZART/bbob/issues/54) ([a16b9f7](https://github.com/JiLiZART/bbob/commit/a16b9f73b0737a46e852f9c55a17a612f17a9587))
### Features
* **plugin-helper:** move `getUniqAttr` from preset to plugin helper ([#63](https://github.com/JiLiZART/bbob/issues/63)) ([f28f19e](https://github.com/JiLiZART/bbob/commit/f28f19e64ce5124db92c446bcc69e78761101744))
## [2.5.5](https://github.com/JiLiZART/bbob/compare/v2.5.4...v2.5.5) (2020-03-25)

@@ -8,0 +24,0 @@

@@ -95,3 +95,17 @@ (function (global, factory) {

};
/**
* Gets value from
* @example
* getUniqAttr({ 'foo': true, 'bar': bar' }) => 'bar'
* @param attrs
* @returns {string}
*/
var getUniqAttr = function getUniqAttr(attrs) {
return Object.keys(attrs).reduce(function (res, key) {
return attrs[key] === key ? attrs[key] : null;
}, null);
};
exports.appendToNode = appendToNode;

@@ -101,2 +115,3 @@ exports.attrValue = attrValue;

exports.getNodeLength = getNodeLength;
exports.getUniqAttr = getUniqAttr;
exports.isEOL = isEOL;

@@ -103,0 +118,0 @@ exports.isStringNode = isStringNode;

2

dist/index.min.js

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).BbobPluginHelper={})}(this,(function(n){"use strict";var t=function(n){return"object"==typeof n&&!!n.tag},e=function(n){return"string"==typeof n},o=function(n){return n.replace(/"/g,""")},r=function(n,t){var e=typeof t,r={boolean:function(){return t?""+n:""},number:function(){return n+'="'+t+'"'},string:function(){return n+'="'+o(t)+'"'},object:function(){return n+'="'+o(JSON.stringify(t))+'"'}};return r[e]?r[e]():""};n.appendToNode=function(n,t){n.content.push(t)},n.attrValue=r,n.attrsToString=function(n){return void 0===n?"":Object.keys(n).reduce((function(t,e){return[].concat(t,[r(e,n[e])])}),[""]).join(" ")},n.getNodeLength=function n(o){return t(o)?o.content.reduce((function(t,e){return t+n(e)}),0):e(o)?o.length:0},n.isEOL=function(n){return"\n"===n},n.isStringNode=e,n.isTagNode=t,Object.defineProperty(n,"__esModule",{value:!0})}));
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).BbobPluginHelper={})}(this,(function(n){"use strict";var t=function(n){return"object"==typeof n&&!!n.tag},e=function(n){return"string"==typeof n},r=function(n){return n.replace(/"/g,""")},o=function(n,t){var e=typeof t,o={boolean:function(){return t?""+n:""},number:function(){return n+'="'+t+'"'},string:function(){return n+'="'+r(t)+'"'},object:function(){return n+'="'+r(JSON.stringify(t))+'"'}};return o[e]?o[e]():""};n.appendToNode=function(n,t){n.content.push(t)},n.attrValue=o,n.attrsToString=function(n){return void 0===n?"":Object.keys(n).reduce((function(t,e){return[].concat(t,[o(e,n[e])])}),[""]).join(" ")},n.getNodeLength=function n(r){return t(r)?r.content.reduce((function(t,e){return t+n(e)}),0):e(r)?r.length:0},n.getUniqAttr=function(n){return Object.keys(n).reduce((function(t,e){return n[e]===e?n[e]:null}),null)},n.isEOL=function(n){return"\n"===n},n.isStringNode=e,n.isTagNode=t,Object.defineProperty(n,"__esModule",{value:!0})}));
"use strict";
exports.__esModule = true;
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0;
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0;

@@ -86,3 +86,15 @@ var _char = require("./char");

};
/**
* Gets value from
* @example
* getUniqAttr({ 'foo': true, 'bar': bar' }) => 'bar'
* @param attrs
* @returns {string}
*/
exports.attrsToString = attrsToString;
exports.attrsToString = attrsToString;
var getUniqAttr = attrs => Object.keys(attrs).reduce((res, key) => attrs[key] === key ? attrs[key] : null, null);
exports.getUniqAttr = getUniqAttr;

@@ -10,5 +10,23 @@ "use strict";

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var getTagAttrs = (tag, params) => {
var uniqAattr = (0, _index.getUniqAttr)(params);
if (uniqAattr) {
var tagAttr = (0, _index.attrValue)(tag, uniqAattr);
var attrs = _extends({}, params);
delete attrs[uniqAattr];
var attrsStr = (0, _index.attrsToString)(attrs);
return "" + tagAttr + attrsStr;
}
return "" + tag + (0, _index.attrsToString)(params);
};
class TagNode {
constructor(tag, attrs, content) {
this.tag = tag.toLowerCase();
this.tag = tag;
this.attrs = attrs;

@@ -34,6 +52,18 @@ this.content = [].concat(content);

toTagNode() {
return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);
}
toString() {
var OB = _char.OPEN_BRAKET;
var CB = _char.CLOSE_BRAKET;
return OB + this.tag + CB + this.content.reduce((r, node) => r + node.toString(), '') + OB + _char.SLASH + this.tag + CB;
var isEmpty = this.content.length === 0;
var content = this.content.reduce((r, node) => r + node.toString(), '');
var tagAttrs = getTagAttrs(this.tag, this.attrs);
if (isEmpty) {
return "" + OB + tagAttrs + CB;
}
return "" + OB + tagAttrs + CB + content + OB + _char.SLASH + this.tag + CB;
}

@@ -40,0 +70,0 @@

"use strict";
exports.__esModule = true;
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0;
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0;

@@ -106,3 +106,19 @@ var _char = require("./char");

};
/**
* Gets value from
* @example
* getUniqAttr({ 'foo': true, 'bar': bar' }) => 'bar'
* @param attrs
* @returns {string}
*/
exports.attrsToString = attrsToString;
exports.attrsToString = attrsToString;
var getUniqAttr = function getUniqAttr(attrs) {
return Object.keys(attrs).reduce(function (res, key) {
return attrs[key] === key ? attrs[key] : null;
}, null);
};
exports.getUniqAttr = getUniqAttr;

@@ -14,2 +14,20 @@ "use strict";

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var getTagAttrs = function getTagAttrs(tag, params) {
var uniqAattr = (0, _index.getUniqAttr)(params);
if (uniqAattr) {
var tagAttr = (0, _index.attrValue)(tag, uniqAattr);
var attrs = _extends({}, params);
delete attrs[uniqAattr];
var attrsStr = (0, _index.attrsToString)(attrs);
return "" + tagAttr + attrsStr;
}
return "" + tag + (0, _index.attrsToString)(params);
};
var TagNode =

@@ -19,3 +37,3 @@ /*#__PURE__*/

function TagNode(tag, attrs, content) {
this.tag = tag.toLowerCase();
this.tag = tag;
this.attrs = attrs;

@@ -39,8 +57,20 @@ this.content = [].concat(content);

_proto.toTagNode = function toTagNode() {
return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);
};
_proto.toString = function toString() {
var OB = _char.OPEN_BRAKET;
var CB = _char.CLOSE_BRAKET;
return OB + this.tag + CB + this.content.reduce(function (r, node) {
var isEmpty = this.content.length === 0;
var content = this.content.reduce(function (r, node) {
return r + node.toString();
}, '') + OB + _char.SLASH + this.tag + CB;
}, '');
var tagAttrs = getTagAttrs(this.tag, this.attrs);
if (isEmpty) {
return "" + OB + tagAttrs + CB;
}
return "" + OB + tagAttrs + CB + content + OB + _char.SLASH + this.tag + CB;
};

@@ -47,0 +77,0 @@

{
"name": "@bbob/plugin-helper",
"version": "2.5.5",
"version": "2.5.6",
"description": "Set of utils to help write plugins for @bbob/core",

@@ -57,3 +57,3 @@ "keywords": [

],
"gitHead": "2670fc128892a48c636c5669b61af06f9824f057"
"gitHead": "5af63e4158f252f901b76ba54cfa7f1bbc246ec8"
}

@@ -66,2 +66,13 @@ import { N } from './char';

/**
* Gets value from
* @example
* getUniqAttr({ 'foo': true, 'bar': bar' }) => 'bar'
* @param attrs
* @returns {string}
*/
const getUniqAttr = (attrs) => Object
.keys(attrs)
.reduce((res, key) => (attrs[key] === key ? attrs[key] : null), null);
export {

@@ -72,2 +83,3 @@ attrsToString,

getNodeLength,
getUniqAttr,
isTagNode,

@@ -74,0 +86,0 @@ isStringNode,

import { OPEN_BRAKET, CLOSE_BRAKET, SLASH } from './char';
import { getNodeLength, appendToNode } from './index';
import {
getNodeLength, appendToNode, attrsToString, attrValue, getUniqAttr,
} from './index';
const getTagAttrs = (tag, params) => {
const uniqAattr = getUniqAttr(params);
if (uniqAattr) {
const tagAttr = attrValue(tag, uniqAattr);
const attrs = { ...params };
delete attrs[uniqAattr];
const attrsStr = attrsToString(attrs);
return `${tagAttr}${attrsStr}`;
}
return `${tag}${attrsToString(params)}`;
};
class TagNode {
constructor(tag, attrs, content) {
this.tag = tag.toLowerCase();
this.tag = tag;
this.attrs = attrs;

@@ -27,7 +46,18 @@ this.content = [].concat(content);

toTagNode() {
return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);
}
toString() {
const OB = OPEN_BRAKET;
const CB = CLOSE_BRAKET;
const isEmpty = this.content.length === 0;
const content = this.content.reduce((r, node) => r + node.toString(), '');
const tagAttrs = getTagAttrs(this.tag, this.attrs);
return OB + this.tag + CB + this.content.reduce((r, node) => r + node.toString(), '') + OB + SLASH + this.tag + CB;
if (isEmpty) {
return `${OB}${tagAttrs}${CB}`;
}
return `${OB}${tagAttrs}${CB}${content}${OB}${SLASH}${this.tag}${CB}`;
}

@@ -34,0 +64,0 @@ }

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