anyone 0.0.6 → 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 +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 -27
- 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/.babelrc +0 -3
- 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 -2
- 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 -44
- 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
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
/**
|
|
36
|
+
* Checks that at least one passed argument evaluates to a truthy value.
|
|
37
|
+
*/
|
|
38
|
+
function any() {
|
|
39
|
+
var args = [];
|
|
40
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
41
|
+
args[_i] = arguments[_i];
|
|
42
|
+
}
|
|
43
|
+
return args.some(run);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function bindNot(fn) {
|
|
47
|
+
return function () {
|
|
48
|
+
var args = [];
|
|
49
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
50
|
+
args[_i] = arguments[_i];
|
|
51
|
+
}
|
|
52
|
+
return !fn.apply(void 0, args);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Checks that at none of the passed arguments evaluate to a truthy value.
|
|
58
|
+
*/
|
|
59
|
+
function none() {
|
|
60
|
+
var args = [];
|
|
61
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
62
|
+
args[_i] = arguments[_i];
|
|
63
|
+
}
|
|
64
|
+
return args.every(bindNot(run));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Checks that at only one passed argument evaluates to a truthy value.
|
|
69
|
+
*/
|
|
70
|
+
function one() {
|
|
71
|
+
var args = [];
|
|
72
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
73
|
+
args[_i] = arguments[_i];
|
|
74
|
+
}
|
|
75
|
+
var count = 0;
|
|
76
|
+
for (var i = 0; i < args.length; i++) {
|
|
77
|
+
if (run(args[i])) {
|
|
78
|
+
count++;
|
|
79
|
+
}
|
|
80
|
+
if (count > 1) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return count === 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { all, any, none, one };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r){if("function"==typeof 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)}}function e(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.every(r)}function u(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.some(r)}function o(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.every(t(r))}function f(){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}export{e as all,u as any,o as none,f as one};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function bindNot(fn) {
|
|
2
|
+
return function () {
|
|
3
|
+
var args = [];
|
|
4
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5
|
+
args[_i] = arguments[_i];
|
|
6
|
+
}
|
|
7
|
+
return !fn.apply(void 0, args);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isFunction(value) {
|
|
12
|
+
return typeof value === 'function';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
17
|
+
*/
|
|
18
|
+
function run(arg) {
|
|
19
|
+
if (isFunction(arg)) {
|
|
20
|
+
try {
|
|
21
|
+
return check(arg());
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return check(arg);
|
|
28
|
+
}
|
|
29
|
+
function check(value) {
|
|
30
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
31
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Checks that at none of the passed arguments evaluate to a truthy value.
|
|
36
|
+
*/
|
|
37
|
+
function none() {
|
|
38
|
+
var args = [];
|
|
39
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
40
|
+
args[_i] = arguments[_i];
|
|
41
|
+
}
|
|
42
|
+
return args.every(bindNot(run));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default none;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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"==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=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.every(r(n))}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 only one passed argument evaluates to a truthy value.
|
|
26
|
+
*/
|
|
27
|
+
function one() {
|
|
28
|
+
var args = [];
|
|
29
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
30
|
+
args[_i] = arguments[_i];
|
|
31
|
+
}
|
|
32
|
+
var count = 0;
|
|
33
|
+
for (var i = 0; i < args.length; i++) {
|
|
34
|
+
if (run(args[i])) {
|
|
35
|
+
count++;
|
|
36
|
+
}
|
|
37
|
+
if (count > 1) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return count === 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default one;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r){return!!Array.isArray(r)||0!=r&&!!r}export default function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var a=n=0;a<t.length;a++){r:{var e=t[a];if("function"==typeof e)try{var f=r(e());break r}catch(r){f=!1;break r}f=r(e)}if(f&&n++,1<n)return!1}return 1===n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.all = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function isFunction(value) {
|
|
8
|
+
return typeof value === 'function';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
13
|
+
*/
|
|
14
|
+
function run(arg) {
|
|
15
|
+
if (isFunction(arg)) {
|
|
16
|
+
try {
|
|
17
|
+
return check(arg());
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return check(arg);
|
|
24
|
+
}
|
|
25
|
+
function check(value) {
|
|
26
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
27
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks that at all passed arguments evaluate to a truthy value.
|
|
32
|
+
*/
|
|
33
|
+
function all() {
|
|
34
|
+
var args = [];
|
|
35
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
+
args[_i] = arguments[_i];
|
|
37
|
+
}
|
|
38
|
+
return args.every(run);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return all;
|
|
42
|
+
|
|
43
|
+
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).all=n()}(this,(function(){function e(e){if("function"==typeof e)try{return n(e())}catch(e){return!1}return n(e)}function n(e){return!!Array.isArray(e)||0!=e&&!!e}return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.every(e)}}));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.any = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function isFunction(value) {
|
|
8
|
+
return typeof value === 'function';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
13
|
+
*/
|
|
14
|
+
function run(arg) {
|
|
15
|
+
if (isFunction(arg)) {
|
|
16
|
+
try {
|
|
17
|
+
return check(arg());
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return check(arg);
|
|
24
|
+
}
|
|
25
|
+
function check(value) {
|
|
26
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
27
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks that at least one passed argument evaluates to a truthy value.
|
|
32
|
+
*/
|
|
33
|
+
function any() {
|
|
34
|
+
var args = [];
|
|
35
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
+
args[_i] = arguments[_i];
|
|
37
|
+
}
|
|
38
|
+
return args.some(run);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return any;
|
|
42
|
+
|
|
43
|
+
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).any=n()}(this,(function(){function e(e){if("function"==typeof e)try{return n(e())}catch(e){return!1}return n(e)}function n(e){return!!Array.isArray(e)||0!=e&&!!e}return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.some(e)}}));
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.anyone = {}));
|
|
5
|
+
}(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function isFunction(value) {
|
|
8
|
+
return typeof value === 'function';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
13
|
+
*/
|
|
14
|
+
function run(arg) {
|
|
15
|
+
if (isFunction(arg)) {
|
|
16
|
+
try {
|
|
17
|
+
return check(arg());
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return check(arg);
|
|
24
|
+
}
|
|
25
|
+
function check(value) {
|
|
26
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
27
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks that at all passed arguments evaluate to a truthy value.
|
|
32
|
+
*/
|
|
33
|
+
function all() {
|
|
34
|
+
var args = [];
|
|
35
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
+
args[_i] = arguments[_i];
|
|
37
|
+
}
|
|
38
|
+
return args.every(run);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checks that at least one passed argument evaluates to a truthy value.
|
|
43
|
+
*/
|
|
44
|
+
function any() {
|
|
45
|
+
var args = [];
|
|
46
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
47
|
+
args[_i] = arguments[_i];
|
|
48
|
+
}
|
|
49
|
+
return args.some(run);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function bindNot(fn) {
|
|
53
|
+
return function () {
|
|
54
|
+
var args = [];
|
|
55
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
56
|
+
args[_i] = arguments[_i];
|
|
57
|
+
}
|
|
58
|
+
return !fn.apply(void 0, args);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Checks that at none of the passed arguments evaluate to a truthy value.
|
|
64
|
+
*/
|
|
65
|
+
function none() {
|
|
66
|
+
var args = [];
|
|
67
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
68
|
+
args[_i] = arguments[_i];
|
|
69
|
+
}
|
|
70
|
+
return args.every(bindNot(run));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Checks that at only one passed argument evaluates to a truthy value.
|
|
75
|
+
*/
|
|
76
|
+
function one() {
|
|
77
|
+
var args = [];
|
|
78
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
79
|
+
args[_i] = arguments[_i];
|
|
80
|
+
}
|
|
81
|
+
var count = 0;
|
|
82
|
+
for (var i = 0; i < args.length; i++) {
|
|
83
|
+
if (run(args[i])) {
|
|
84
|
+
count++;
|
|
85
|
+
}
|
|
86
|
+
if (count > 1) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return count === 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.all = all;
|
|
94
|
+
exports.any = any;
|
|
95
|
+
exports.none = none;
|
|
96
|
+
exports.one = one;
|
|
97
|
+
|
|
98
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
99
|
+
|
|
100
|
+
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).anyone={})}(this,(function(n){function e(n){if("function"==typeof n)try{return r(n())}catch(n){return!1}return r(n)}function r(n){return!!Array.isArray(n)||0!=n&&!!n}function t(n){return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return!n.apply(void 0,e)}}n.all=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.every(e)},n.any=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.some(e)},n.none=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.every(t(e))},n.one=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];for(var t=r=0;t<n.length;t++)if(e(n[t])&&r++,1<r)return!1;return 1===r},Object.defineProperty(n,"__esModule",{value:!0})}));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.none = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function bindNot(fn) {
|
|
8
|
+
return function () {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
return !fn.apply(void 0, args);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isFunction(value) {
|
|
18
|
+
return typeof value === 'function';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
23
|
+
*/
|
|
24
|
+
function run(arg) {
|
|
25
|
+
if (isFunction(arg)) {
|
|
26
|
+
try {
|
|
27
|
+
return check(arg());
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return check(arg);
|
|
34
|
+
}
|
|
35
|
+
function check(value) {
|
|
36
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
37
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks that at none of the passed arguments evaluate to a truthy value.
|
|
42
|
+
*/
|
|
43
|
+
function none() {
|
|
44
|
+
var args = [];
|
|
45
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
46
|
+
args[_i] = arguments[_i];
|
|
47
|
+
}
|
|
48
|
+
return args.every(bindNot(run));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return none;
|
|
52
|
+
|
|
53
|
+
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).none=e()}(this,(function(){function n(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return!n.apply(void 0,e)}}function e(n){if("function"==typeof n)try{return t(n())}catch(n){return!1}return t(n)}function t(n){return!!Array.isArray(n)||0!=n&&!!n}return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.every(n(e))}}));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.one = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function isFunction(value) {
|
|
8
|
+
return typeof value === 'function';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Accepts a value or a function, and coerces it into a boolean value
|
|
13
|
+
*/
|
|
14
|
+
function run(arg) {
|
|
15
|
+
if (isFunction(arg)) {
|
|
16
|
+
try {
|
|
17
|
+
return check(arg());
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return check(arg);
|
|
24
|
+
}
|
|
25
|
+
function check(value) {
|
|
26
|
+
// We use abstract equality intentionally here. This enables falsy valueOf support.
|
|
27
|
+
return Array.isArray(value) ? true : value != false && Boolean(value); // eslint-disable-line
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks that at only one passed argument evaluates to a truthy value.
|
|
32
|
+
*/
|
|
33
|
+
function one() {
|
|
34
|
+
var args = [];
|
|
35
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
+
args[_i] = arguments[_i];
|
|
37
|
+
}
|
|
38
|
+
var count = 0;
|
|
39
|
+
for (var i = 0; i < args.length; i++) {
|
|
40
|
+
if (run(args[i])) {
|
|
41
|
+
count++;
|
|
42
|
+
}
|
|
43
|
+
if (count > 1) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return count === 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return one;
|
|
51
|
+
|
|
52
|
+
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).one=n()}(this,(function(){function e(e){return!!Array.isArray(e)||0!=e&&!!e}return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var r=t=0;r<n.length;r++){e:{var f=n[r];if("function"==typeof f)try{var o=e(f());break e}catch(e){o=!1;break e}o=e(f)}if(o&&t++,1<t)return!1}return 1===t}}));
|