patroon 1.2.2 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patroon",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Pattern matching library",
5
5
  "repository": "github:bas080/patroon",
6
6
  "main": "./src/index.js",
package/src/index.test.js CHANGED
@@ -57,6 +57,17 @@ test('Matches always when pattern equals value', check(gen.any, (t, val) => {
57
57
  patroon(val, () => t.end())(val)
58
58
  }))
59
59
 
60
+ test('Matches when empty array matches with empty array', t => {
61
+ patroon([], () => t.end())([])
62
+ })
63
+
64
+ test('May or may not match with any value', check(gen.any, gen.any, (t, a, b) => {
65
+ patroon(
66
+ a, () => t.end(),
67
+ _, () => t.end()
68
+ )(b)
69
+ }))
70
+
60
71
  test('Matches none of the patterns and throws', t => {
61
72
  t.plan(1)
62
73
  t.throws(() =>
package/src/walkable.js CHANGED
@@ -1,4 +1,4 @@
1
- const { isEmpty, isFunction, isNil } = require('./helpers')
1
+ const { isEmpty, isFunction, isNil, isPrimitive } = require('./helpers')
2
2
 
3
3
  function walk (config, transform, item, path = []) {
4
4
  if (config.isLeafe(item)) { return transform(item, path) }
@@ -52,7 +52,7 @@ function path (pth, v, errorData) {
52
52
 
53
53
  const [key, ...rest] = pth
54
54
 
55
- if (isNil(v) || !(key in v)) {
55
+ if (isPrimitive(v) || !(key in v)) {
56
56
  const error = new PathError(
57
57
  `Cannot read path ${pth}.`)
58
58