caesar-parser
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -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 |
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
62430
4
2033
- Removedreact@~0.13.3
- Removedacorn@5.7.4(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedast-types@0.9.6(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase62@1.2.8(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcommoner@0.10.8(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddefined@1.0.1(transitive)
- Removeddetective@4.7.1(transitive)
- Removedenvify@3.4.1(transitive)
- Removedesprima@3.1.3(transitive)
- Removedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
- Removedglob@5.0.15(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjstransform@11.0.3(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedobject-assign@2.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedprivate@0.1.8(transitive)
- Removedq@1.5.1(transitive)
- Removedreact@0.13.3(transitive)
- Removedrecast@0.11.23(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsource-map@0.4.40.5.7(transitive)
- Removedthrough@2.3.8(transitive)
- Removedwrappy@1.0.2(transitive)