Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Commit d790239

Browse files
committed
feat(packages/test/samples): ✨ Add more samples & allow importing groups
1 parent 64097e3 commit d790239

File tree

18 files changed

+335
-120
lines changed

18 files changed

+335
-120
lines changed

packages/test/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"./*": {
3434
"types": "./dist/*/*.d.ts",
3535
"import": "./dist/*/*.js"
36+
},
37+
"./sample/*": {
38+
"types": "./dist/sample/groups/*.d.ts",
39+
"import": "./dist/sample/groups/*.js"
3640
}
3741
},
3842
"files": [
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const SAMPLE_EMPTY_ARRAY = [] as const;
2+
3+
/* prettier-ignore */
4+
export const SAMPLE_ARRAYS = [
5+
SAMPLE_EMPTY_ARRAY,
6+
[1, 2],
7+
] as const;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const SAMPLE_BIG_INT = BigInt(987);
2+
/* prettier-ignore */
3+
export const FALSY_BIG_INTS = [
4+
0n,
5+
-0n,
6+
BigInt(0),
7+
BigInt(-0),
8+
] as const;
9+
10+
export const TRUTHY_BIG_INTS = [
11+
BigInt(Number.MIN_SAFE_INTEGER),
12+
BigInt(Number.MAX_SAFE_INTEGER),
13+
BigInt(Number.MAX_VALUE),
14+
] as const;
15+
16+
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt} */
17+
export const SAMPLE_BIG_INTS = [...FALSY_BIG_INTS, ...TRUTHY_BIG_INTS] as const;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export const FALSY_BOOLEANS = [
2+
false,
3+
Boolean(false),
4+
Boolean(),
5+
Boolean(0),
6+
Boolean(""),
7+
// eslint-disable-next-line unicorn/no-useless-undefined
8+
Boolean(undefined),
9+
// eslint-disable-next-line unicorn/no-null
10+
Boolean(null),
11+
] as const;
12+
13+
/* prettier-ignore */
14+
export const TRUTHY_BOOLEANS = [
15+
true,
16+
Boolean(true),
17+
Boolean(1),
18+
Boolean("a"),
19+
] as const;
20+
21+
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean} */
22+
export const SAMPLE_BOOLEANS = [...FALSY_BOOLEANS, ...TRUTHY_BOOLEANS] as const;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* prettier-ignore */
2+
export const SAMPLE_DATES = [
3+
new Date(),
4+
new Date("2023-01-01T00:00:00.000Z"),
5+
] as const;
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
export const SAMPLE_ARROW_FUNCTION = () => void 0;
2+
3+
export const SAMPLE_ARROW_ASYNC_FUNCTION = async () => void 0;
4+
5+
export const SAMPLE_SIMPLE_FUNCTION = function () {
6+
return void 0;
7+
};
8+
9+
export const SAMPLE_SIMPLE_ASYNC_FUNCTION = async function () {
10+
return void 0;
11+
};
12+
13+
export const SAMPLE_SIMPLE_ASYNC_GENERATOR_FUNCTION = async function* () {
14+
yield void 0;
15+
return void 0;
16+
};
17+
18+
export const SAMPLE_SIMPLE_GENERATOR_FUNCTION = function* () {
19+
yield void 0;
20+
return void 0;
21+
};
22+
23+
export const SAMPLE_ASYNC_FUNCTIONS = [
24+
SAMPLE_ARROW_ASYNC_FUNCTION,
25+
SAMPLE_SIMPLE_ASYNC_FUNCTION,
26+
SAMPLE_SIMPLE_ASYNC_GENERATOR_FUNCTION,
27+
] as const;
28+
29+
export const SAMPLE_SYNC_FUNCTIONS = [
30+
SAMPLE_ARROW_FUNCTION,
31+
SAMPLE_SIMPLE_FUNCTION,
32+
SAMPLE_SIMPLE_GENERATOR_FUNCTION,
33+
] as const;
34+
35+
export const SAMPLE_GENERATOR_FUNCTIONS = [
36+
SAMPLE_SIMPLE_ASYNC_GENERATOR_FUNCTION,
37+
SAMPLE_SIMPLE_GENERATOR_FUNCTION,
38+
] as const;
39+
40+
export const SAMPLE_NON_GENERATOR_FUNCTIONS = [
41+
SAMPLE_ARROW_FUNCTION,
42+
SAMPLE_ARROW_ASYNC_FUNCTION,
43+
SAMPLE_SIMPLE_FUNCTION,
44+
SAMPLE_SIMPLE_ASYNC_FUNCTION,
45+
] as const;
46+
47+
export const SAMPLE_BUILT_IN_METHODS = [
48+
Date.now,
49+
Intl.NumberFormat.supportedLocalesOf,
50+
Math.min,
51+
Math.max,
52+
Number.isNaN,
53+
String.prototype.match,
54+
] as const;
55+
56+
export const SAMPLE_OBJECT_WITH_METHODS = {
57+
arrow: SAMPLE_ARROW_FUNCTION,
58+
arrowAsync: SAMPLE_ARROW_ASYNC_FUNCTION,
59+
simple: SAMPLE_SIMPLE_FUNCTION,
60+
simpleAsync: SAMPLE_SIMPLE_ASYNC_FUNCTION,
61+
simpleAsyncGenerator: SAMPLE_SIMPLE_ASYNC_GENERATOR_FUNCTION,
62+
simpleGenerator: SAMPLE_SIMPLE_GENERATOR_FUNCTION,
63+
} as const;
64+
65+
class SampleClass {
66+
static staticArrow = SAMPLE_ARROW_FUNCTION;
67+
static staticSimple = SAMPLE_SIMPLE_FUNCTION;
68+
69+
/* prettier-ignore */
70+
constructor() { void 0; }
71+
72+
public arrow = SAMPLE_ARROW_FUNCTION;
73+
public simple = SAMPLE_SIMPLE_FUNCTION;
74+
/* prettier-ignore */
75+
public method() { return void 0; }
76+
}
77+
78+
const sampleClass = new SampleClass();
79+
80+
export const SAMPLE_CLASS_METHODS = [
81+
SampleClass.staticArrow,
82+
SampleClass.staticSimple,
83+
sampleClass.arrow,
84+
sampleClass.simple,
85+
sampleClass.method,
86+
] as const;
87+
88+
export const SAMPLE_OBJECT_METHODS = [
89+
SAMPLE_OBJECT_WITH_METHODS.arrow,
90+
SAMPLE_OBJECT_WITH_METHODS.arrowAsync,
91+
SAMPLE_OBJECT_WITH_METHODS.simple,
92+
SAMPLE_OBJECT_WITH_METHODS.simpleAsync,
93+
SAMPLE_OBJECT_WITH_METHODS.simpleAsyncGenerator,
94+
SAMPLE_OBJECT_WITH_METHODS.simpleGenerator,
95+
] as const;
96+
97+
export const SAMPLE_ARROW_FUNCTIONS = [
98+
SampleClass.staticArrow,
99+
SAMPLE_OBJECT_WITH_METHODS.arrow,
100+
SAMPLE_OBJECT_WITH_METHODS.arrowAsync,
101+
sampleClass.arrow,
102+
SAMPLE_ARROW_FUNCTION,
103+
() => SAMPLE_SIMPLE_FUNCTION,
104+
SAMPLE_ARROW_ASYNC_FUNCTION,
105+
async () => SAMPLE_SIMPLE_FUNCTION,
106+
] as const;
107+
108+
/* prettier-ignore */
109+
export const SAMPLE_SIMPLE_FUNCTIONS = [
110+
SAMPLE_SIMPLE_FUNCTION,
111+
function simple() { return SAMPLE_ARROW_FUNCTION; },
112+
SAMPLE_SIMPLE_ASYNC_FUNCTION,
113+
async function simple() { return SAMPLE_ARROW_FUNCTION; },
114+
SAMPLE_SIMPLE_ASYNC_GENERATOR_FUNCTION,
115+
async function* simple() { yield void 0; return SAMPLE_ARROW_FUNCTION; },
116+
SAMPLE_SIMPLE_GENERATOR_FUNCTION,
117+
function* simple() { yield void 0; return SAMPLE_ARROW_FUNCTION; },
118+
SampleClass.staticSimple,
119+
sampleClass.simple,
120+
SAMPLE_OBJECT_WITH_METHODS.simple,
121+
SAMPLE_OBJECT_WITH_METHODS.simpleAsync,
122+
SAMPLE_OBJECT_WITH_METHODS.simpleAsyncGenerator,
123+
SAMPLE_OBJECT_WITH_METHODS.simpleGenerator,
124+
sampleClass.method,
125+
...SAMPLE_BUILT_IN_METHODS,
126+
] as const;
127+
128+
export const SAMPLE_FUNCTIONS = [...SAMPLE_ARROW_FUNCTIONS, ...SAMPLE_SIMPLE_FUNCTIONS] as const;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const SAMPLE_INFINITIES = [
2+
// eslint-disable-next-line unicorn/prefer-number-properties
3+
-Infinity,
4+
Number.NEGATIVE_INFINITY,
5+
// eslint-disable-next-line unicorn/prefer-number-properties
6+
Infinity,
7+
Number.POSITIVE_INFINITY,
8+
] as const;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const SAMPLE_EMPTY_MAP = new Map();
2+
3+
export const SAMPLE_MAPS = [
4+
new Map(),
5+
new Map([
6+
[1, "one"],
7+
[2, "two"],
8+
[3, "three"],
9+
]),
10+
] as const;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN} NaN - Not-A-Number */
2+
export const SAMPLE_NANS = [
3+
// eslint-disable-next-line unicorn/prefer-number-properties
4+
NaN,
5+
Number.NaN,
6+
// eslint-disable-next-line unicorn/prefer-number-properties
7+
Number(NaN),
8+
Number(Number.NaN),
9+
] as const;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* prettier-ignore */
2+
/** @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Null} Null */
3+
export const SAMPLE_NULLS = [
4+
// eslint-disable-next-line unicorn/no-null
5+
null,
6+
] as const;

0 commit comments

Comments
 (0)