anyone 0.0.7 → 2.0.0-dev-031d95
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 +63 -0
- package/LICENSE +2 -2
- package/README.md +37 -37
- package/all/package.json +7 -0
- package/any/package.json +7 -0
- package/dist/cjs/all.development.js +37 -0
- package/dist/cjs/all.js +7 -0
- package/dist/cjs/all.production.js +1 -0
- package/dist/cjs/any.development.js +37 -0
- package/dist/cjs/any.js +7 -0
- package/dist/cjs/any.production.js +1 -0
- package/dist/cjs/anyone.development.js +94 -0
- package/dist/cjs/anyone.js +7 -0
- package/dist/cjs/anyone.production.js +1 -0
- package/dist/cjs/none.development.js +47 -0
- package/dist/cjs/none.js +7 -0
- package/dist/cjs/none.production.js +1 -0
- package/dist/cjs/one.development.js +46 -0
- package/dist/cjs/one.js +7 -0
- package/dist/cjs/one.production.js +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/es/all.development.js +35 -0
- package/dist/es/all.production.js +1 -0
- package/dist/es/any.development.js +35 -0
- package/dist/es/any.production.js +1 -0
- package/dist/es/anyone.development.js +87 -0
- package/dist/es/anyone.production.js +1 -0
- package/dist/es/none.development.js +45 -0
- package/dist/es/none.production.js +1 -0
- package/dist/es/one.development.js +44 -0
- package/dist/es/one.production.js +1 -0
- package/dist/es/package.json +1 -0
- package/dist/umd/all.development.js +43 -0
- package/dist/umd/all.production.js +1 -0
- package/dist/umd/any.development.js +43 -0
- package/dist/umd/any.production.js +1 -0
- package/dist/umd/anyone.development.js +100 -0
- package/dist/umd/anyone.production.js +1 -0
- package/dist/umd/none.development.js +53 -0
- package/dist/umd/none.production.js +1 -0
- package/dist/umd/one.development.js +52 -0
- package/dist/umd/one.production.js +1 -0
- package/none/package.json +7 -0
- package/one/package.json +7 -0
- package/package.json +156 -30
- package/tsconfig.json +8 -0
- package/types/all.d.ts +5 -0
- package/types/any.d.ts +5 -0
- package/types/anyone.d.ts +17 -0
- package/types/none.d.ts +5 -0
- package/types/one.d.ts +5 -0
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -31
- package/.travis.yml +0 -17
- package/all/index.js +0 -1
- package/all/index.min.js +0 -1
- package/any/index.js +0 -1
- package/any/index.min.js +0 -1
- package/dist/index.js +0 -1
- package/dist/index.min.js +0 -1
- package/none/index.js +0 -1
- package/none/index.min.js +0 -1
- package/one/index.js +0 -1
- package/one/index.min.js +0 -1
- package/rollup.config.js +0 -51
- package/src/index.js +0 -3
- package/src/lib/constants/index.js +0 -16
- package/src/lib/run/index.js +0 -21
- package/src/lib/run/spec.js +0 -31
- package/src/methods/all/index.js +0 -10
- package/src/methods/all/spec.js +0 -49
- package/src/methods/any/index.js +0 -10
- package/src/methods/any/spec.js +0 -63
- package/src/methods/index.js +0 -4
- package/src/methods/none/index.js +0 -10
- package/src/methods/none/spec.js +0 -63
- package/src/methods/one/index.js +0 -28
- package/src/methods/one/spec.js +0 -61
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# anyone - Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
## 2.0.0 - 2021-12-13
|
|
8
|
+
### Changed or removed
|
|
9
|
+
- e8652bc breaking(vest, enforce): prepare next major (ealush)
|
|
10
|
+
- dab8e00 breaking(vest, enforce): prepare next major (ealush)
|
|
11
|
+
|
|
12
|
+
### Fixed and improved
|
|
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)
|
|
24
|
+
- .gitignore
|
|
25
|
+
|
|
26
|
+
## 0.1.21 - 2021-07-02
|
|
27
|
+
|
|
28
|
+
### Fixed and improved
|
|
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)
|
|
38
|
+
|
|
39
|
+
## 0.1.20 - 2021-07-02
|
|
40
|
+
|
|
41
|
+
### Fixed and improved
|
|
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)
|
|
51
|
+
|
|
52
|
+
## 0.1.19 - 2021-07-02
|
|
53
|
+
|
|
54
|
+
### Fixed and improved
|
|
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/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2020 ealush
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -14,12 +14,14 @@ They all accept any amount of arguments, or no arguments at all. If a function i
|
|
|
14
14
|
All functions other than `one` will short circuit when realizing the condition is not met.
|
|
15
15
|
|
|
16
16
|
## Why use it
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
In most cases (other than `one`) you can do just fine using `Array.prototype.some` and `Array.prototype.every`, some of these functions are used internally by Vest.
|
|
18
19
|
|
|
19
20
|
- You can use these functions as conditionals:
|
|
21
|
+
|
|
20
22
|
```js
|
|
21
|
-
if (one(
|
|
22
|
-
|
|
23
|
+
if (one(var1, var2, var3)) {
|
|
24
|
+
// will reach here if ONLY ONE of the arguments is true
|
|
23
25
|
}
|
|
24
26
|
```
|
|
25
27
|
|
|
@@ -27,9 +29,9 @@ if (one( var1, var2, var3 )) {
|
|
|
27
29
|
|
|
28
30
|
```js
|
|
29
31
|
all(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
validateInput1, // returns true
|
|
33
|
+
validateInput2, // returns false
|
|
34
|
+
validateInput3 // no need to run this, we already know our validation failed
|
|
33
35
|
);
|
|
34
36
|
```
|
|
35
37
|
|
|
@@ -46,75 +48,73 @@ yarn add anyone
|
|
|
46
48
|
## Usage Examples
|
|
47
49
|
|
|
48
50
|
```js
|
|
49
|
-
import { any, all, none
|
|
51
|
+
import { any, one, all, none } from 'anyone';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import any from 'anyone/any';
|
|
56
|
+
import one from 'anyone/one';
|
|
57
|
+
import none from 'anyone/none';
|
|
58
|
+
import all from 'anyone/all';
|
|
50
59
|
|
|
51
60
|
any(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
someFunction, // evaluates to false
|
|
62
|
+
1,
|
|
63
|
+
someVar // truthy
|
|
55
64
|
);
|
|
56
65
|
// true
|
|
57
66
|
|
|
58
67
|
// --------
|
|
59
68
|
|
|
60
69
|
any(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
someFunction, // evaluates to false
|
|
71
|
+
0,
|
|
72
|
+
someVar // falsy
|
|
64
73
|
);
|
|
65
74
|
// false
|
|
66
75
|
|
|
67
76
|
// --------
|
|
68
77
|
|
|
69
78
|
one(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
someFunction, // evaluates to false
|
|
80
|
+
0,
|
|
81
|
+
someVar // truthy
|
|
73
82
|
);
|
|
74
83
|
// true
|
|
75
84
|
|
|
76
85
|
// --------
|
|
77
86
|
|
|
78
87
|
none(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
someFunction, // evaluates to false
|
|
89
|
+
1,
|
|
90
|
+
someVar // truthy
|
|
82
91
|
);
|
|
83
92
|
// false
|
|
84
93
|
|
|
85
94
|
// --------
|
|
86
95
|
|
|
87
96
|
none(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
someFunction, // evaluates to false
|
|
98
|
+
0,
|
|
99
|
+
someVar // falsy
|
|
91
100
|
);
|
|
92
101
|
// true
|
|
93
102
|
|
|
94
103
|
// --------
|
|
95
104
|
|
|
96
105
|
all(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
someFunction, // evaluates to false
|
|
107
|
+
0,
|
|
108
|
+
someVar // truthy
|
|
100
109
|
);
|
|
101
110
|
// false
|
|
102
111
|
|
|
103
112
|
// --------
|
|
104
113
|
|
|
105
114
|
all(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
someFunction, // evaluates to true
|
|
116
|
+
1,
|
|
117
|
+
someVar // truthy
|
|
109
118
|
);
|
|
110
119
|
// true
|
|
111
120
|
```
|
|
112
|
-
|
|
113
|
-
You can also import any of the functions directly. If you use more than one, you should opt import them together, as they share most of their code.
|
|
114
|
-
|
|
115
|
-
```js
|
|
116
|
-
import any from 'anyone/any';
|
|
117
|
-
import one from 'anyone/one';
|
|
118
|
-
import all from 'anyone/all';
|
|
119
|
-
import none from 'anyone/none';
|
|
120
|
-
```
|
package/all/package.json
ADDED
package/any/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isFunction(value) {
|
|
4
|
+
return typeof value === 'function';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
9
|
+
*/
|
|
10
|
+
function run(arg) {
|
|
11
|
+
if (isFunction(arg)) {
|
|
12
|
+
try {
|
|
13
|
+
return check(arg());
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return check(arg);
|
|
20
|
+
}
|
|
21
|
+
function check(value) {
|
|
22
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
23
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks that at all passed arguments evaluate to a truthy value.
|
|
28
|
+
*/
|
|
29
|
+
function all() {
|
|
30
|
+
var args = [];
|
|
31
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
32
|
+
args[_i] = arguments[_i];
|
|
33
|
+
}
|
|
34
|
+
return args.every(run);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = all;
|
package/dist/cjs/all.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(r){if(function(r){return"function"==typeof r}(r))try{return t(r())}catch(r){return!1}return t(r)}function t(r){return!!Array.isArray(r)||0!=r&&!!r}module.exports=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.every(r)};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isFunction(value) {
|
|
4
|
+
return typeof value === 'function';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
9
|
+
*/
|
|
10
|
+
function run(arg) {
|
|
11
|
+
if (isFunction(arg)) {
|
|
12
|
+
try {
|
|
13
|
+
return check(arg());
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return check(arg);
|
|
20
|
+
}
|
|
21
|
+
function check(value) {
|
|
22
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
23
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks that at least one passed argument evaluates to a truthy value.
|
|
28
|
+
*/
|
|
29
|
+
function any() {
|
|
30
|
+
var args = [];
|
|
31
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
32
|
+
args[_i] = arguments[_i];
|
|
33
|
+
}
|
|
34
|
+
return args.some(run);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = any;
|
package/dist/cjs/any.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(r){if(function(r){return"function"==typeof r}(r))try{return t(r())}catch(r){return!1}return t(r)}function t(r){return!!Array.isArray(r)||0!=r&&!!r}module.exports=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.some(r)};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function isFunction(value) {
|
|
6
|
+
return typeof value === 'function';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
11
|
+
*/
|
|
12
|
+
function run(arg) {
|
|
13
|
+
if (isFunction(arg)) {
|
|
14
|
+
try {
|
|
15
|
+
return check(arg());
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return check(arg);
|
|
22
|
+
}
|
|
23
|
+
function check(value) {
|
|
24
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
25
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Checks that at all passed arguments evaluate to a truthy value.
|
|
30
|
+
*/
|
|
31
|
+
function all() {
|
|
32
|
+
var args = [];
|
|
33
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
34
|
+
args[_i] = arguments[_i];
|
|
35
|
+
}
|
|
36
|
+
return args.every(run);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Checks that at least one passed argument evaluates to a truthy value.
|
|
41
|
+
*/
|
|
42
|
+
function any() {
|
|
43
|
+
var args = [];
|
|
44
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
45
|
+
args[_i] = arguments[_i];
|
|
46
|
+
}
|
|
47
|
+
return args.some(run);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function bindNot(fn) {
|
|
51
|
+
return function () {
|
|
52
|
+
var args = [];
|
|
53
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
54
|
+
args[_i] = arguments[_i];
|
|
55
|
+
}
|
|
56
|
+
return !fn.apply(void 0, args);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Checks that at none of the passed arguments evaluate to a truthy value.
|
|
62
|
+
*/
|
|
63
|
+
function none() {
|
|
64
|
+
var args = [];
|
|
65
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
66
|
+
args[_i] = arguments[_i];
|
|
67
|
+
}
|
|
68
|
+
return args.every(bindNot(run));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Checks that at only one passed argument evaluates to a truthy value.
|
|
73
|
+
*/
|
|
74
|
+
function one() {
|
|
75
|
+
var args = [];
|
|
76
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
77
|
+
args[_i] = arguments[_i];
|
|
78
|
+
}
|
|
79
|
+
var count = 0;
|
|
80
|
+
for (var i = 0; i < args.length; i++) {
|
|
81
|
+
if (run(args[i])) {
|
|
82
|
+
count++;
|
|
83
|
+
}
|
|
84
|
+
if (count > 1) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return count === 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.all = all;
|
|
92
|
+
exports.any = any;
|
|
93
|
+
exports.none = none;
|
|
94
|
+
exports.one = one;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(r){if(function(r){return"function"==typeof r}(r))try{return n(r())}catch(r){return!1}return n(r)}function n(r){return!!Array.isArray(r)||0!=r&&!!r}function t(r){return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return!r.apply(void 0,n)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.all=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.every(r)},exports.any=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.some(r)},exports.none=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.every(t(r))},exports.one=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var e=t=0;e<n.length;e++)if(r(n[e])&&t++,1<t)return!1;return 1===t};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function bindNot(fn) {
|
|
4
|
+
return function () {
|
|
5
|
+
var args = [];
|
|
6
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
+
args[_i] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
return !fn.apply(void 0, args);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isFunction(value) {
|
|
14
|
+
return typeof value === 'function';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
19
|
+
*/
|
|
20
|
+
function run(arg) {
|
|
21
|
+
if (isFunction(arg)) {
|
|
22
|
+
try {
|
|
23
|
+
return check(arg());
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return check(arg);
|
|
30
|
+
}
|
|
31
|
+
function check(value) {
|
|
32
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
33
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Checks that at none of the passed arguments evaluate to a truthy value.
|
|
38
|
+
*/
|
|
39
|
+
function none() {
|
|
40
|
+
var args = [];
|
|
41
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
42
|
+
args[_i] = arguments[_i];
|
|
43
|
+
}
|
|
44
|
+
return args.every(bindNot(run));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = none;
|
package/dist/cjs/none.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(r){return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return!r.apply(void 0,n)}}function n(r){if(function(r){return"function"==typeof r}(r))try{return t(r())}catch(r){return!1}return t(r)}function t(r){return!!Array.isArray(r)||0!=r&&!!r}module.exports=function(){for(var t=[],u=0;u<arguments.length;u++)t[u]=arguments[u];return t.every(r(n))};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isFunction(value) {
|
|
4
|
+
return typeof value === 'function';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
9
|
+
*/
|
|
10
|
+
function run(arg) {
|
|
11
|
+
if (isFunction(arg)) {
|
|
12
|
+
try {
|
|
13
|
+
return check(arg());
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return check(arg);
|
|
20
|
+
}
|
|
21
|
+
function check(value) {
|
|
22
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
23
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks that at only one passed argument evaluates to a truthy value.
|
|
28
|
+
*/
|
|
29
|
+
function one() {
|
|
30
|
+
var args = [];
|
|
31
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
32
|
+
args[_i] = arguments[_i];
|
|
33
|
+
}
|
|
34
|
+
var count = 0;
|
|
35
|
+
for (var i = 0; i < args.length; i++) {
|
|
36
|
+
if (run(args[i])) {
|
|
37
|
+
count++;
|
|
38
|
+
}
|
|
39
|
+
if (count > 1) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return count === 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = one;
|
package/dist/cjs/one.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(r){if(function(r){return"function"==typeof r}(r))try{return t(r())}catch(r){return!1}return t(r)}function t(r){return!!Array.isArray(r)||0!=r&&!!r}module.exports=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var u=n=0;u<t.length;u++)if(r(t[u])&&n++,1<n)return!1;return 1===n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function isFunction(value) {
|
|
2
|
+
return typeof value === 'function';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
7
|
+
*/
|
|
8
|
+
function run(arg) {
|
|
9
|
+
if (isFunction(arg)) {
|
|
10
|
+
try {
|
|
11
|
+
return check(arg());
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return check(arg);
|
|
18
|
+
}
|
|
19
|
+
function check(value) {
|
|
20
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
21
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks that at all passed arguments evaluate to a truthy value.
|
|
26
|
+
*/
|
|
27
|
+
function all() {
|
|
28
|
+
var args = [];
|
|
29
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
30
|
+
args[_i] = arguments[_i];
|
|
31
|
+
}
|
|
32
|
+
return args.every(run);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default all;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r){if("function"==typeof r)try{return t(r())}catch(r){return!1}return t(r)}function t(r){return!!Array.isArray(r)||0!=r&&!!r}export default function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.every(r)}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function isFunction(value) {
|
|
2
|
+
return typeof value === 'function';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
7
|
+
*/
|
|
8
|
+
function run(arg) {
|
|
9
|
+
if (isFunction(arg)) {
|
|
10
|
+
try {
|
|
11
|
+
return check(arg());
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return check(arg);
|
|
18
|
+
}
|
|
19
|
+
function check(value) {
|
|
20
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
21
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks that at least one passed argument evaluates to a truthy value.
|
|
26
|
+
*/
|
|
27
|
+
function any() {
|
|
28
|
+
var args = [];
|
|
29
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
30
|
+
args[_i] = arguments[_i];
|
|
31
|
+
}
|
|
32
|
+
return args.some(run);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r){if("function"==typeof r)try{return t(r())}catch(r){return!1}return t(r)}function t(r){return!!Array.isArray(r)||0!=r&&!!r}export default function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.some(r)}
|