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

et-parser

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

et-parser - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

es5/configs.js

19

es5/helper.js

@@ -1,3 +0,2 @@

var SPLIT_TOKEN = '|';
var STATE_TOKEN = ':';
var configs_1 = require('./configs');
var ESCAPE_MAP = {

@@ -15,7 +14,7 @@ '&': '&',

function translateLine(line) {
var lineStates = line.split(SPLIT_TOKEN).map(function (item) { return item.trim(); });
var lineStates = line.split(configs_1.SPLIT_TOKEN).map(function (item) { return item.trim(); });
var origin = lineStates.shift();
var symbol;
if (origin.indexOf(STATE_TOKEN) === 0) {
origin = escape(origin.substr(1));
if (configs_1.REGEXP_TEST.test(origin)) {
origin = escape(origin.replace(configs_1.REGEXP_TEST, ''));
symbol = new RegExp(origin);

@@ -30,4 +29,7 @@ }

state = state.trim();
if (~state.indexOf(STATE_TOKEN)) {
var states = state.split(STATE_TOKEN);
if (state === configs_1.IGNORE_TOKEN || !~state.indexOf(configs_1.STATE_TOKEN)) {
return { prevState: state, nextState: state };
}
else {
var states = state.split(configs_1.STATE_TOKEN);
var prevState = (states[0] || '').trim();

@@ -37,5 +39,2 @@ var nextState = (states[1] || '').trim();

}
else {
return { prevState: state, nextState: state };
}
}

@@ -42,0 +41,0 @@ function symbolSorter(left, right) {

@@ -1,4 +0,2 @@

var STATE_BACK_MARK = '_';
var STATE_CHILD_REG = /^_/;
var IGNORE_TOKEN = ':::';
var configs_1 = require('./configs');
var Machine = (function () {

@@ -37,3 +35,3 @@ function Machine() {

var char = source[index];
var token = char;
var token = '';
var prevStateOut = '';

@@ -44,3 +42,3 @@ var nextStateOut = '';

var _a = this.getState(symbol, currentState), prevState = _a.prevState, nextState = _a.nextState;
if (nextState === IGNORE_TOKEN) {
if (nextState === configs_1.IGNORE_TOKEN) {
continue;

@@ -66,12 +64,24 @@ }

}
if (!token) {
token = char;
var _b = this.getState('', currentState), prevState = _b.prevState, nextState = _b.nextState;
if (nextState === configs_1.IGNORE_TOKEN) {
prevStateOut = null;
nextStateOut = null;
}
else {
prevStateOut = prevState;
nextStateOut = nextState;
}
}
return { token: token, prevState: prevStateOut, nextState: nextStateOut };
};
Machine.prototype.chargeLoopState = function (currentState, prevState, nextState, stateStack) {
var isCurrentLoop = STATE_CHILD_REG.test(currentState);
var isNextLoop = STATE_CHILD_REG.test(nextState);
var isBackState = nextState === STATE_BACK_MARK;
var isCurrentLoop = configs_1.STATE_CHILD_REG.test(currentState);
var isNextLoop = configs_1.STATE_CHILD_REG.test(nextState);
var isBackState = nextState === configs_1.STATE_BACK_MARK;
if (!isBackState && isNextLoop) {
stateStack.push(currentState);
}
if (!prevState || prevState === STATE_BACK_MARK) {
if (!prevState || prevState === configs_1.STATE_BACK_MARK) {
prevState = currentState;

@@ -78,0 +88,0 @@ }

{
"name": "et-parser",
"version": "0.1.5",
"version": "0.1.6",
"description": "A library to parse string.",

@@ -5,0 +5,0 @@ "main": "es5/parser.js",

import {Machine} from './machine';
import {SPLIT_TOKEN, STATE_TOKEN, REGEXP_TEST, IGNORE_TOKEN} from './configs';
const SPLIT_TOKEN = '|';
const STATE_TOKEN = ':';
const ESCAPE_MAP = {

@@ -25,4 +23,4 @@ '&': '&',

if (origin.indexOf(STATE_TOKEN) === 0) {
origin = escape(origin.substr(1));
if (REGEXP_TEST.test(origin)) {
origin = escape(origin.replace(REGEXP_TEST, ''));
symbol = new RegExp(origin);

@@ -37,9 +35,9 @@ } else {

state = state.trim()
if (~state.indexOf(STATE_TOKEN)) {
if (state === IGNORE_TOKEN || !~state.indexOf(STATE_TOKEN)) {
return {prevState: state, nextState: state}
} else {
let states = state.split(STATE_TOKEN);
let prevState = (states[0] || '').trim();
let nextState = (states[1] || '').trim();
return {prevState, nextState}
} else {
return {prevState: state, nextState: state}
return {prevState, nextState};
}

@@ -46,0 +44,0 @@ }

const STATE_BACK_MARK = '_';
const STATE_CHILD_REG = /^_/;
const IGNORE_TOKEN = ':::';
import {STATE_BACK_MARK, STATE_CHILD_REG, IGNORE_TOKEN} from './configs';

@@ -38,3 +36,3 @@ export class Machine {

let char = source[index];
let token = char;
let token = '';
let prevStateOut = '';

@@ -66,2 +64,15 @@ let nextStateOut = '';

}
if (!token) {// no symbol matched, go into others
token = char;
let {prevState, nextState} = this.getState('', currentState);
if (nextState === IGNORE_TOKEN) {
prevStateOut = null;
nextStateOut = null;
} else {
prevStateOut = prevState;
nextStateOut = nextState;
}
}
return {token, prevState: prevStateOut, nextState: nextStateOut}

@@ -68,0 +79,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