Socket
Socket
Sign inDemoInstall

@bbob/parser

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbob/parser - npm Package Compare versions

Comparing version 1.0.10 to 1.1.0

11

CHANGELOG.md

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

<a name="1.1.0"></a>
# [1.1.0](https://github.com/JiLiZART/bbob/compare/@bbob/parser@1.0.10...@bbob/parser@1.1.0) (2018-07-13)
### Features
* **parser:** optimize size ([4c8dbed](https://github.com/JiLiZART/bbob/commit/4c8dbed))
<a name="1.0.10"></a>

@@ -8,0 +19,0 @@ ## [1.0.10](https://github.com/JiLiZART/bbob/compare/@bbob/parser@1.0.9...@bbob/parser@1.0.10) (2018-07-11)

58

lib/parse.js

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

const {
convertTagToText,
getTagName,
getTokenColumn,
getTokenLine,
getTokenValue,
isAttrNameToken,
isAttrValueToken,
isTagStart,
isTagToken,
isTextToken,
isTagEnd,
} = require('./Token');
const Tokenizer = require('./Tokenizer');

@@ -70,10 +56,12 @@ const TagNode = require('./TagNode');

* @private
* @param {Token} token
* @return {Array}
*/
const createTagNode = token => tagNodes.push(newTagNode(getTokenValue(token)));
const createTagNode = token => tagNodes.push(newTagNode(token.getValue()));
/**
* @private
* @param {Token} token
* @return {Array}
*/
const createTagNodeAttrName = token => tagNodesAttrName.push(getTokenValue(token));
const createTagNodeAttrName = token => tagNodesAttrName.push(token.getValue());

@@ -144,6 +132,6 @@ /**

* @private
* @param token
* @param {Token} token
*/
const handleTagStart = (token) => {
if (isTagStart(token)) {
if (token.isStart()) {
createTagNode(token);

@@ -162,6 +150,6 @@

* @private
* @param token
* @param {Token} token
*/
const handleTagEnd = (token) => {
if (isTagEnd(token)) {
if (token.isEnd()) {
clearTagNode();

@@ -174,5 +162,5 @@

} else if (options.onError) {
const tag = getTokenValue(token);
const line = getTokenLine(token);
const column = getTokenColumn(token);
const tag = token.getValue();
const line = token.getLine();
const column = token.getColumn();
options.onError({

@@ -189,7 +177,7 @@ message: `Inconsistent tag '${tag}' on line ${line} and column ${column}`,

* @private
* @param token
* @param {Token} token
*/
const handleTagToken = (token) => {
if (isTagToken(token)) {
if (isAllowedTag(getTagName(token))) {
if (token.isTag()) {
if (isAllowedTag(token.getName())) {
// [tag]

@@ -201,3 +189,3 @@ handleTagStart(token);

} else {
appendNode(convertTagToText(token));
appendNode(token.toString());
}

@@ -209,3 +197,3 @@ }

* @private
* @param token
* @param {Token} token
*/

@@ -216,13 +204,13 @@ const handleTagNode = (token) => {

if (tagNode) {
if (isAttrNameToken(token)) {
if (token.isAttrName()) {
createTagNodeAttrName(token);
tagNode.attr(getTagNodeAttrName(), null);
} else if (isAttrValueToken(token)) {
tagNode.attr(getTagNodeAttrName(), getTokenValue(token));
} else if (token.isAttrValue()) {
tagNode.attr(getTagNodeAttrName(), token.getValue());
clearTagNodeAttrName();
} else if (isTextToken(token)) {
tagNode.append(getTokenValue(token));
} else if (token.isText()) {
tagNode.append(token.getValue());
}
} else if (isTextToken(token)) {
appendNode(getTokenValue(token));
} else if (token.isText()) {
appendNode(token.getValue());
}

@@ -229,0 +217,0 @@ };

@@ -83,2 +83,6 @@ const {

isStart() {
return isTagStart(this);
}
isEnd() {

@@ -121,13 +125,1 @@ return isTagEnd(this);

module.exports.TYPE_NEW_LINE = TOKEN_TYPE_NEW_LINE;
module.exports.convertTagToText = convertTagToText;
module.exports.getTagName = getTagName;
module.exports.getTokenColumn = getTokenColumn;
module.exports.getTokenLine = getTokenLine;
module.exports.getTokenValue = getTokenValue;
module.exports.isAttrNameToken = isAttrNameToken;
module.exports.isAttrValueToken = isAttrValueToken;
module.exports.isTagStart = isTagStart;
module.exports.isTagToken = isTagToken;
module.exports.isTextToken = isTextToken;
module.exports.isTagEnd = isTagEnd;

@@ -180,10 +180,26 @@ const {

charOPENBRAKET() {
this.flushWord();
this.tagToken = this.createTagToken('');
charOPENBRAKET(charCode) {
const nextCharCode = this.seekChar(1);
const isNextSpace = nextCharCode === SPACE || nextCharCode === TAB;
if (isNextSpace) {
this.createWord();
this.wordToken[Token.VALUE_ID] += getChar(charCode);
} else {
this.flushWord();
this.tagToken = this.createTagToken('');
}
this.nextCol();
}
charCLOSEBRAKET() {
charCLOSEBRAKET(charCode) {
const prevCharCode = this.seekChar(-1);
const isPrevSpace = prevCharCode === SPACE || prevCharCode === TAB;
if (isPrevSpace) {
this.wordToken[Token.VALUE_ID] += getChar(charCode);
}
this.nextCol();

@@ -327,3 +343,3 @@ this.flushTag();

isTokenNested(token) {
const value = getChar(OPEN_BRAKET) + getChar(SLASH) + Token.getTokenValue(token);
const value = getChar(OPEN_BRAKET) + getChar(SLASH) + token.getValue();
return this.buffer.indexOf(value) > -1;

@@ -335,16 +351,1 @@ }

module.exports.createTokenOfType = createTokenOfType;
module.exports.TYPE = {
WORD: Token.TYPE_WORD,
TAG: Token.TYPE_TAG,
ATTR_NAME: Token.TYPE_ATTR_NAME,
ATTR_VALUE: Token.TYPE_ATTR_VALUE,
SPACE: Token.TYPE_SPACE,
NEW_LINE: Token.TYPE_NEW_LINE,
};
module.exports.TOKEN = {
TYPE_ID: Token.TYPE_ID,
VALUE_ID: Token.VALUE_ID,
LINE_ID: Token.LINE_ID,
COLUMN_ID: Token.COLUMN_ID,
};
{
"name": "@bbob/parser",
"version": "1.0.10",
"version": "1.1.0",
"description": "Fast, flexible, and lean implementation of BBcode parser",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/JiLiZART/bbob",

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