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

caesar-parser

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caesar-parser - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

22

lib/Doc.js

@@ -20,2 +20,3 @@ 'use strict';

var emptyStack = new _immutable.List();
var count = 0;

@@ -60,8 +61,12 @@ var Doc = (function () {

return new _immutable.Map({
var line = new _immutable.Map({
content: content !== undefined ? content : '',
context: context || null,
styleStack: styleStack ? new _immutable.List(styleStack) : emptyStack,
indentStack: indentStack ? new _immutable.List(indentStack) : emptyStack
});
// 没创建的行都会有唯一的标记
line.id = count++;
// context 不保存到Map里以免影响hashCode判断
line.context = context;
return line;
}

@@ -75,9 +80,8 @@ }, {

var oldContent = oldRow.get('content');
var newRow = undefined;
if (data.content !== undefined && oldContent !== data.content) {
// clear other data if content changed
newRow = this._createRow({ content: data.content });
} else {
data.content = oldContent;
newRow = this._createRow(data);
data.content = data.content === undefined ? oldContent : data.content;
var newRow = this._createRow(data);
// 如果hashCode没变, 则只更新context
if (oldRow.hashCode() === newRow.hashCode()) {
oldRow.context = newRow.context === undefined ? oldRow.context : newRow.context;
return this._code;
}

@@ -84,0 +88,0 @@ return this._code.set(index, newRow);

@@ -275,3 +275,3 @@ 'use strict';

var preCtx = undefined;
if (preRow && (preCtx = preRow.get('context'))) {
if (preRow && (preCtx = preRow.context)) {
// 获取之前的状态

@@ -278,0 +278,0 @@ this.ctx = preCtx;

{
"name": "caesar-parser",
"version": "0.2.1",
"version": "0.2.2",
"description": "",

@@ -55,5 +55,4 @@ "main": "lib/index.js",

"immutable": "~3.7.5",
"object-assign": "~3.0.0",
"react": "~0.13.3"
"object-assign": "~3.0.0"
}
}
import immutable, {Map, List} from 'immutable'
import {ENDED_REG} from './constants'
const emptyStack = new List()
let count = 0

@@ -26,8 +27,12 @@ class Doc {

_createRow({content, styleStack, indentStack, context}) {
return new Map({
const line = new Map({
content: content !== undefined ? content : '',
context: context || null,
styleStack: styleStack ? new List(styleStack) : emptyStack,
indentStack: indentStack ? new List(indentStack) : emptyStack,
})
// 没创建的行都会有唯一的标记
line.id = count ++
// context 不保存到Map里以免影响hashCode判断
line.context = context
return line
}

@@ -37,9 +42,8 @@ updateRow(index, data = {}) {

const oldContent = oldRow.get('content')
let newRow
if (data.content !== undefined && oldContent !== data.content) {
// clear other data if content changed
newRow = this._createRow({content: data.content})
} else {
data.content = oldContent
newRow = this._createRow(data)
data.content = data.content === undefined ? oldContent : data.content
const newRow = this._createRow(data)
// 如果hashCode没变, 则只更新context
if (oldRow.hashCode() === newRow.hashCode()) {
oldRow.context = newRow.context === undefined ? oldRow.context : newRow.context
return this._code
}

@@ -46,0 +50,0 @@ return this._code.set(index, newRow)

@@ -185,3 +185,3 @@ import {EventEmitter} from 'events'

let preCtx
if (preRow && (preCtx = preRow.get('context'))) {
if (preRow && (preCtx = preRow.context)) {
// 获取之前的状态

@@ -188,0 +188,0 @@ this.ctx = preCtx

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