@formvk/path 0.1.0 → 1.0.0
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 +7 -0
- package/README.md +50 -0
- package/package.json +5 -1
- package/src/__tests__/accessor.spec.ts +0 -429
- package/src/__tests__/basic.spec.ts +0 -14
- package/src/__tests__/match.spec.ts +0 -280
- package/src/__tests__/parser.spec.ts +0 -689
- package/src/__tests__/share.spec.ts +0 -43
- package/src/contexts.ts +0 -23
- package/src/destructor.ts +0 -131
- package/src/index.ts +0 -583
- package/src/matcher.ts +0 -224
- package/src/parser.ts +0 -460
- package/src/shared.ts +0 -83
- package/src/tokenizer.ts +0 -306
- package/src/tokens.ts +0 -233
- package/src/types.ts +0 -133
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -4
- package/vite.config.ts +0 -22
package/src/types.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { Path } from './index'
|
|
2
|
-
interface INode {
|
|
3
|
-
type?: string
|
|
4
|
-
after?: Node
|
|
5
|
-
depth?: number
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type Node =
|
|
9
|
-
| IdentifierNode
|
|
10
|
-
| WildcardOperatorNode
|
|
11
|
-
| GroupExpressionNode
|
|
12
|
-
| RangeExpressionNode
|
|
13
|
-
| DestructorExpressionNode
|
|
14
|
-
| ObjectPatternNode
|
|
15
|
-
| ArrayPatternNode
|
|
16
|
-
| DotOperatorNode
|
|
17
|
-
| ExpandOperatorNode
|
|
18
|
-
| INode
|
|
19
|
-
|
|
20
|
-
export type IdentifierNode = {
|
|
21
|
-
type: 'Identifier'
|
|
22
|
-
value: string
|
|
23
|
-
arrayIndex?: boolean
|
|
24
|
-
} & INode
|
|
25
|
-
|
|
26
|
-
export type IgnoreExpressionNode = {
|
|
27
|
-
type: 'IgnoreExpression'
|
|
28
|
-
value: string
|
|
29
|
-
} & INode
|
|
30
|
-
|
|
31
|
-
export type DotOperatorNode = {
|
|
32
|
-
type: 'DotOperator'
|
|
33
|
-
} & INode
|
|
34
|
-
|
|
35
|
-
export type WildcardOperatorNode = {
|
|
36
|
-
type: 'WildcardOperator'
|
|
37
|
-
filter?: GroupExpressionNode | RangeExpressionNode
|
|
38
|
-
optional?: boolean
|
|
39
|
-
} & INode
|
|
40
|
-
|
|
41
|
-
export type ExpandOperatorNode = {
|
|
42
|
-
type: 'ExpandOperator'
|
|
43
|
-
} & INode
|
|
44
|
-
|
|
45
|
-
export type GroupExpressionNode = {
|
|
46
|
-
type: 'GroupExpression'
|
|
47
|
-
value: Node[]
|
|
48
|
-
isExclude?: boolean
|
|
49
|
-
} & INode
|
|
50
|
-
|
|
51
|
-
export type RangeExpressionNode = {
|
|
52
|
-
type: 'RangeExpression'
|
|
53
|
-
start?: IdentifierNode
|
|
54
|
-
end?: IdentifierNode
|
|
55
|
-
} & INode
|
|
56
|
-
|
|
57
|
-
export type DestructorExpressionNode = {
|
|
58
|
-
type: 'DestructorExpression'
|
|
59
|
-
value?: ObjectPatternNode | ArrayPatternNode
|
|
60
|
-
source?: string
|
|
61
|
-
} & INode
|
|
62
|
-
|
|
63
|
-
export type ObjectPatternNode = {
|
|
64
|
-
type: 'ObjectPattern'
|
|
65
|
-
properties: ObjectPatternPropertyNode[]
|
|
66
|
-
} & INode
|
|
67
|
-
|
|
68
|
-
export type ObjectPatternPropertyNode = {
|
|
69
|
-
type: 'ObjectPatternProperty'
|
|
70
|
-
key: IdentifierNode
|
|
71
|
-
value?: ObjectPatternNode[] | ArrayPatternNode[] | IdentifierNode
|
|
72
|
-
} & INode
|
|
73
|
-
|
|
74
|
-
export type ArrayPatternNode = {
|
|
75
|
-
type: 'ArrayPattern'
|
|
76
|
-
elements: ObjectPatternNode[] | ArrayPatternNode[] | IdentifierNode[]
|
|
77
|
-
} & INode
|
|
78
|
-
|
|
79
|
-
export type DestructorRule = {
|
|
80
|
-
key: string | number
|
|
81
|
-
path: Array<number | string>
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type MatcherFunction = ((path: Pattern) => boolean) & {
|
|
85
|
-
path: Path
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type Pattern = string | number | Path | Segments | MatcherFunction | RegExp
|
|
89
|
-
|
|
90
|
-
export type DestructorRules = DestructorRule[]
|
|
91
|
-
|
|
92
|
-
export type Segments = Array<string | number>
|
|
93
|
-
|
|
94
|
-
export function isType<T>(type: string) {
|
|
95
|
-
return (obj: any): obj is T => {
|
|
96
|
-
return obj && obj.type === type
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export const isIdentifier = isType<IdentifierNode>('Identifier')
|
|
101
|
-
|
|
102
|
-
export const isIgnoreExpression = isType<IgnoreExpressionNode>('IgnoreExpression')
|
|
103
|
-
|
|
104
|
-
export const isDotOperator = isType<DotOperatorNode>('DotOperator')
|
|
105
|
-
|
|
106
|
-
export const isWildcardOperator = isType<WildcardOperatorNode>('WildcardOperator')
|
|
107
|
-
|
|
108
|
-
export const isExpandOperator = isType<ExpandOperatorNode>('ExpandOperator')
|
|
109
|
-
|
|
110
|
-
export const isGroupExpression = isType<GroupExpressionNode>('GroupExpression')
|
|
111
|
-
|
|
112
|
-
export const isRangeExpression = isType<RangeExpressionNode>('RangeExpression')
|
|
113
|
-
|
|
114
|
-
export const isDestructorExpression = isType<DestructorExpressionNode>('DestructorExpression')
|
|
115
|
-
|
|
116
|
-
export const isObjectPattern = isType<ObjectPatternNode>('ObjectPattern')
|
|
117
|
-
|
|
118
|
-
export const isObjectPatternProperty = isType<ObjectPatternPropertyNode>('ObjectPatternProperty')
|
|
119
|
-
|
|
120
|
-
export const isArrayPattern = isType<ArrayPatternNode>('ArrayPattern')
|
|
121
|
-
|
|
122
|
-
export type KeyType = string | number | symbol
|
|
123
|
-
|
|
124
|
-
export type IAccessors = {
|
|
125
|
-
get?: (source: any, key: KeyType) => any
|
|
126
|
-
set?: (source: any, key: KeyType, value: any) => any
|
|
127
|
-
has?: (source: any, key: KeyType) => boolean
|
|
128
|
-
delete?: (source: any, key: KeyType) => any
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export type IRegistry = {
|
|
132
|
-
accessors?: IAccessors
|
|
133
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import dts from 'vite-plugin-dts'
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
plugins: [
|
|
5
|
-
dts({
|
|
6
|
-
tsconfigPath: './tsconfig.build.json',
|
|
7
|
-
entryRoot: 'src',
|
|
8
|
-
bundleTypes: true,
|
|
9
|
-
}),
|
|
10
|
-
],
|
|
11
|
-
build: {
|
|
12
|
-
lib: {
|
|
13
|
-
entry: 'src/index.ts',
|
|
14
|
-
name: 'Formvk.Core',
|
|
15
|
-
fileName: 'index',
|
|
16
|
-
formats: ['es'],
|
|
17
|
-
},
|
|
18
|
-
minify: false,
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
target: 'esnext',
|
|
21
|
-
},
|
|
22
|
-
})
|