mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-11 14:14:36 +08:00
DISABLE_THIRD_PARTY_CHECK=NPM update R=jacktfranklin@chromium.org Bug: none Change-Id: I41b7006f336b9465677cc7434abd70a732c58221 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2692907 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
32 lines
546 B
JavaScript
32 lines
546 B
JavaScript
'use strict'
|
|
|
|
var markdownSpace = require('../character/markdown-space.js')
|
|
|
|
function spaceFactory(effects, ok, type, max) {
|
|
var limit = max ? max - 1 : Infinity
|
|
var size = 0
|
|
|
|
return start
|
|
|
|
function start(code) {
|
|
if (markdownSpace(code)) {
|
|
effects.enter(type)
|
|
return prefix(code)
|
|
}
|
|
|
|
return ok(code)
|
|
}
|
|
|
|
function prefix(code) {
|
|
if (markdownSpace(code) && size++ < limit) {
|
|
effects.consume(code)
|
|
return prefix
|
|
}
|
|
|
|
effects.exit(type)
|
|
return ok(code)
|
|
}
|
|
}
|
|
|
|
module.exports = spaceFactory
|