main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
---|
4 | exports.__esModule = true;
|
---|
5 | exports.default = exports.createRefractor = void 0;
|
---|
6 | var _index = require("./plugins/utils/index.cjs");
|
---|
7 | var _visitor = require("../traversal/visitor.cjs");
|
---|
8 | var _toolbox = _interopRequireDefault(require("./toolbox.cjs"));
|
---|
9 | const refract = (value, {
|
---|
10 | Type,
|
---|
11 | plugins = []
|
---|
12 | }) => {
|
---|
13 | /**
|
---|
14 | * This is where values gets refracted into generic ApiDOM.
|
---|
15 | * We don't allow consumers to hook into this translation.
|
---|
16 | * Though we allow consumers to define their onw plugins on already transformed ApiDOM.
|
---|
17 | */
|
---|
18 | const element = new Type(value);
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Run plugins only when necessary.
|
---|
22 | * Running plugins visitors means extra single traversal === performance hit.
|
---|
23 | */
|
---|
24 | return (0, _index.dispatchPlugins)(element, plugins, {
|
---|
25 | toolboxCreator: _toolbox.default,
|
---|
26 | visitorOptions: {
|
---|
27 | nodeTypeGetter: _visitor.getNodeType
|
---|
28 | }
|
---|
29 | });
|
---|
30 | };
|
---|
31 | const createRefractor = Type => (value, options = {}) => refract(value, {
|
---|
32 | ...options,
|
---|
33 | Type
|
---|
34 | });
|
---|
35 | exports.createRefractor = createRefractor;
|
---|
36 | var _default = exports.default = refract; |
---|
Note:
See
TracBrowser
for help on using the repository browser.