remove bare for .. of iterations - fixes #220
This commit is contained in:
@@ -564,11 +564,11 @@ export const typeMapGetAll = (parent) => {
|
||||
* @type {Object<string,any>}
|
||||
*/
|
||||
const res = {}
|
||||
for (const [key, value] of parent._map) {
|
||||
parent._map.forEach((value, key) => {
|
||||
if (!value.deleted) {
|
||||
res[key] = value.content.getContent()[value.length - 1]
|
||||
}
|
||||
}
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ export class YMap extends AbstractType {
|
||||
*/
|
||||
_integrate (y, item) {
|
||||
super._integrate(y, item)
|
||||
for (const [key, value] of /** @type {Map<string, any>} */ (this._prelimContent)) {
|
||||
;/** @type {Map<string, any>} */ (this._prelimContent).forEach((value, key) => {
|
||||
this.set(key, value)
|
||||
}
|
||||
})
|
||||
this._prelimContent = null
|
||||
}
|
||||
|
||||
@@ -104,12 +104,12 @@ export class YMap extends AbstractType {
|
||||
* @type {Object<string,T>}
|
||||
*/
|
||||
const map = {}
|
||||
for (const [key, item] of this._map) {
|
||||
this._map.forEach((item, key) => {
|
||||
if (!item.deleted) {
|
||||
const v = item.content.getContent()[item.length - 1]
|
||||
map[key] = v instanceof AbstractType ? v.toJSON() : v
|
||||
}
|
||||
}
|
||||
})
|
||||
return map
|
||||
}
|
||||
|
||||
@@ -159,11 +159,11 @@ export class YMap extends AbstractType {
|
||||
* @type {Object<string,T>}
|
||||
*/
|
||||
const map = {}
|
||||
for (const [key, item] of this._map) {
|
||||
this._map.forEach((item, key) => {
|
||||
if (!item.deleted) {
|
||||
f(item.content.getContent()[item.length - 1], key, this)
|
||||
}
|
||||
}
|
||||
})
|
||||
return map
|
||||
}
|
||||
|
||||
|
||||
@@ -149,10 +149,10 @@ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes
|
||||
}
|
||||
const doc = transaction.doc
|
||||
const ownClientId = doc.clientID
|
||||
for (const [key, val] of negatedAttributes) {
|
||||
negatedAttributes.forEach((val, key) => {
|
||||
left = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))
|
||||
left.integrate(transaction, 0)
|
||||
}
|
||||
})
|
||||
currPos.left = left
|
||||
currPos.right = right
|
||||
}
|
||||
@@ -244,11 +244,11 @@ const insertAttributes = (transaction, parent, currPos, currentAttributes, attri
|
||||
* @function
|
||||
**/
|
||||
const insertText = (transaction, parent, currPos, currentAttributes, text, attributes) => {
|
||||
for (const [key] of currentAttributes) {
|
||||
currentAttributes.forEach((val, key) => {
|
||||
if (attributes[key] === undefined) {
|
||||
attributes[key] = null
|
||||
}
|
||||
}
|
||||
})
|
||||
const doc = transaction.doc
|
||||
const ownClientId = doc.clientID
|
||||
minimizeAttributeChanges(currPos, currentAttributes, attributes)
|
||||
@@ -567,11 +567,11 @@ export class YTextEvent extends YEvent {
|
||||
op = { insert }
|
||||
if (currentAttributes.size > 0) {
|
||||
op.attributes = {}
|
||||
for (const [key, value] of currentAttributes) {
|
||||
currentAttributes.forEach((value, key) => {
|
||||
if (value !== null) {
|
||||
op.attributes[key] = value
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
insert = ''
|
||||
break
|
||||
@@ -771,7 +771,7 @@ export class YText extends AbstractType {
|
||||
if (!transaction.local) {
|
||||
// check if another formatting item was inserted
|
||||
let foundFormattingItem = false
|
||||
for (const [client, afterClock] of transaction.afterState) {
|
||||
for (const [client, afterClock] of transaction.afterState.entries()) {
|
||||
const clock = transaction.beforeState.get(client) || 0
|
||||
if (afterClock === clock) {
|
||||
continue
|
||||
@@ -908,10 +908,10 @@ export class YText extends AbstractType {
|
||||
*/
|
||||
const attributes = {}
|
||||
let addAttributes = false
|
||||
for (const [key, value] of currentAttributes) {
|
||||
currentAttributes.forEach((value, key) => {
|
||||
addAttributes = true
|
||||
attributes[key] = value
|
||||
}
|
||||
})
|
||||
/**
|
||||
* @type {Object<string,any>}
|
||||
*/
|
||||
@@ -965,9 +965,9 @@ export class YText extends AbstractType {
|
||||
if (currentAttributes.size > 0) {
|
||||
const attrs = /** @type {Object<string,any>} */ ({})
|
||||
op.attributes = attrs
|
||||
for (const [key, value] of currentAttributes) {
|
||||
currentAttributes.forEach((value, key) => {
|
||||
attrs[key] = value
|
||||
}
|
||||
})
|
||||
}
|
||||
ops.push(op)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user