patroon 1.1.1 → 1.1.2
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 +7 -7
- package/package.json +1 -1
- package/src/index.js +2 -1
- package/src/index.test.js +19 -0
- package/src/walkable.js +1 -1
package/README.md
CHANGED
|
@@ -519,7 +519,7 @@ oneIsTwo(3)
|
|
|
519
519
|
```
|
|
520
520
|
```
|
|
521
521
|
[ 3 ]
|
|
522
|
-
/home/ant/projects/patroon/src/index.js:
|
|
522
|
+
/home/ant/projects/patroon/src/index.js:93
|
|
523
523
|
throw error
|
|
524
524
|
^
|
|
525
525
|
|
|
@@ -534,12 +534,12 @@ Another error that occurs is when the patroon function is not used correctly.
|
|
|
534
534
|
patroon(1)
|
|
535
535
|
```
|
|
536
536
|
```
|
|
537
|
-
/home/ant/projects/patroon/src/index.js:
|
|
537
|
+
/home/ant/projects/patroon/src/index.js:80
|
|
538
538
|
if (!isEven(list.length)) { throw new UnevenArgumentCountError('Patroon should have an even amount of arguments.') }
|
|
539
539
|
^
|
|
540
540
|
|
|
541
541
|
UnevenArgumentCountError: Patroon should have an even amount of arguments.
|
|
542
|
-
at patroon (/home/ant/projects/patroon/src/index.js:
|
|
542
|
+
at patroon (/home/ant/projects/patroon/src/index.js:80:37)
|
|
543
543
|
```
|
|
544
544
|
|
|
545
545
|
#### PatroonError
|
|
@@ -583,7 +583,7 @@ npx nyc npm t | npx tap-nyc
|
|
|
583
583
|
npx nyc check-coverage
|
|
584
584
|
```
|
|
585
585
|
```
|
|
586
|
-
> patroon@1.1.
|
|
586
|
+
> patroon@1.1.2 test
|
|
587
587
|
> tape ./src/index.test.js
|
|
588
588
|
-------------|---------|----------|---------|---------|-------------------
|
|
589
589
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
@@ -594,10 +594,10 @@ npx nyc check-coverage
|
|
|
594
594
|
walkable.js | 100 | 100 | 100 | 100 |
|
|
595
595
|
-------------|---------|----------|---------|---------|-------------------
|
|
596
596
|
|
|
597
|
-
total:
|
|
598
|
-
passing:
|
|
597
|
+
total: 19
|
|
598
|
+
passing: 19
|
|
599
599
|
|
|
600
|
-
duration: 1.
|
|
600
|
+
duration: 1.5s
|
|
601
601
|
|
|
602
602
|
```
|
|
603
603
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { mapLeaves, path, PathError } = require('./walkable')()
|
|
2
2
|
const { isFunction, equals, T, is, tryCatch, isEven, isNil, toPairs, always } = require('./helpers')
|
|
3
|
+
const { inspect } = require('util')
|
|
3
4
|
|
|
4
5
|
const deprecated = (fn, message) => (...args) => {
|
|
5
6
|
console.error(`[patroon] deprecated: ${message}`)
|
|
@@ -87,7 +88,7 @@ const patroon = (...list) => {
|
|
|
87
88
|
const error = new NoMatchError('Not able to match any pattern for arguments')
|
|
88
89
|
error.arguments = args
|
|
89
90
|
|
|
90
|
-
console.error(args)
|
|
91
|
+
console.error(inspect(args))
|
|
91
92
|
|
|
92
93
|
throw error
|
|
93
94
|
}
|
package/src/index.test.js
CHANGED
|
@@ -171,3 +171,22 @@ test('Deprecated functions', ts => {
|
|
|
171
171
|
console.error = consoleError
|
|
172
172
|
ts.end()
|
|
173
173
|
})
|
|
174
|
+
|
|
175
|
+
// Circular reference
|
|
176
|
+
const circular = {}
|
|
177
|
+
circular.a = circular
|
|
178
|
+
|
|
179
|
+
test('At the moment recursive patterns throw and print', t => {
|
|
180
|
+
t.plan(1)
|
|
181
|
+
t.throws(() => patroon(circular, true)({}))
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test('Throws and prints because path is not defined', t => {
|
|
185
|
+
t.plan(1)
|
|
186
|
+
t.throws(() => patroon({ b: _ }, true)(circular))
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
test('Does not throw when value is recursive', t => {
|
|
190
|
+
t.plan(1)
|
|
191
|
+
t.ok(patroon({ a: _ }, true)(circular))
|
|
192
|
+
})
|
package/src/walkable.js
CHANGED