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
package/src/methods/none/spec.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { sample, random } from 'lodash';
|
|
2
|
-
import { TRUTHY_VALUES, FALSY_VALUES } from '../../lib/constants';
|
|
3
|
-
import any from '.';
|
|
4
|
-
|
|
5
|
-
describe('methods/none', () => {
|
|
6
|
-
|
|
7
|
-
describe('When only falsy values', () => {
|
|
8
|
-
it('Should return true', () => {
|
|
9
|
-
expect(
|
|
10
|
-
any.apply(null,
|
|
11
|
-
Array.from(
|
|
12
|
-
{ length: random(1, 10) },
|
|
13
|
-
(_, i) => i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
|
|
14
|
-
)
|
|
15
|
-
)
|
|
16
|
-
).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('When only truthy values', () => {
|
|
21
|
-
it('Should return false', () => {
|
|
22
|
-
expect(
|
|
23
|
-
any.apply(null,
|
|
24
|
-
Array.from(
|
|
25
|
-
{ length: random(1, 10) },
|
|
26
|
-
(_, i) => 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
|
-
any.apply(null,
|
|
37
|
-
[...Array.from(
|
|
38
|
-
{ length: random(1, 10) },
|
|
39
|
-
(_, i) => i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
|
|
40
|
-
),
|
|
41
|
-
sample(TRUTHY_VALUES)]
|
|
42
|
-
)
|
|
43
|
-
).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('When some truthy values', () => {
|
|
48
|
-
it('Should return false', () => {
|
|
49
|
-
expect(
|
|
50
|
-
any.apply(null,
|
|
51
|
-
[...Array.from(
|
|
52
|
-
{ length: random(1, 10) },
|
|
53
|
-
(_, i) => i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
|
|
54
|
-
),
|
|
55
|
-
...Array.from(
|
|
56
|
-
{ length: random(1, 10) },
|
|
57
|
-
(_, i) => i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES)
|
|
58
|
-
)]
|
|
59
|
-
)
|
|
60
|
-
).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
package/src/methods/one/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import run from '../../lib/run';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Checks that at only one passed argument evaluates to a truthy value.
|
|
5
|
-
* @param {[]*} [args] Any amount of values or expressions.
|
|
6
|
-
* @returns {Boolean}
|
|
7
|
-
*/
|
|
8
|
-
const one = (...args) => {
|
|
9
|
-
let count = 0;
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < args.length; i++) {
|
|
12
|
-
if (run(args[i])) {
|
|
13
|
-
count++;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (count > 1) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (count !== 1) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return true;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default one;
|
package/src/methods/one/spec.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { sample, random } from 'lodash';
|
|
2
|
-
import { TRUTHY_VALUES, FALSY_VALUES } from '../../lib/constants';
|
|
3
|
-
import any from '.';
|
|
4
|
-
|
|
5
|
-
describe('methods/one', () => {
|
|
6
|
-
|
|
7
|
-
describe('When only falsy values', () => {
|
|
8
|
-
it('Should return false', () => {
|
|
9
|
-
expect(
|
|
10
|
-
any.apply(null,
|
|
11
|
-
Array.from(
|
|
12
|
-
{ length: random(1, 10) },
|
|
13
|
-
(_, i) => 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 false', () => {
|
|
22
|
-
expect(
|
|
23
|
-
any.apply(null,
|
|
24
|
-
Array.from(
|
|
25
|
-
{ length: random(2, 10) },
|
|
26
|
-
(_, i) => 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
|
-
any.apply(null,
|
|
37
|
-
[...Array.from(
|
|
38
|
-
{ length: random(1, 10) },
|
|
39
|
-
(_, i) => i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES)
|
|
40
|
-
),
|
|
41
|
-
sample(TRUTHY_VALUES)]
|
|
42
|
-
)
|
|
43
|
-
).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe.only('When some truthy values', () => {
|
|
48
|
-
it('Should return false', () => {
|
|
49
|
-
expect(
|
|
50
|
-
any.apply(null, [...Array.from(
|
|
51
|
-
{ length: random(2, 10) },
|
|
52
|
-
() => sample(TRUTHY_VALUES)
|
|
53
|
-
),
|
|
54
|
-
...Array.from(
|
|
55
|
-
{ length: random(1, 10) },
|
|
56
|
-
() => sample(FALSY_VALUES)
|
|
57
|
-
)])
|
|
58
|
-
).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|