patroon 1.2.2 → 1.2.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/CONTRIBUTING.md CHANGED
@@ -32,7 +32,26 @@ We also generate the table of contents and store it in memplate.
32
32
 
33
33
  ```bash bash | memplate toc
34
34
  npx markdown-toc --no-firsth1 --maxdepth 4 README.mz
35
+ ```
36
+
37
+ For the tests in the README.mz to work we also need to install patroon.
38
+
39
+ ```bash bash
40
+ npm link
41
+ npm link patroon
42
+ ```
43
+ ```
44
+
45
+ up to date, audited 3 packages in 2s
46
+
47
+ found 0 vulnerabilities
48
+
49
+ added 1 package, and audited 78 packages in 936ms
50
+
51
+ 51 packages are looking for funding
52
+ run `npm fund` for details
35
53
 
54
+ found 0 vulnerabilities
36
55
  ```
37
56
 
38
57
  We then use memplate to template the README. Then we run [markatzea][6] to run
package/CONTRIBUTING.mz CHANGED
@@ -32,7 +32,13 @@ We also generate the table of contents and store it in memplate.
32
32
 
33
33
  ```bash bash | memplate toc
34
34
  npx markdown-toc --no-firsth1 --maxdepth 4 README.mz
35
+ ```
36
+
37
+ For the tests in the README.mz to work we also need to install patroon.
35
38
 
39
+ ```bash bash
40
+ npm link
41
+ npm link patroon
36
42
  ```
37
43
 
38
44
  We then use memplate to template the README. Then we run [markatzea][6] to run
package/README.md CHANGED
@@ -42,6 +42,26 @@ npm install patroon
42
42
 
43
43
  ## Usage
44
44
 
45
+ ```js node -
46
+ const {
47
+
48
+ patroon,
49
+
50
+ // Pattern Helpers
51
+ every,
52
+ some,
53
+ multi,
54
+ reference,
55
+ instanceOf,
56
+ _,
57
+
58
+ // Errors
59
+ NoMatchError,
60
+ UnevenArgumentCountError,
61
+ PatroonError,
62
+ } = require('patroon')
63
+ ```
64
+
45
65
  Let's see what valid and less valid uses of patroon are.
46
66
 
47
67
  > You can try out patroon over at [RunKit][runkit].
@@ -583,7 +603,7 @@ npx nyc npm t | npx tap-nyc
583
603
  npx nyc check-coverage
584
604
  ```
585
605
  ```
586
- > patroon@1.2.1 test
606
+ > patroon@1.2.3 test
587
607
  > tape ./src/index.test.js
588
608
  -------------|---------|----------|---------|---------|-------------------
589
609
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
@@ -597,7 +617,7 @@ npx nyc check-coverage
597
617
  total: 28
598
618
  passing: 28
599
619
 
600
- duration: 9s
620
+ duration: 9.6s
601
621
 
602
622
  ```
603
623
 
package/README.mz CHANGED
@@ -21,6 +21,26 @@ npm install patroon
21
21
 
22
22
  ## Usage
23
23
 
24
+ ```js node -
25
+ const {
26
+
27
+ patroon,
28
+
29
+ // Pattern Helpers
30
+ every,
31
+ some,
32
+ multi,
33
+ reference,
34
+ instanceOf,
35
+ _,
36
+
37
+ // Errors
38
+ NoMatchError,
39
+ UnevenArgumentCountError,
40
+ PatroonError,
41
+ } = require('patroon')
42
+ ```
43
+
24
44
  Let's see what valid and less valid uses of patroon are.
25
45
 
26
46
  > You can try out patroon over at [RunKit][runkit].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patroon",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
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