@mockmaster/core 1.0.3 → 1.0.4
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/README.md +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,34 @@ Creates a mock object with path, method, and response.
|
|
|
75
75
|
|
|
76
76
|
Finds the first mock matching the given path and method.
|
|
77
77
|
|
|
78
|
+
### `extractParams(pattern: string, path: string): Record<string, string> | null`
|
|
79
|
+
|
|
80
|
+
Extracts parameter values from a path.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { extractParams } from '@mockmaster/core'
|
|
84
|
+
|
|
85
|
+
const params = extractParams('/users/:id', '/users/123')
|
|
86
|
+
// { id: '123' }
|
|
87
|
+
|
|
88
|
+
const params2 = extractParams('/users/:userId/posts/:postId', '/users/1/posts/42')
|
|
89
|
+
// { userId: '1', postId: '42' }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### `createMatcher(patterns: string[]): (path: string) => boolean`
|
|
93
|
+
|
|
94
|
+
Creates a matcher function from multiple patterns.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { createMatcher } from '@mockmaster/core'
|
|
98
|
+
|
|
99
|
+
const matcher = createMatcher(['/api/*', '/users/:id'])
|
|
100
|
+
|
|
101
|
+
matcher('/api/users') // true
|
|
102
|
+
matcher('/users/123') // true
|
|
103
|
+
matcher('/posts/456') // false
|
|
104
|
+
```
|
|
105
|
+
|
|
78
106
|
## Links
|
|
79
107
|
|
|
80
108
|
- [Main Documentation](https://github.com/PxPerfectMike/MockMaster)
|