nv-random-empty 1.0.5
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/README.md +144 -0
- package/index.js +102 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
|
|
2
|
+
nv-random-empty
|
|
3
|
+
=======================
|
|
4
|
+
- generate a random \<empty-like\> js-value
|
|
5
|
+
- this is for test your runtime
|
|
6
|
+
|
|
7
|
+
###
|
|
8
|
+
0 |0n | NaN| undefined | null | '' | false |
|
|
9
|
+
Symbol() | Symbol.for() |
|
|
10
|
+
new Number(0) | new String('') | new Boolean(false) |
|
|
11
|
+
[] | {} | Object.create(null) | new Set() | new Map() |
|
|
12
|
+
|
|
13
|
+
new Date(NaN);
|
|
14
|
+
new Regexp("^$");
|
|
15
|
+
|
|
16
|
+
new ArrayBuffer(0) | new DataView(new Array) | Buffer.alloc(0) | Buffer.allocUnsafe(0) | new SharedArrayBuffer(0)
|
|
17
|
+
new Uint8Array(0) | new Int8Array(0) | new Uint8ClampedArray(0) |
|
|
18
|
+
new Uint16Array(0) | new Int16Array(0) |
|
|
19
|
+
new Uint32Array(0) | new Int32Array(0) |
|
|
20
|
+
new BigUint64Array(0) | new BigInt64Array(0) |
|
|
21
|
+
new Float32Array(0) | new Float64Array(0)
|
|
22
|
+
|
|
23
|
+
new WeakSet();
|
|
24
|
+
new WeakMap();
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
install
|
|
28
|
+
=======
|
|
29
|
+
- npm install nv-random-empty
|
|
30
|
+
|
|
31
|
+
splitted
|
|
32
|
+
--------
|
|
33
|
+
|
|
34
|
+
usage
|
|
35
|
+
=====
|
|
36
|
+
|
|
37
|
+
const x = require("nv-random-empty");
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
example
|
|
41
|
+
-------
|
|
42
|
+
|
|
43
|
+
> x()
|
|
44
|
+
BigUint64Array(0) []
|
|
45
|
+
> x()
|
|
46
|
+
''
|
|
47
|
+
> x()
|
|
48
|
+
[Boolean: false]
|
|
49
|
+
> x()
|
|
50
|
+
WeakMap { <items unknown> }
|
|
51
|
+
> x()
|
|
52
|
+
null
|
|
53
|
+
> x()
|
|
54
|
+
Float64Array(0) []
|
|
55
|
+
> x()
|
|
56
|
+
Float32Array(0) []
|
|
57
|
+
> x()
|
|
58
|
+
[String: '']
|
|
59
|
+
> x()
|
|
60
|
+
false
|
|
61
|
+
> x()
|
|
62
|
+
[String: '']
|
|
63
|
+
> x()
|
|
64
|
+
undefined
|
|
65
|
+
> x()
|
|
66
|
+
Int8Array(0) []
|
|
67
|
+
> x()
|
|
68
|
+
[Boolean: false]
|
|
69
|
+
> x()
|
|
70
|
+
BigUint64Array(0) []
|
|
71
|
+
> x()
|
|
72
|
+
0
|
|
73
|
+
> x()
|
|
74
|
+
Int8Array(0) []
|
|
75
|
+
> x()
|
|
76
|
+
WeakSet { <items unknown> }
|
|
77
|
+
> x()
|
|
78
|
+
Uint8ClampedArray(0) []
|
|
79
|
+
> x()
|
|
80
|
+
Symbol()
|
|
81
|
+
> x()
|
|
82
|
+
Symbol()
|
|
83
|
+
> x()
|
|
84
|
+
[]
|
|
85
|
+
> x()
|
|
86
|
+
''
|
|
87
|
+
> x()
|
|
88
|
+
[Object: null prototype] {}
|
|
89
|
+
> x()
|
|
90
|
+
undefined
|
|
91
|
+
> x()
|
|
92
|
+
DataView {
|
|
93
|
+
byteLength: 0,
|
|
94
|
+
byteOffset: 0,
|
|
95
|
+
buffer: ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 }
|
|
96
|
+
}
|
|
97
|
+
> x()
|
|
98
|
+
0
|
|
99
|
+
> x()
|
|
100
|
+
WeakMap { <items unknown> }
|
|
101
|
+
> x()
|
|
102
|
+
null
|
|
103
|
+
> x()
|
|
104
|
+
Float64Array(0) []
|
|
105
|
+
> x()
|
|
106
|
+
<Buffer >
|
|
107
|
+
> x()
|
|
108
|
+
WeakSet { <items unknown> }
|
|
109
|
+
> x()
|
|
110
|
+
DataView {
|
|
111
|
+
byteLength: 0,
|
|
112
|
+
byteOffset: 0,
|
|
113
|
+
buffer: ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 }
|
|
114
|
+
}
|
|
115
|
+
> x()
|
|
116
|
+
undefined
|
|
117
|
+
> x()
|
|
118
|
+
Map(0) {}
|
|
119
|
+
> x()
|
|
120
|
+
undefined
|
|
121
|
+
> x()
|
|
122
|
+
[Number: 0]
|
|
123
|
+
> x()
|
|
124
|
+
Int8Array(0) []
|
|
125
|
+
> x()
|
|
126
|
+
undefined
|
|
127
|
+
> x()
|
|
128
|
+
<Buffer >
|
|
129
|
+
> x()
|
|
130
|
+
WeakMap { <items unknown> }
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
METHODS
|
|
134
|
+
========
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
APIS
|
|
138
|
+
=======
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
LICENSE
|
|
142
|
+
=======
|
|
143
|
+
- ISC
|
|
144
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const {rand_from_ary}=require("nv-random-util");
|
|
2
|
+
let MAX_CNT = 128;
|
|
3
|
+
const count = ()=>parseInt(Math.random()*MAX_CNT);
|
|
4
|
+
|
|
5
|
+
const V = [
|
|
6
|
+
()=>0, ()=>undefined,()=>null,()=>'',()=>false, ()=>0n,
|
|
7
|
+
()=>Symbol(), ()=>Symbol.for(),
|
|
8
|
+
()=>[],()=>{},()=>Object.create(null), ()=>new Set(), ()=>new Map(),
|
|
9
|
+
()=>new Number(0),
|
|
10
|
+
()=>new String(''),
|
|
11
|
+
()=>new Boolean(false),
|
|
12
|
+
()=>new Date(NaN),
|
|
13
|
+
////
|
|
14
|
+
()=> {
|
|
15
|
+
let u8a = new Uint8Array(0);
|
|
16
|
+
return(u8a)
|
|
17
|
+
},
|
|
18
|
+
()=> {
|
|
19
|
+
let buf = new Uint8ClampedArray(0);
|
|
20
|
+
return(buf)
|
|
21
|
+
},
|
|
22
|
+
()=> {
|
|
23
|
+
let buf = new Int8Array(0);
|
|
24
|
+
return(buf)
|
|
25
|
+
},
|
|
26
|
+
()=> {
|
|
27
|
+
let buf = new Uint16Array(0);
|
|
28
|
+
return(buf)
|
|
29
|
+
},
|
|
30
|
+
()=> {
|
|
31
|
+
let buf = new Int16Array(0);
|
|
32
|
+
return(buf)
|
|
33
|
+
},
|
|
34
|
+
()=> {
|
|
35
|
+
let buf = new Uint32Array(0);
|
|
36
|
+
return(buf)
|
|
37
|
+
},
|
|
38
|
+
()=> {
|
|
39
|
+
let buf = new Int32Array(0);
|
|
40
|
+
return(buf)
|
|
41
|
+
},
|
|
42
|
+
()=> {
|
|
43
|
+
let buf = new BigUint64Array(0);
|
|
44
|
+
return(buf)
|
|
45
|
+
},
|
|
46
|
+
()=> {
|
|
47
|
+
let buf = new BigInt64Array(0);
|
|
48
|
+
return(buf)
|
|
49
|
+
},
|
|
50
|
+
()=> {
|
|
51
|
+
let buf = new Float32Array(0);
|
|
52
|
+
return(buf)
|
|
53
|
+
},
|
|
54
|
+
()=> {
|
|
55
|
+
let buf = new Float64Array(0);
|
|
56
|
+
return(buf)
|
|
57
|
+
},
|
|
58
|
+
()=> {
|
|
59
|
+
let u8a = new Uint8Array(0);
|
|
60
|
+
return(u8a.buffer)
|
|
61
|
+
},
|
|
62
|
+
()=> {
|
|
63
|
+
let u8a = new Uint8Array(0);
|
|
64
|
+
return(new DataView(u8a.buffer))
|
|
65
|
+
},
|
|
66
|
+
()=> new WeakSet(),
|
|
67
|
+
()=> new WeakMap()
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if(globalThis.Buffer) {
|
|
72
|
+
V.push(()=>{
|
|
73
|
+
let buf = globalThis.Buffer.allocUnsafe(0);
|
|
74
|
+
return(buf)
|
|
75
|
+
});
|
|
76
|
+
V.push(()=>{
|
|
77
|
+
let buf = globalThis.Buffer.alloc(0);
|
|
78
|
+
return(buf)
|
|
79
|
+
});
|
|
80
|
+
} else {}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if(globalThis.SharedArrayBuffer) {
|
|
84
|
+
V.push(()=>{
|
|
85
|
+
let buf = new globalThis.SharedArrayBuffer(0);
|
|
86
|
+
return(buf)
|
|
87
|
+
});
|
|
88
|
+
} else {}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
module.exports = ()=> rand_from_ary(V)();
|
|
92
|
+
|
|
93
|
+
Object.defineProperty(
|
|
94
|
+
module.exports,
|
|
95
|
+
"MAX_CNT",
|
|
96
|
+
{
|
|
97
|
+
get:()=>MAX_CNT,
|
|
98
|
+
set:(v)=>{MAX_CNT =v}
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nv-random-empty",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"nanoid": "^3.3.7",
|
|
8
|
+
"nv-facutil-basic": "^1.3.20",
|
|
9
|
+
"nv-facutil-notandor": "^1.0.5",
|
|
10
|
+
"nv-number-basic": "^1.0.6",
|
|
11
|
+
"nv-random-number": "^1.0.3",
|
|
12
|
+
"nv-random-util": "^0.0.2"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC"
|
|
20
|
+
}
|