1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 19:01:54 +02:00

Update benchmark to use Value (#1420)

This commit is contained in:
Nicolas Gaborit
2017-11-19 21:46:52 +01:00
committed by Ian Storm Taylor
parent 0d43d26f91
commit aec62f06ba
27 changed files with 135 additions and 135 deletions

View File

@@ -35,7 +35,7 @@ export default function (state) {
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -45,5 +45,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -9,7 +9,7 @@ export default function (state) {
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -21,5 +21,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -6,13 +6,13 @@ import ReactDOM from 'react-dom/server'
import h from '../../test/helpers/h'
import { Editor } from '../..'
export default function (state) {
const el = React.createElement(Editor, { state })
export default function (value) {
const el = React.createElement(Editor, { value })
ReactDOM.renderToStaticMarkup(el)
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -24,5 +24,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -7,13 +7,13 @@ export default function (change) {
change.deleteBackward()
}
export function before(state) {
const change = state.change()
export function before(value) {
const change = value.change()
return change
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -26,5 +26,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -7,13 +7,13 @@ export default function (change) {
change.deleteForward()
}
export function before(state) {
const change = state.change()
export function before(value) {
const change = value.change()
return change
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -26,5 +26,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -10,15 +10,15 @@ export default function ({ change, keys }) {
}
}
export function before(state) {
const change = state.change()
const keys = state.document.getTexts().toArray().map(t => t.key)
export function before(value) {
const change = value.change()
const keys = value.document.getTexts().toArray().map(t => t.key)
__clear()
return { change, keys }
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -31,5 +31,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -8,15 +8,15 @@ export default function ({ change, text }) {
change.insertTextByKey(text.key, 0, 'a')
}
export function before(state) {
const change = state.change()
const text = state.document.getLastText()
export function before(value) {
const change = value.change()
const text = value.document.getLastText()
__clear()
return { change, text }
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -29,5 +29,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -7,13 +7,13 @@ export default function (change) {
change.insertText('a')
}
export function before(state) {
const change = state.change()
export function before(value) {
const change = value.change()
return change
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -26,5 +26,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,14 +3,16 @@
import h from '../../test/helpers/h'
export default function (state) {
state
.change()
.normalize()
export default function (change) {
change.normalize()
}
export function before(value) {
return value.change()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -23,5 +25,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -7,13 +7,13 @@ export default function (change) {
change.splitBlock()
}
export function before(state) {
const change = state.change()
export function before(value) {
const change = value.change()
return change
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
@@ -26,5 +26,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -1,11 +1,9 @@
/** @jsx h */
/* eslint-disable react/jsx-key */
import h from '../../test/helpers/h'
import { State } from '../..'
import { Value } from '../..'
export default function (json) {
State.fromJSON(json)
Value.fromJSON(json)
}
export const input = {

View File

@@ -3,19 +3,19 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getBlocksAtRange(state.selection)
export default function (value) {
value.document.getBlocksAtRange(value.selection)
}
export function before(state) {
return state
export function before(value) {
return value
.change()
.selectAll()
.state
.value
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,12 +3,12 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getBlocks()
export default function (value) {
value.document.getBlocks()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -20,5 +20,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,19 +3,19 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getCharactersAtRange(state.selection)
export default function (value) {
value.document.getCharactersAtRange(value.selection)
}
export function before(state) {
return state
export function before(value) {
return value
.change()
.selectAll()
.state
.value
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,12 +3,12 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getCharacters()
export default function (value) {
value.document.getCharacters()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -20,5 +20,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,19 +3,19 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getInlinesAtRange(state.selection)
export default function (value) {
value.document.getInlinesAtRange(value.selection)
}
export function before(state) {
return state
export function before(value) {
return value
.change()
.selectAll()
.state
.value
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,12 +3,12 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getInlines()
export default function (value) {
value.document.getInlines()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -20,5 +20,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -8,14 +8,14 @@ export default function (text) {
text.getLeaves()
}
export function before(state) {
const text = state.document.getFirstText()
export function before(value) {
const text = value.document.getFirstText()
__clear()
return text
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,19 +3,19 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getMarksAtRange(state.selection)
export default function (value) {
value.document.getMarksAtRange(value.selection)
}
export function before(state) {
return state
export function before(value) {
return value
.change()
.selectAll()
.state
.value
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,12 +3,12 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getMarks()
export default function (value) {
value.document.getMarks()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -20,5 +20,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -4,18 +4,18 @@
import h from '../../test/helpers/h'
import { __clear } from '../../lib/utils/memoize'
export default function ({ state, text }) {
state.document.getPath(text.key)
export default function ({ value, text }) {
value.document.getPath(text.key)
}
export function before(state) {
const text = state.document.getLastText()
export function before(value) {
const text = value.document.getLastText()
__clear()
return { state, text }
return { value, text }
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,19 +3,19 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getTextsAtRange(state.selection)
export default function (value) {
value.document.getTextsAtRange(value.selection)
}
export function before(state) {
return state
export function before(value) {
return value
.change()
.selectAll()
.state
.value
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,12 +3,12 @@
import h from '../../test/helpers/h'
export default function (state) {
state.document.getTexts()
export default function (value) {
value.document.getTexts()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -20,5 +20,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -4,20 +4,20 @@
import h from '../../test/helpers/h'
import { __clear } from '../../lib/utils/memoize'
export default function ({ state, keys }) {
export default function ({ value, keys }) {
keys.forEach((key) => {
state.document.hasNode(key)
value.document.hasNode(key)
})
}
export function before(state) {
const keys = state.document.getTexts().toArray().map(t => t.key)
export function before(value) {
const keys = value.document.getTexts().toArray().map(t => t.key)
__clear()
return { state, keys }
return { value, keys }
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -29,5 +29,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -4,18 +4,18 @@
import h from '../../test/helpers/h'
import { __clear } from '../../lib/utils/memoize'
export default function ({ state, text }) {
state.document.hasNode(text.key)
export default function ({ value, text }) {
value.document.hasNode(text.key)
}
export function before(state) {
const text = state.document.getLastText()
export function before(value) {
const text = value.document.getLastText()
__clear()
return { state, text }
return { value, text }
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -27,5 +27,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -3,12 +3,12 @@
import h from '../../test/helpers/h'
export default function (state) {
state.toJSON()
export default function (value) {
value.toJSON()
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -20,5 +20,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)

View File

@@ -4,21 +4,21 @@
import h from '../../test/helpers/h'
import { __clear } from '../../lib/utils/memoize'
export default function ({ state, next }) {
state.document.updateNode(next)
export default function ({ value, next }) {
value.document.updateNode(next)
}
export function before(state) {
const texts = state.document.getTexts()
export function before(value) {
const texts = value.document.getTexts()
const { size } = texts
const text = texts.get(Math.round(size / 2))
const next = text.insertText(0, 'some text')
__clear()
return { state, next }
return { value, next }
}
export const input = (
<state>
<value>
<document>
{Array.from(Array(10)).map(() => (
<quote>
@@ -30,5 +30,5 @@ export const input = (
</quote>
))}
</document>
</state>
</value>
)