@swagger-api/apidom-core 0.69.2 → 0.69.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/cjs/traversal/filter.cjs +2 -6
- package/cjs/traversal/find.cjs +2 -5
- package/cjs/traversal/findAtOffset.cjs +2 -6
- package/cjs/traversal/parents.cjs +0 -1
- package/cjs/traversal/reject.cjs +3 -4
- package/cjs/traversal/some.cjs +3 -5
- package/cjs/traversal/traverse.cjs +2 -3
- package/cjs/traversal/visitor.cjs +1 -1
- package/dist/apidom-core.browser.js +1706 -1117
- package/dist/apidom-core.browser.min.js +1 -1
- package/es/traversal/filter.js +2 -6
- package/es/traversal/find.js +3 -6
- package/es/traversal/findAtOffset.js +3 -7
- package/es/traversal/parents.js +0 -1
- package/es/traversal/reject.js +4 -5
- package/es/traversal/some.js +3 -5
- package/es/traversal/traverse.js +3 -4
- package/es/traversal/visitor.js +2 -2
- package/package.json +6 -6
- package/types/dist.d.ts +6 -8
package/es/traversal/filter.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { curry } from 'ramda';
|
|
2
1
|
import { ArraySlice } from 'minim';
|
|
3
2
|
import { PredicateVisitor, visit } from "./visitor.js"; // finds all elements matching the predicate
|
|
4
|
-
|
|
5
|
-
const filter = curry((predicate, element) => {
|
|
3
|
+
const filter = (predicate, element) => {
|
|
6
4
|
const visitor = PredicateVisitor({
|
|
7
5
|
predicate
|
|
8
6
|
});
|
|
9
|
-
|
|
10
|
-
// @ts-ignore
|
|
11
7
|
visit(element, visitor);
|
|
12
8
|
return new ArraySlice(visitor.result);
|
|
13
|
-
}
|
|
9
|
+
};
|
|
14
10
|
export default filter;
|
package/es/traversal/find.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pathOr } from 'ramda';
|
|
2
2
|
import { PredicateVisitor, BREAK, visit } from "./visitor.js"; // find first element that satisfies the provided predicate
|
|
3
|
-
|
|
4
|
-
const find = curry((predicate, element) => {
|
|
3
|
+
const find = (predicate, element) => {
|
|
5
4
|
const visitor = PredicateVisitor({
|
|
6
5
|
predicate,
|
|
7
6
|
returnOnTrue: BREAK
|
|
8
7
|
});
|
|
9
|
-
|
|
10
|
-
// @ts-ignore
|
|
11
8
|
visit(element, visitor);
|
|
12
9
|
return pathOr(undefined, [0], visitor.result);
|
|
13
|
-
}
|
|
10
|
+
};
|
|
14
11
|
export default find;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import stampit from 'stampit';
|
|
2
|
-
import {
|
|
2
|
+
import { last, pathOr } from 'ramda';
|
|
3
3
|
import { isNumber } from 'ramda-adjunct';
|
|
4
4
|
import { hasElementSourceMap } from "../predicates/index.js";
|
|
5
5
|
import { visit } from "./visitor.js";
|
|
@@ -41,7 +41,7 @@ const Visitor = stampit({
|
|
|
41
41
|
// Finds the most inner node at the given offset.
|
|
42
42
|
// If includeRightBound is set, also finds nodes that end at the given offset.
|
|
43
43
|
// findAtOffset :: Number -> Element -> Element | Undefined
|
|
44
|
-
const findAtOffset =
|
|
44
|
+
const findAtOffset = (options, element) => {
|
|
45
45
|
let offset;
|
|
46
46
|
let includeRightBound;
|
|
47
47
|
if (isNumber(options)) {
|
|
@@ -55,11 +55,7 @@ const findAtOffset = curry((options, element) => {
|
|
|
55
55
|
offset,
|
|
56
56
|
includeRightBound
|
|
57
57
|
});
|
|
58
|
-
|
|
59
|
-
// @ts-ignore
|
|
60
58
|
visit(element, visitor);
|
|
61
|
-
|
|
62
|
-
// @ts-ignore
|
|
63
59
|
return last(visitor.result);
|
|
64
|
-
}
|
|
60
|
+
};
|
|
65
61
|
export default findAtOffset;
|
package/es/traversal/parents.js
CHANGED
package/es/traversal/reject.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { complement
|
|
1
|
+
import { complement } from 'ramda';
|
|
2
2
|
import filter from "./filter.js"; // complement of filter
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
3
|
+
const reject = (predicate, element) => {
|
|
4
|
+
return filter(complement(predicate), element);
|
|
5
|
+
};
|
|
7
6
|
export default reject;
|
package/es/traversal/some.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { curry } from 'ramda';
|
|
2
1
|
import { isNotUndefined } from 'ramda-adjunct';
|
|
3
2
|
import find from "./find.js"; // tests whether at least one element passes the predicate
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
3
|
+
const some = (predicate, element) => {
|
|
4
|
+
return isNotUndefined(find(predicate, element));
|
|
5
|
+
};
|
|
8
6
|
export default some;
|
package/es/traversal/traverse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import stampit from 'stampit';
|
|
2
|
-
import {
|
|
2
|
+
import { pathOr } from 'ramda';
|
|
3
3
|
import { isFunction, noop } from 'ramda-adjunct';
|
|
4
4
|
import { visit, PredicateVisitor } from "./visitor.js";
|
|
5
5
|
import { isElement } from "../predicates/index.js";
|
|
@@ -25,8 +25,7 @@ export const CallbackVisitor = stampit(PredicateVisitor, {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
// executes the callback on this element and all descendants
|
|
28
|
-
|
|
29
|
-
const traverse = curry((options, element) => {
|
|
28
|
+
const traverse = (options, element) => {
|
|
30
29
|
let callback;
|
|
31
30
|
let predicate;
|
|
32
31
|
if (isFunction(options)) {
|
|
@@ -43,5 +42,5 @@ const traverse = curry((options, element) => {
|
|
|
43
42
|
|
|
44
43
|
// @ts-ignore
|
|
45
44
|
visit(element, visitor);
|
|
46
|
-
}
|
|
45
|
+
};
|
|
47
46
|
export default traverse;
|
package/es/traversal/visitor.js
CHANGED
|
@@ -5,7 +5,7 @@ const _excluded = ["keyMap"],
|
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
import stampit from 'stampit';
|
|
8
|
-
import {
|
|
8
|
+
import { F as stubFalse, pipe } from 'ramda';
|
|
9
9
|
import { isString } from 'ramda-adjunct';
|
|
10
10
|
import { visit as astVisit, BREAK, mergeAllVisitors } from '@swagger-api/apidom-ast';
|
|
11
11
|
import { isMemberElement, isArrayElement, isStringElement, isBooleanElement, isLinkElement, isRefElement, isObjectElement, isNullElement, isNumberElement } from "../predicates/index.js";
|
|
@@ -26,7 +26,7 @@ export const getNodeType = element => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
// isNode :: Node -> Boolean
|
|
29
|
-
export const isNode =
|
|
29
|
+
export const isNode = pipe(getNodeType, isString);
|
|
30
30
|
export const keyMapDefault = {
|
|
31
31
|
ObjectElement: ['content'],
|
|
32
32
|
ArrayElement: ['content'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-core",
|
|
3
|
-
"version": "0.69.
|
|
3
|
+
"version": "0.69.3",
|
|
4
4
|
"description": "Tools for manipulating ApiDOM structures.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime-corejs3": "^7.20.7",
|
|
45
|
-
"@swagger-api/apidom-ast": "^0.69.
|
|
46
|
-
"@types/ramda": "=0.
|
|
45
|
+
"@swagger-api/apidom-ast": "^0.69.3",
|
|
46
|
+
"@types/ramda": "=0.29.0",
|
|
47
47
|
"minim": "=0.23.8",
|
|
48
|
-
"ramda": "=0.
|
|
49
|
-
"ramda-adjunct": "=
|
|
48
|
+
"ramda": "=0.29.0",
|
|
49
|
+
"ramda-adjunct": "=4.0.0",
|
|
50
50
|
"short-unique-id": "=4.4.4",
|
|
51
51
|
"stampit": "=4.3.2"
|
|
52
52
|
},
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"README.md",
|
|
62
62
|
"CHANGELOG.md"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "282b7885b28b7595534ce65b2c72f752c27cdf88"
|
|
65
65
|
}
|
package/types/dist.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference path="./minim.d.ts" />
|
|
2
|
-
/// <reference types="ts-toolbelt" />
|
|
3
2
|
import { Element, Namespace as Namespace$1, NamespacePlugin, StringElement, Meta, Attributes, ArrayElement, ArraySlice, ObjectElement } from 'minim';
|
|
4
3
|
export { ArrayElement, ArraySlice, Attributes, BooleanElement, Element, KeyValuePair, LinkElement, MemberElement, Meta, NamespacePluginOptions, NullElement, NumberElement, ObjectElement, ObjectSlice, RefElement, StringElement, refract } from 'minim';
|
|
5
|
-
import * as Function_Curry from 'Function/Curry';
|
|
6
4
|
import { Pred } from 'ramda';
|
|
7
5
|
import stampit from 'stampit';
|
|
8
6
|
export { BREAK, mergeAllVisitors } from '@swagger-api/apidom-ast';
|
|
@@ -124,26 +122,26 @@ interface PredicateHelpers {
|
|
|
124
122
|
type PredicateCreator = (helpers: PredicateHelpers) => (element: any) => boolean;
|
|
125
123
|
declare const createPredicate: (predicateCreator: PredicateCreator) => (element: any) => boolean;
|
|
126
124
|
|
|
127
|
-
declare const filter:
|
|
125
|
+
declare const filter: <T extends Element>(predicate: Pred, element: T) => ArraySlice;
|
|
128
126
|
|
|
129
|
-
declare const find:
|
|
127
|
+
declare const find: <T extends Element>(predicate: Pred, element: T) => T | undefined;
|
|
130
128
|
|
|
131
129
|
interface FindAtOffsetOptions {
|
|
132
130
|
offset: number;
|
|
133
131
|
includeRightBound?: boolean;
|
|
134
132
|
}
|
|
135
|
-
declare const findAtOffset:
|
|
133
|
+
declare const findAtOffset: <T extends Element>(options: number | FindAtOffsetOptions, element: T) => T | undefined;
|
|
136
134
|
|
|
137
|
-
declare const reject:
|
|
135
|
+
declare const reject: <T extends Element>(predicate: Pred, element: T) => ArraySlice;
|
|
138
136
|
|
|
139
|
-
declare const some:
|
|
137
|
+
declare const some: <T extends Element>(predicate: Pred, element: T) => boolean;
|
|
140
138
|
|
|
141
139
|
type Callback = <T extends Element>(element: T) => void;
|
|
142
140
|
interface TraverseOptions {
|
|
143
141
|
callback?: Callback;
|
|
144
142
|
predicate?: Pred;
|
|
145
143
|
}
|
|
146
|
-
declare const traverse:
|
|
144
|
+
declare const traverse: <T extends Element>(options: Callback | TraverseOptions, element: T) => void;
|
|
147
145
|
|
|
148
146
|
declare const parents: <T extends Element>(element: T) => WeakMap<Element, Element>;
|
|
149
147
|
|