@stdlib/random-streams-improved-ziggurat 0.0.7 → 0.2.0

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/docs/repl.txt DELETED
@@ -1,239 +0,0 @@
1
-
2
- {{alias}}( [options] )
3
- Returns a readable stream for generating pseudorandom numbers drawn from a
4
- standard normal distribution using the Improved Ziggurat algorithm.
5
-
6
- In addition to standard readable stream events, the returned stream emits a
7
- 'state' event after internally generating `siter` pseudorandom numbers,
8
- which is useful when wanting to deterministically capture a stream's
9
- underlying PRNG state.
10
-
11
- Parameters
12
- ----------
13
- options: Object (optional)
14
- Options.
15
-
16
- options.objectMode: boolean (optional)
17
- Specifies whether a stream should operate in "objectMode". Default:
18
- false.
19
-
20
- options.encoding: string|null (optional)
21
- Specifies how Buffer objects should be decoded to strings. Default:
22
- null.
23
-
24
- options.highWaterMark: integer (optional)
25
- Specifies the maximum number of bytes to store in an internal buffer
26
- before ceasing to generate additional pseudorandom numbers.
27
-
28
- options.sep: string (optional)
29
- Separator used to join streamed data. This option is only applicable
30
- when a stream is not in "objectMode". Default: '\n'.
31
-
32
- options.iter: integer (optional)
33
- Number of iterations.
34
-
35
- options.prng: Function (optional)
36
- Pseudorandom number generator (PRNG) for generating uniformly
37
- distributed pseudorandom numbers on the interval `[0,1)`. If provided,
38
- the `state` and `seed` options are ignored. In order to seed the
39
- returned iterator, one must seed the provided `prng` (assuming the
40
- provided `prng` is seedable).
41
-
42
- options.seed: integer|ArrayLikeObject<integer> (optional)
43
- Pseudorandom number generator seed. The seed may be either a positive
44
- unsigned 32-bit integer or, for arbitrary length seeds, an array-like
45
- object containing unsigned 32-bit integers.
46
-
47
- options.state: Uint32Array (optional)
48
- Pseudorandom number generator state. If provided, the `seed` option is
49
- ignored.
50
-
51
- options.copy: boolean (optional)
52
- Boolean indicating whether to copy a provided pseudorandom number
53
- generator state. Setting this option to `false` allows sharing state
54
- between two or more pseudorandom number generators. Setting this option
55
- to `true` ensures that a returned iterator has exclusive control over
56
- its internal state. Default: true.
57
-
58
- options.siter: integer (optional)
59
- Number of iterations after which to emit the PRNG state. Default: 1e308.
60
-
61
- Returns
62
- -------
63
- stream: ReadableStream
64
- Readable stream.
65
-
66
- stream.PRNG: Function
67
- Underlying pseudorandom number generator.
68
-
69
- stream.seed: Uint32Array|null
70
- Pseudorandom number generator seed.
71
-
72
- stream.seedLength: integer|null
73
- Length of generator seed.
74
-
75
- stream.state: Uint32Array|null
76
- Generator state.
77
-
78
- stream.stateLength: integer|null
79
- Length of generator state.
80
-
81
- stream.byteLength: integer|null
82
- Size (in bytes) of generator state.
83
-
84
- Examples
85
- --------
86
- > function fcn( chunk ) { console.log( chunk.toString() ); };
87
- > var opts = { 'iter': 10 };
88
- > var s = {{alias}}( opts );
89
- > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn );
90
- > s.pipe( o );
91
-
92
-
93
- {{alias}}.factory( [options] )
94
- Returns a function for creating readable streams which generate pseudorandom
95
- numbers drawn from a standard normal distribution using the Improved
96
- Ziggurat algorithm.
97
-
98
- Parameters
99
- ----------
100
- options: Object (optional)
101
- Options.
102
-
103
- options.objectMode: boolean (optional)
104
- Specifies whether a stream should operate in "objectMode". Default:
105
- false.
106
-
107
- options.encoding: string|null (optional)
108
- Specifies how Buffer objects should be decoded to strings. Default:
109
- null.
110
-
111
- options.highWaterMark: integer (optional)
112
- Specifies the maximum number of bytes to store in an internal buffer
113
- before ceasing to generate additional pseudorandom numbers.
114
-
115
- options.sep: string (optional)
116
- Separator used to join streamed data. This option is only applicable
117
- when a stream is not in "objectMode". Default: '\n'.
118
-
119
- options.iter: integer (optional)
120
- Number of iterations.
121
-
122
- options.prng: Function (optional)
123
- Pseudorandom number generator (PRNG) for generating uniformly
124
- distributed pseudorandom numbers on the interval `[0,1)`. If provided,
125
- the `state` and `seed` options are ignored. In order to seed the
126
- returned iterator, one must seed the provided `prng` (assuming the
127
- provided `prng` is seedable).
128
-
129
- options.seed: integer|ArrayLikeObject<integer> (optional)
130
- Pseudorandom number generator seed. The seed may be either a positive
131
- unsigned 32-bit integer or, for arbitrary length seeds, an array-like
132
- object containing unsigned 32-bit integers.
133
-
134
- options.state: Uint32Array (optional)
135
- Pseudorandom number generator state. If provided, the `seed` option is
136
- ignored.
137
-
138
- options.copy: boolean (optional)
139
- Boolean indicating whether to copy a provided pseudorandom number
140
- generator state. Setting this option to `false` allows sharing state
141
- between two or more pseudorandom number generators. Setting this option
142
- to `true` ensures that a returned iterator has exclusive control over
143
- its internal state. Default: true.
144
-
145
- options.siter: integer (optional)
146
- Number of iterations after which to emit the PRNG state. Default: 1e308.
147
-
148
- Returns
149
- -------
150
- fcn: Function
151
- Function for creating readable streams.
152
-
153
- Examples
154
- --------
155
- > var opts = { 'objectMode': true, 'highWaterMark': 64 };
156
- > var createStream = {{alias}}.factory( opts );
157
-
158
-
159
- {{alias}}.objectMode( [options] )
160
- Returns an "objectMode" readable stream for generating pseudorandom numbers
161
- drawn from a standard normal distribution using the Improved Ziggurat
162
- algorithm.
163
-
164
- Parameters
165
- ----------
166
- options: Object (optional)
167
- Options.
168
-
169
- options.encoding: string|null (optional)
170
- Specifies how Buffer objects should be decoded to strings. Default:
171
- null.
172
-
173
- options.highWaterMark: integer (optional)
174
- Specifies the maximum number of objects to store in an internal buffer
175
- before ceasing to generate additional pseudorandom numbers.
176
-
177
- options.iter: integer (optional)
178
- Number of iterations.
179
-
180
- options.prng: Function (optional)
181
- Pseudorandom number generator (PRNG) for generating uniformly
182
- distributed pseudorandom numbers on the interval `[0,1)`. If provided,
183
- the `state` and `seed` options are ignored. In order to seed the
184
- returned iterator, one must seed the provided `prng` (assuming the
185
- provided `prng` is seedable).
186
-
187
- options.seed: integer|ArrayLikeObject<integer> (optional)
188
- Pseudorandom number generator seed. The seed may be either a positive
189
- unsigned 32-bit integer or, for arbitrary length seeds, an array-like
190
- object containing unsigned 32-bit integers.
191
-
192
- options.state: Uint32Array (optional)
193
- Pseudorandom number generator state. If provided, the `seed` option is
194
- ignored.
195
-
196
- options.copy: boolean (optional)
197
- Boolean indicating whether to copy a provided pseudorandom number
198
- generator state. Setting this option to `false` allows sharing state
199
- between two or more pseudorandom number generators. Setting this option
200
- to `true` ensures that a returned iterator has exclusive control over
201
- its internal state. Default: true.
202
-
203
- options.siter: integer (optional)
204
- Number of iterations after which to emit the PRNG state. Default: 1e308.
205
-
206
- Returns
207
- -------
208
- stream: ReadableStream
209
- Readable stream operating in "objectMode".
210
-
211
- stream.PRNG: Function
212
- Underlying pseudorandom number generator.
213
-
214
- stream.seed: Uint32Array|null
215
- Pseudorandom number generator seed.
216
-
217
- stream.seedLength: integer|null
218
- Length of generator seed.
219
-
220
- stream.state: Uint32Array|null
221
- Generator state.
222
-
223
- stream.stateLength: integer|null
224
- Length of generator state.
225
-
226
- stream.byteLength: integer|null
227
- Size (in bytes) of generator state.
228
-
229
- Examples
230
- --------
231
- > function fcn( v ) { console.log( v ); };
232
- > var opts = { 'iter': 10 };
233
- > var s = {{alias}}.objectMode( opts );
234
- > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn );
235
- > s.pipe( o );
236
-
237
- See Also
238
- --------
239
-
@@ -1,103 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2021 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- // tslint:disable: no-unused-expression
20
-
21
- import RandomStream = require( './index' );
22
-
23
-
24
- // TESTS //
25
-
26
- // The constructor returns a stream...
27
- {
28
- new RandomStream(); // $ExpectType RandomStream
29
- new RandomStream( { 'iter': 10 } ); // $ExpectType RandomStream
30
- }
31
-
32
- // The constructor is callable...
33
- {
34
- const randomStream = RandomStream;
35
- randomStream(); // $ExpectType RandomStream
36
- randomStream( { 'iter': 10 } ); // $ExpectType RandomStream
37
- }
38
-
39
- // The constructor has an `objectMode` method which returns a stream...
40
- {
41
- RandomStream.objectMode(); // $ExpectType RandomStream
42
- RandomStream.objectMode( { 'iter': 10 } ); // $ExpectType RandomStream
43
- }
44
-
45
- // The constructor has a `factory` method which returns a function for creating streams...
46
- {
47
- let f = RandomStream.factory();
48
- f(); // $ExpectType RandomStream
49
- f(); // $ExpectType RandomStream
50
- f(); // $ExpectType RandomStream
51
-
52
- f = RandomStream.factory( {} );
53
- f(); // $ExpectType RandomStream
54
- f(); // $ExpectType RandomStream
55
- f(); // $ExpectType RandomStream
56
-
57
- f = RandomStream.factory( { 'iter': 10 } );
58
- f(); // $ExpectType RandomStream
59
- f(); // $ExpectType RandomStream
60
- f(); // $ExpectType RandomStream
61
- }
62
-
63
- // The compiler throws an error if the constructor is provided an argument which is not an options object...
64
- {
65
- new RandomStream( 'abc' ); // $ExpectError
66
- new RandomStream( 123 ); // $ExpectError
67
- new RandomStream( true ); // $ExpectError
68
- new RandomStream( false ); // $ExpectError
69
- new RandomStream( [] ); // $ExpectError
70
- new RandomStream( null ); // $ExpectError
71
- }
72
-
73
- // The compiler throws an error if the `objectMode` method is provided an argument which is not an options object...
74
- {
75
- RandomStream.objectMode( 'abc' ); // $ExpectError
76
- RandomStream.objectMode( 123 ); // $ExpectError
77
- RandomStream.objectMode( true ); // $ExpectError
78
- RandomStream.objectMode( false ); // $ExpectError
79
- RandomStream.objectMode( [] ); // $ExpectError
80
- RandomStream.objectMode( null ); // $ExpectError
81
- }
82
-
83
- // The compiler throws an error if the `factory` method is provided an argument which is not an options object...
84
- {
85
- RandomStream.factory( 'abc' ); // $ExpectError
86
- RandomStream.factory( 123 ); // $ExpectError
87
- RandomStream.factory( true ); // $ExpectError
88
- RandomStream.factory( false ); // $ExpectError
89
- RandomStream.factory( [] ); // $ExpectError
90
- RandomStream.factory( null ); // $ExpectError
91
- }
92
-
93
- // The compiler throws an error if the function returned by the `factory` method is provided input arguments...
94
- {
95
- let f = RandomStream.factory();
96
- f( 2.0 ); // $ExpectError
97
-
98
- f = RandomStream.factory( {} );
99
- f( 2.0 ); // $ExpectError
100
-
101
- f = RandomStream.factory( { 'iter': 10 } );
102
- f( 2.0 ); // $ExpectError
103
- }
package/docs/usage.txt DELETED
@@ -1,15 +0,0 @@
1
-
2
- Usage: random-improved-ziggurat [options]
3
-
4
- Options:
5
-
6
- -h, --help Print this message.
7
- -V, --version Print the package version.
8
- --sep sep Separator used to join streamed data. Default: '\n'.
9
- -n, --iter iterations Number of pseudorandom numbers.
10
- --seed seed Pseudorandom number generator seed.
11
- --state filepath Path to a file containing the pseudorandom number
12
- generator state.
13
- --snapshot filepath Output file path for saving the pseudorandom number
14
- generator state upon exit.
15
-
package/etc/cli_opts.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "string": [
3
- "sep",
4
- "iter",
5
- "state",
6
- "seed",
7
- "snapshot"
8
- ],
9
- "boolean": [
10
- "help",
11
- "version"
12
- ],
13
- "alias": {
14
- "help": [
15
- "h"
16
- ],
17
- "version": [
18
- "V"
19
- ],
20
- "iter": [
21
- "n"
22
- ]
23
- }
24
- }