mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-11 06:04:55 +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>
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
'use strict'
|
|
|
|
var hasOwnProperty = require('../constant/has-own-property.js')
|
|
var chunkedSplice = require('./chunked-splice.js')
|
|
var miniflat = require('./miniflat.js')
|
|
|
|
// Combine several syntax extensions into one.
|
|
function combineExtensions(extensions) {
|
|
var all = {}
|
|
var index = -1
|
|
|
|
while (++index < extensions.length) {
|
|
extension(all, extensions[index])
|
|
}
|
|
|
|
return all
|
|
}
|
|
|
|
function extension(all, extension) {
|
|
var hook
|
|
var left
|
|
var right
|
|
var code
|
|
|
|
for (hook in extension) {
|
|
left = hasOwnProperty.call(all, hook) ? all[hook] : (all[hook] = {})
|
|
right = extension[hook]
|
|
|
|
for (code in right) {
|
|
left[code] = constructs(
|
|
miniflat(right[code]),
|
|
hasOwnProperty.call(left, code) ? left[code] : []
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
function constructs(list, existing) {
|
|
var index = -1
|
|
var before = []
|
|
|
|
while (++index < list.length) {
|
|
;(list[index].add === 'after' ? existing : before).push(list[index])
|
|
}
|
|
|
|
chunkedSplice(existing, 0, 0, before)
|
|
return existing
|
|
}
|
|
|
|
module.exports = combineExtensions
|