anyone 0.1.1 → 2.0.0-dev-e266d9

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 CHANGED
@@ -4,42 +4,60 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 0.1.1 - 2021-07-17
7
+ ## 2.0.0 - 2021-12-12
8
+ ### Changed or removed
9
+ - e8652bc breaking(vest, enforce): prepare next major (ealush)
10
+ - dab8e00 breaking(vest, enforce): prepare next major (ealush)
11
+
8
12
  ### Fixed and improved
9
- - 744aec5 add integration branch references in release (ealush)
10
- - 0103b38 lint: handling lint of all packages (ealush)
13
+ - 825e74b types(n4s): fix proxy type (ealush)
14
+ - 9f9b970 vx: improve package.json generation (ealush)
15
+ - 03ba92c vx: support namespaced exports (ealush)
16
+ - bed7040 vx: add back to workspace (ealush)
17
+ - f2d458d update build artifacts (ealush)
18
+ - package.json
19
+ - .husky/pre-commit
20
+ - 4d88c04 patch: add nodejs exports (undefined)
21
+ - 26af06b chore: reduce complexity, remove all lint errors (undefined)
22
+ - .github/PULL_REQUEST_TEMPLATE.md
23
+ - ba68539 lint: handling lint of all packages (ealush)
11
24
  - .gitignore
12
- - 49b6b84 Vest 4 Infra Setup (ealush)
13
25
 
14
26
  ## 0.1.21 - 2021-07-02
27
+
15
28
  ### Fixed and improved
16
- - 33f4e46 release (undefined)
17
- - 6fe40c7 better bundle (undefined)
18
- - c6387ab before ts settings (undefined)
19
- - c0e9708 generate correct d.ts file (undefined)
20
- - 8e01b8e x (undefined)
21
- - afb3960 x (undefined)
22
- - e0a8463 add changelog support (undefined)
23
- - cc46c38 current (undefined)
29
+
30
+ - 33f4e46 release (undefined)
31
+ - 6fe40c7 better bundle (undefined)
32
+ - c6387ab before ts settings (undefined)
33
+ - c0e9708 generate correct d.ts file (undefined)
34
+ - 8e01b8e x (undefined)
35
+ - afb3960 x (undefined)
36
+ - e0a8463 add changelog support (undefined)
37
+ - cc46c38 current (undefined)
24
38
 
25
39
  ## 0.1.20 - 2021-07-02
40
+
26
41
  ### Fixed and improved
27
- - 33f4e46 release (undefined)
28
- - 6fe40c7 better bundle (undefined)
29
- - c6387ab before ts settings (undefined)
30
- - c0e9708 generate correct d.ts file (undefined)
31
- - 8e01b8e x (undefined)
32
- - afb3960 x (undefined)
33
- - e0a8463 add changelog support (undefined)
34
- - cc46c38 current (undefined)
42
+
43
+ - 33f4e46 release (undefined)
44
+ - 6fe40c7 better bundle (undefined)
45
+ - c6387ab before ts settings (undefined)
46
+ - c0e9708 generate correct d.ts file (undefined)
47
+ - 8e01b8e x (undefined)
48
+ - afb3960 x (undefined)
49
+ - e0a8463 add changelog support (undefined)
50
+ - cc46c38 current (undefined)
35
51
 
36
52
  ## 0.1.19 - 2021-07-02
53
+
37
54
  ### Fixed and improved
38
- - 33f4e46 release (undefined)
39
- - 6fe40c7 better bundle (undefined)
40
- - c6387ab before ts settings (undefined)
41
- - c0e9708 generate correct d.ts file (undefined)
42
- - 8e01b8e x (undefined)
43
- - afb3960 x (undefined)
44
- - e0a8463 add changelog support (undefined)
45
- - cc46c38 current (undefined)
55
+
56
+ - 33f4e46 release (undefined)
57
+ - 6fe40c7 better bundle (undefined)
58
+ - c6387ab before ts settings (undefined)
59
+ - c0e9708 generate correct d.ts file (undefined)
60
+ - 8e01b8e x (undefined)
61
+ - afb3960 x (undefined)
62
+ - e0a8463 add changelog support (undefined)
63
+ - cc46c38 current (undefined)
package/README.md CHANGED
@@ -47,6 +47,10 @@ yarn add anyone
47
47
 
48
48
  ## Usage Examples
49
49
 
50
+ ```js
51
+ import { any, one, all, none } from 'anyone';
52
+ ```
53
+
50
54
  ```js
51
55
  import any from 'anyone/any';
52
56
  import one from 'anyone/one';
@@ -0,0 +1,7 @@
1
+ {
2
+ "main": "../dist/cjs/all.js",
3
+ "module": "../dist/es/all.production.js",
4
+ "name": "all",
5
+ "types": "../types/all.d.ts",
6
+ "private": true
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "main": "../dist/cjs/any.js",
3
+ "module": "../dist/es/any.production.js",
4
+ "name": "any",
5
+ "types": "../types/any.d.ts",
6
+ "private": true
7
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./all.production.js');
5
+ } else {
6
+ module.exports = require('./all.development.js');
7
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./any.production.js');
5
+ } else {
6
+ module.exports = require('./any.development.js');
7
+ }
@@ -85,10 +85,7 @@ function one() {
85
85
  return false;
86
86
  }
87
87
  }
88
- if (count !== 1) {
89
- return false;
90
- }
91
- return true;
88
+ return count === 1;
92
89
  }
93
90
 
94
91
  exports.all = all;
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./anyone.production.js');
5
+ } else {
6
+ module.exports = require('./anyone.development.js');
7
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./none.production.js');
5
+ } else {
6
+ module.exports = require('./none.development.js');
7
+ }
@@ -40,10 +40,7 @@ function one() {
40
40
  return false;
41
41
  }
42
42
  }
43
- if (count !== 1) {
44
- return false;
45
- }
46
- return true;
43
+ return count === 1;
47
44
  }
48
45
 
49
46
  module.exports = one;
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./one.production.js');
5
+ } else {
6
+ module.exports = require('./one.development.js');
7
+ }
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -81,10 +81,7 @@ function one() {
81
81
  return false;
82
82
  }
83
83
  }
84
- if (count !== 1) {
85
- return false;
86
- }
87
- return true;
84
+ return count === 1;
88
85
  }
89
86
 
90
87
  export { all, any, none, one };
@@ -38,10 +38,7 @@ function one() {
38
38
  return false;
39
39
  }
40
40
  }
41
- if (count !== 1) {
42
- return false;
43
- }
44
- return true;
41
+ return count === 1;
45
42
  }
46
43
 
47
44
  export default one;
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -87,10 +87,7 @@
87
87
  return false;
88
88
  }
89
89
  }
90
- if (count !== 1) {
91
- return false;
92
- }
93
- return true;
90
+ return count === 1;
94
91
  }
95
92
 
96
93
  exports.all = all;
@@ -44,10 +44,7 @@
44
44
  return false;
45
45
  }
46
46
  }
47
- if (count !== 1) {
48
- return false;
49
- }
50
- return true;
47
+ return count === 1;
51
48
  }
52
49
 
53
50
  return one;
@@ -0,0 +1,7 @@
1
+ {
2
+ "main": "../dist/cjs/none.js",
3
+ "module": "../dist/es/none.production.js",
4
+ "name": "none",
5
+ "types": "../types/none.d.ts",
6
+ "private": true
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "main": "../dist/cjs/one.js",
3
+ "module": "../dist/es/one.production.js",
4
+ "name": "one",
5
+ "types": "../types/one.d.ts",
6
+ "private": true
7
+ }
package/package.json CHANGED
@@ -1,17 +1,166 @@
1
1
  {
2
2
  "name": "anyone",
3
3
  "license": "MIT",
4
- "main": "index.js",
5
- "types": "types",
6
- "files": [
7
- "dist",
8
- "src"
9
- ],
10
- "version": "0.1.1",
4
+ "main": "./dist/cjs/anyone.js",
5
+ "types": "./types/anyone.d.ts",
6
+ "version": "2.0.0-dev-e266d9",
11
7
  "author": "ealush",
12
8
  "scripts": {
13
9
  "test": "vx test",
14
10
  "build": "vx build",
15
11
  "release": "vx release"
12
+ },
13
+ "module": "./dist/es/anyone.production.js",
14
+ "exports": {
15
+ "./all": {
16
+ "production": {
17
+ "types": "./types/all.d.ts",
18
+ "browser": "./dist/es/all.production.js",
19
+ "umd": "./dist/umd/all.production.js",
20
+ "import": "./dist/es/all.production.js",
21
+ "require": "./dist/cjs/all.production.js",
22
+ "node": "./dist/cjs/all.production.js",
23
+ "module": "./dist/es/all.production.js",
24
+ "default": "./dist/cjs/all.production.js"
25
+ },
26
+ "development": {
27
+ "types": "./types/all.d.ts",
28
+ "browser": "./dist/es/all.development.js",
29
+ "umd": "./dist/umd/all.development.js",
30
+ "import": "./dist/es/all.development.js",
31
+ "require": "./dist/cjs/all.development.js",
32
+ "node": "./dist/cjs/all.development.js",
33
+ "module": "./dist/es/all.development.js",
34
+ "default": "./dist/cjs/all.development.js"
35
+ },
36
+ "types": "./types/all.d.ts",
37
+ "browser": "./dist/es/all.production.js",
38
+ "umd": "./dist/umd/all.production.js",
39
+ "import": "./dist/es/all.production.js",
40
+ "require": "./dist/cjs/all.production.js",
41
+ "node": "./dist/cjs/all.production.js",
42
+ "module": "./dist/es/all.production.js",
43
+ "default": "./dist/cjs/all.production.js"
44
+ },
45
+ "./any": {
46
+ "production": {
47
+ "types": "./types/any.d.ts",
48
+ "browser": "./dist/es/any.production.js",
49
+ "umd": "./dist/umd/any.production.js",
50
+ "import": "./dist/es/any.production.js",
51
+ "require": "./dist/cjs/any.production.js",
52
+ "node": "./dist/cjs/any.production.js",
53
+ "module": "./dist/es/any.production.js",
54
+ "default": "./dist/cjs/any.production.js"
55
+ },
56
+ "development": {
57
+ "types": "./types/any.d.ts",
58
+ "browser": "./dist/es/any.development.js",
59
+ "umd": "./dist/umd/any.development.js",
60
+ "import": "./dist/es/any.development.js",
61
+ "require": "./dist/cjs/any.development.js",
62
+ "node": "./dist/cjs/any.development.js",
63
+ "module": "./dist/es/any.development.js",
64
+ "default": "./dist/cjs/any.development.js"
65
+ },
66
+ "types": "./types/any.d.ts",
67
+ "browser": "./dist/es/any.production.js",
68
+ "umd": "./dist/umd/any.production.js",
69
+ "import": "./dist/es/any.production.js",
70
+ "require": "./dist/cjs/any.production.js",
71
+ "node": "./dist/cjs/any.production.js",
72
+ "module": "./dist/es/any.production.js",
73
+ "default": "./dist/cjs/any.production.js"
74
+ },
75
+ "./none": {
76
+ "production": {
77
+ "types": "./types/none.d.ts",
78
+ "browser": "./dist/es/none.production.js",
79
+ "umd": "./dist/umd/none.production.js",
80
+ "import": "./dist/es/none.production.js",
81
+ "require": "./dist/cjs/none.production.js",
82
+ "node": "./dist/cjs/none.production.js",
83
+ "module": "./dist/es/none.production.js",
84
+ "default": "./dist/cjs/none.production.js"
85
+ },
86
+ "development": {
87
+ "types": "./types/none.d.ts",
88
+ "browser": "./dist/es/none.development.js",
89
+ "umd": "./dist/umd/none.development.js",
90
+ "import": "./dist/es/none.development.js",
91
+ "require": "./dist/cjs/none.development.js",
92
+ "node": "./dist/cjs/none.development.js",
93
+ "module": "./dist/es/none.development.js",
94
+ "default": "./dist/cjs/none.development.js"
95
+ },
96
+ "types": "./types/none.d.ts",
97
+ "browser": "./dist/es/none.production.js",
98
+ "umd": "./dist/umd/none.production.js",
99
+ "import": "./dist/es/none.production.js",
100
+ "require": "./dist/cjs/none.production.js",
101
+ "node": "./dist/cjs/none.production.js",
102
+ "module": "./dist/es/none.production.js",
103
+ "default": "./dist/cjs/none.production.js"
104
+ },
105
+ "./one": {
106
+ "production": {
107
+ "types": "./types/one.d.ts",
108
+ "browser": "./dist/es/one.production.js",
109
+ "umd": "./dist/umd/one.production.js",
110
+ "import": "./dist/es/one.production.js",
111
+ "require": "./dist/cjs/one.production.js",
112
+ "node": "./dist/cjs/one.production.js",
113
+ "module": "./dist/es/one.production.js",
114
+ "default": "./dist/cjs/one.production.js"
115
+ },
116
+ "development": {
117
+ "types": "./types/one.d.ts",
118
+ "browser": "./dist/es/one.development.js",
119
+ "umd": "./dist/umd/one.development.js",
120
+ "import": "./dist/es/one.development.js",
121
+ "require": "./dist/cjs/one.development.js",
122
+ "node": "./dist/cjs/one.development.js",
123
+ "module": "./dist/es/one.development.js",
124
+ "default": "./dist/cjs/one.development.js"
125
+ },
126
+ "types": "./types/one.d.ts",
127
+ "browser": "./dist/es/one.production.js",
128
+ "umd": "./dist/umd/one.production.js",
129
+ "import": "./dist/es/one.production.js",
130
+ "require": "./dist/cjs/one.production.js",
131
+ "node": "./dist/cjs/one.production.js",
132
+ "module": "./dist/es/one.production.js",
133
+ "default": "./dist/cjs/one.production.js"
134
+ },
135
+ ".": {
136
+ "development": {
137
+ "types": "./types/anyone.d.ts",
138
+ "browser": "./dist/es/anyone.development.js",
139
+ "umd": "./dist/umd/anyone.development.js",
140
+ "import": "./dist/es/anyone.development.js",
141
+ "require": "./dist/cjs/anyone.development.js",
142
+ "node": "./dist/cjs/anyone.development.js",
143
+ "module": "./dist/es/anyone.development.js",
144
+ "default": "./dist/cjs/anyone.development.js"
145
+ },
146
+ "types": "./types/anyone.d.ts",
147
+ "browser": "./dist/es/anyone.production.js",
148
+ "umd": "./dist/umd/anyone.production.js",
149
+ "import": "./dist/es/anyone.production.js",
150
+ "require": "./dist/cjs/anyone.production.js",
151
+ "node": "./dist/cjs/anyone.production.js",
152
+ "module": "./dist/es/anyone.production.js",
153
+ "default": "./dist/cjs/anyone.production.js"
154
+ },
155
+ "./package.json": "./package.json",
156
+ "./": "./"
157
+ },
158
+ "repository": {
159
+ "type": "git",
160
+ "url": "https://github.com/ealush/vest.git",
161
+ "directory": "packages/anyone"
162
+ },
163
+ "bugs": {
164
+ "url": "https://github.com/ealush/vest.git/issues"
16
165
  }
17
166
  }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "declarationMap": true,
5
+ "declarationDir": "./types",
6
+ "outDir": "./dist"
7
+ }
8
+ }
package/types/all.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks that at all passed arguments evaluate to a truthy value.
3
+ */
4
+ declare function all(...args: unknown[]): boolean;
5
+ export { all as default };
package/types/any.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks that at least one passed argument evaluates to a truthy value.
3
+ */
4
+ declare function any(...args: unknown[]): boolean;
5
+ export { any as default };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks that at all passed arguments evaluate to a truthy value.
3
+ */
4
+ declare function all(...args: unknown[]): boolean;
5
+ /**
6
+ * Checks that at least one passed argument evaluates to a truthy value.
7
+ */
8
+ declare function any(...args: unknown[]): boolean;
9
+ /**
10
+ * Checks that at none of the passed arguments evaluate to a truthy value.
11
+ */
12
+ declare function none(...args: unknown[]): boolean;
13
+ /**
14
+ * Checks that at only one passed argument evaluates to a truthy value.
15
+ */
16
+ declare function one(...args: unknown[]): boolean;
17
+ export { all, any, none, one };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks that at none of the passed arguments evaluate to a truthy value.
3
+ */
4
+ declare function none(...args: unknown[]): boolean;
5
+ export { none as default };
package/types/one.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks that at only one passed argument evaluates to a truthy value.
3
+ */
4
+ declare function one(...args: unknown[]): boolean;
5
+ export { one as default };
package/index.js DELETED
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./dist/cjs/anyone.production.js')
5
- } else {
6
- module.exports = require('./dist/cjs/anyone.development.js')
7
- }
@@ -1,46 +0,0 @@
1
- import { sample, random } from 'lodash';
2
-
3
- import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues';
4
-
5
- import all from 'all';
6
-
7
- describe('methods/all', () => {
8
- describe('When only falsy values', () => {
9
- it('Should return false', () => {
10
- expect(
11
- all(
12
- ...Array.from({ length: random(1, 10) }, (_, i) =>
13
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
14
- )
15
- )
16
- ).toBe(false);
17
- });
18
- });
19
-
20
- describe('When only truthy values', () => {
21
- it('Should return true', () => {
22
- expect(
23
- all(
24
- ...Array.from({ length: random(1, 10) }, (_, i) =>
25
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
26
- )
27
- )
28
- ).toBe(true);
29
- });
30
- });
31
-
32
- describe('When some truthy values', () => {
33
- it('Should return false', () => {
34
- expect(
35
- all.apply(null, [
36
- ...Array.from({ length: random(1, 10) }, (_, i) =>
37
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
38
- ),
39
- ...Array.from({ length: random(1, 10) }, (_, i) =>
40
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
41
- ),
42
- ])
43
- ).toBe(false);
44
- });
45
- });
46
- });
@@ -1,59 +0,0 @@
1
- import { sample, random } from 'lodash';
2
-
3
- import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues';
4
-
5
- import any from 'any';
6
-
7
- describe('methods/any', () => {
8
- describe('When only falsy values', () => {
9
- it('Should return false', () => {
10
- expect(
11
- any(
12
- ...Array.from({ length: random(1, 10) }, (_, i) =>
13
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
14
- )
15
- )
16
- ).toBe(false);
17
- });
18
- });
19
-
20
- describe('When only truthy values', () => {
21
- it('Should return true', () => {
22
- expect(
23
- any(
24
- ...Array.from({ length: random(1, 10) }, (_, i) =>
25
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
26
- )
27
- )
28
- ).toBe(true);
29
- });
30
- });
31
-
32
- describe('When one truthy value', () => {
33
- it('Should return true', () => {
34
- expect(
35
- any.apply(null, [
36
- ...Array.from({ length: random(1, 10) }, (_, i) =>
37
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
38
- ),
39
- sample(TRUTHY_VALUES),
40
- ])
41
- ).toBe(true);
42
- });
43
- });
44
-
45
- describe('When some truthy values', () => {
46
- it('Should return true', () => {
47
- expect(
48
- any.apply(null, [
49
- ...Array.from({ length: random(1, 10) }, (_, i) =>
50
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
51
- ),
52
- ...Array.from({ length: random(1, 10) }, (_, i) =>
53
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
54
- ),
55
- ])
56
- ).toBe(true);
57
- });
58
- });
59
- });
@@ -1,3 +0,0 @@
1
- export const FALSY_VALUES = [false, 0, null, undefined, '', NaN];
2
-
3
- export const TRUTHY_VALUES = [true, 1, 'true', [], {}];
@@ -1,60 +0,0 @@
1
- import { sample, random } from 'lodash';
2
-
3
- import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues';
4
-
5
- import none from 'none';
6
-
7
-
8
- describe('methods/none', () => {
9
- describe('When only falsy values', () => {
10
- it('Should return true', () => {
11
- expect(
12
- none(
13
- ...Array.from({ length: random(1, 10) }, (_, i) =>
14
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
15
- )
16
- )
17
- ).toBe(true);
18
- });
19
- });
20
-
21
- describe('When only truthy values', () => {
22
- it('Should return false', () => {
23
- expect(
24
- none(
25
- ...Array.from({ length: random(1, 10) }, (_, i) =>
26
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
27
- )
28
- )
29
- ).toBe(false);
30
- });
31
- });
32
-
33
- describe('When one truthy value', () => {
34
- it('Should return false', () => {
35
- expect(
36
- none.apply(null, [
37
- ...Array.from({ length: random(1, 10) }, (_, i) =>
38
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
39
- ),
40
- sample(TRUTHY_VALUES),
41
- ])
42
- ).toBe(false);
43
- });
44
- });
45
-
46
- describe('When some truthy values', () => {
47
- it('Should return false', () => {
48
- expect(
49
- none.apply(null, [
50
- ...Array.from({ length: random(1, 10) }, (_, i) =>
51
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
52
- ),
53
- ...Array.from({ length: random(1, 10) }, (_, i) =>
54
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
55
- ),
56
- ])
57
- ).toBe(false);
58
- });
59
- });
60
- });
@@ -1,56 +0,0 @@
1
- import { sample, random } from 'lodash';
2
-
3
- import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues';
4
-
5
- import one from 'one';
6
-
7
-
8
- describe('methods/one', () => {
9
- describe('When only falsy values', () => {
10
- it('Should return false', () => {
11
- expect(
12
- one(
13
- ...Array.from({ length: random(1, 10) }, (_, i) =>
14
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
15
- )
16
- )
17
- ).toBe(false);
18
- });
19
- });
20
-
21
- describe('When only truthy values', () => {
22
- it('Should return false', () => {
23
- expect(
24
- one(
25
- ...Array.from({ length: random(2, 10) }, (_, i) =>
26
- i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
27
- )
28
- )
29
- ).toBe(false);
30
- });
31
- });
32
-
33
- describe('When one truthy value', () => {
34
- it('Should return true', () => {
35
- expect(
36
- one(
37
- ...Array.from({ length: random(1, 10) }, (_, i) =>
38
- i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
39
- ),
40
- sample(TRUTHY_VALUES)
41
- )
42
- ).toBe(true);
43
- });
44
- });
45
-
46
- describe('When some truthy values', () => {
47
- it('Should return false', () => {
48
- expect(
49
- one(
50
- ...Array.from({ length: random(2, 10) }, () => sample(TRUTHY_VALUES)),
51
- ...Array.from({ length: random(1, 10) }, () => sample(FALSY_VALUES))
52
- )
53
- ).toBe(false);
54
- });
55
- });
56
- });
@@ -1,32 +0,0 @@
1
- import { FALSY_VALUES, TRUTHY_VALUES } from './anyoneTestValues';
2
-
3
- import run from 'runAnyoneMethods';
4
-
5
-
6
- describe('lib/run', () => {
7
- describe('When value is falsy', () => {
8
- it.each([FALSY_VALUES])('Should return `false` ("%s")', value =>
9
- expect(run(value)).toBe(false)
10
- );
11
- });
12
-
13
- describe('When value is truthy', () => {
14
- it.each([TRUTHY_VALUES])('Should return `true` ("%s")', value =>
15
- expect(run(value)).toBe(true)
16
- );
17
- });
18
-
19
- describe('When value is a function', () => {
20
- describe('When value is falsy', () => {
21
- it.each([FALSY_VALUES])('Should return `false` ("%s")', value =>
22
- expect(run(() => value)).toBe(false)
23
- );
24
- });
25
-
26
- describe('When value is truthy', () => {
27
- it.each([TRUTHY_VALUES])('Should return `true` ("%s")', value =>
28
- expect(run(() => value)).toBe(true)
29
- );
30
- });
31
- });
32
- });
package/src/anyone.ts DELETED
@@ -1,4 +0,0 @@
1
- export { default as all } from 'all';
2
- export { default as any } from 'any';
3
- export { default as none } from 'none';
4
- export { default as one } from 'one';
@@ -1,8 +0,0 @@
1
- import run from 'runAnyoneMethods';
2
-
3
- /**
4
- * Checks that at all passed arguments evaluate to a truthy value.
5
- */
6
- export default function all(...args: unknown[]): boolean {
7
- return args.every(run);
8
- }
@@ -1,8 +0,0 @@
1
- import run from 'runAnyoneMethods';
2
-
3
- /**
4
- * Checks that at least one passed argument evaluates to a truthy value.
5
- */
6
- export default function any(...args: unknown[]): boolean {
7
- return args.some(run);
8
- }
@@ -1,10 +0,0 @@
1
- import bindNot from 'bindNot';
2
-
3
- import run from 'runAnyoneMethods';
4
-
5
- /**
6
- * Checks that at none of the passed arguments evaluate to a truthy value.
7
- */
8
- export default function none(...args: unknown[]): boolean {
9
- return args.every(bindNot(run));
10
- }
@@ -1,24 +0,0 @@
1
- import run from 'runAnyoneMethods';
2
-
3
- /**
4
- * Checks that at only one passed argument evaluates to a truthy value.
5
- */
6
- export default function one(...args: unknown[]): boolean {
7
- let count = 0;
8
-
9
- for (let i = 0; i < args.length; i++) {
10
- if (run(args[i])) {
11
- count++;
12
- }
13
-
14
- if (count > 1) {
15
- return false;
16
- }
17
- }
18
-
19
- if (count !== 1) {
20
- return false;
21
- }
22
-
23
- return true;
24
- }
@@ -1,21 +0,0 @@
1
- import isFunction from 'isFunction';
2
-
3
- /**
4
- * Accepts a value or a function, and coerces it into a boolean value
5
- */
6
- export default function run(arg: unknown): boolean {
7
- if (isFunction(arg)) {
8
- try {
9
- return check(arg());
10
- } catch (err) {
11
- return false;
12
- }
13
- }
14
-
15
- return check(arg);
16
- }
17
-
18
- function check(value: unknown): boolean {
19
- // We use abstract equality intentionally here. This enables falsy valueOf support.
20
- return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
21
- }