mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 21:49:48 +00:00

Greatly simplify how ESLint and its plugins are installed. PR-URL: https://github.com/nodejs/node/pull/53413 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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
|