PageSourceSearch

https://wiki-to-yes.org/public/generated/js/vendor_dist/@popperjs/core/dist/esm/utils/orderModifiers.js

js wiki-to-yes.org collected 2026-10-06 10:36:12 UTC 1,240 bytes, 44 lines download raw bytes

vendor: 1,240 bytes, lines 1-44
1import { modifierPhases } from "../enums.js"; // source: https://stackoverflow.com/questions/49875255
2
3function order(modifiers) {
4  var map = new Map();
5  var visited = new Set();
6  var result = [];
7  modifiers.forEach(function (modifier) {
8    map.set(modifier.name, modifier);
9  }); // On visiting object, check for its dependencies and visit them recursively
10
11  function sort(modifier) {
12    visited.add(modifier.name);
13    var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
14    requires.forEach(function (dep) {
15      if (!visited.has(dep)) {
16        var depModifier = map.get(dep);
17
18        if (depModifier) {
19          sort(depModifier);
20        }
21      }
22    });
23    result.push(modifier);
24  }
25
26  modifiers.forEach(function (modifier) {
27    if (!visited.has(modifier.name)) {
28      // check for visited object
29      sort(modifier);
30    }
31  });
32  return result;
33}
34
35export default function orderModifiers(modifiers) {
36  // order based on dependencies
37  var orderedModifiers = order(modifiers); // order based on phase
38
39  return modifierPhases.reduce(function (acc, phase) {
40    return acc.concat(orderedModifiers.filter(function (modifier) {
41      return modifier.phase === phase;
42    }));
43  }, []);
44}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.