@stdlib/datasets-suthaharan-single-hop-sensor-network-cli 0.1.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/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
20
+
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
32
+ # Single-Hop Sensor Network
33
+
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
+
36
+ > Labeled wireless sensor network data set collected from a simple single-hop wireless sensor network deployment using TelosB motes.
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+ <section class="cli">
49
+
50
+
51
+
52
+ <section class="installation">
53
+
54
+ ## Installation
55
+
56
+ To use as a general utility, install the CLI package globally
57
+
58
+ ```bash
59
+ npm install -g @stdlib/datasets-suthaharan-single-hop-sensor-network-cli
60
+ ```
61
+
62
+ </section>
63
+
64
+ <!-- CLI usage documentation. -->
65
+
66
+ <section class="usage">
67
+
68
+ ## Usage
69
+
70
+ ```text
71
+ Usage: suthaharan-single-hop-sensor-network [options]
72
+
73
+ Options:
74
+
75
+ -h, --help Print this message.
76
+ -V, --version Print the package version.
77
+ --format fmt Output format: 'csv' or 'ndjson'.
78
+ ```
79
+
80
+ </section>
81
+
82
+ <!-- /.usage -->
83
+
84
+ <section class="examples">
85
+
86
+ ## Examples
87
+
88
+ ```bash
89
+ $ suthaharan-single-hop-sensor-network
90
+ ```
91
+
92
+ </section>
93
+
94
+ <!-- /.examples -->
95
+
96
+ </section>
97
+
98
+ <!-- /.cli -->
99
+
100
+ * * *
101
+
102
+ <section class="references">
103
+
104
+ ## References
105
+
106
+ - Suthaharan, Shan, Mohammed Alzahrani, Sutharshan Rajasegarar, Christopher Leckie, and Marimuthu Palaniswami. 2010. "Labelled data collection for anomaly detection in wireless sensor networks." In _Proceedings of the Sixth International Conference on Intelligent Sensors, Sensor Networks and Information Processing (ISSNIP 2010)_. Brisbane, Australia: IEEE.
107
+
108
+ </section>
109
+
110
+ <!-- /.references -->
111
+
112
+ <!-- <license> -->
113
+
114
+ ## License
115
+
116
+ The data files (databases) are licensed under an [Open Data Commons Attribution 1.0 License][odc-by-1.0] and their contents are licensed under a [Creative Commons Attribution 4.0 International Public License][cc-by-4.0]. The original dataset is attributed to Shan Suthaharan, Mohammed Alzahrani, Sutharshan Rajasegarar, Christopher Leckie, and Marimuthu Palaniswami and can be found [here][suthaharan-single-hop-sensor-network-data]. The software is licensed under [Apache License, Version 2.0][apache-license].
117
+
118
+ <!-- </license> -->
119
+
120
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
121
+
122
+ <section class="related">
123
+
124
+ ## See Also
125
+
126
+ - <span class="package-name">[`@stdlib/datasets-suthaharan-single-hop-sensor-network`][@stdlib/datasets-suthaharan-single-hop-sensor-network]</span><span class="delimiter">: </span><span class="description">labeled wireless sensor network data set collected from a simple single-hop wireless sensor network deployment using TelosB motes.</span>
127
+ - <span class="package-name">[`@stdlib/datasets-suthaharan-multi-hop-sensor-network`][@stdlib/datasets/suthaharan-multi-hop-sensor-network]</span><span class="delimiter">: </span><span class="description">labeled wireless sensor network data set collected from a multi-hop wireless sensor network deployment using TelosB motes.</span>
128
+
129
+ </section>
130
+
131
+ <!-- /.related -->
132
+
133
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
134
+
135
+
136
+ <section class="main-repo" >
137
+
138
+ * * *
139
+
140
+ ## Notice
141
+
142
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
143
+
144
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
145
+
146
+ ### Community
147
+
148
+ [![Chat][chat-image]][chat-url]
149
+
150
+ ---
151
+
152
+ ## Copyright
153
+
154
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
155
+
156
+ </section>
157
+
158
+ <!-- /.stdlib -->
159
+
160
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
161
+
162
+ <section class="links">
163
+
164
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/datasets-suthaharan-single-hop-sensor-network-cli.svg
165
+ [npm-url]: https://npmjs.org/package/@stdlib/datasets-suthaharan-single-hop-sensor-network-cli
166
+
167
+ [test-image]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/actions/workflows/test.yml/badge.svg?branch=v0.1.0
168
+ [test-url]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/actions/workflows/test.yml?query=branch:v0.1.0
169
+
170
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/datasets-suthaharan-single-hop-sensor-network/main.svg
171
+ [coverage-url]: https://codecov.io/github/stdlib-js/datasets-suthaharan-single-hop-sensor-network?branch=main
172
+
173
+ <!--
174
+
175
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/datasets-suthaharan-single-hop-sensor-network.svg
176
+ [dependencies-url]: https://david-dm.org/stdlib-js/datasets-suthaharan-single-hop-sensor-network/main
177
+
178
+ -->
179
+
180
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
181
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
182
+
183
+ [stdlib]: https://github.com/stdlib-js/stdlib
184
+
185
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
186
+
187
+ [cli-section]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network#cli
188
+ [cli-url]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/tree/cli
189
+ [@stdlib/datasets-suthaharan-single-hop-sensor-network]: https://www.npmjs.com/package/@stdlib/datasets-suthaharan-single-hop-sensor-network
190
+
191
+ [umd]: https://github.com/umdjs/umd
192
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
193
+
194
+ [deno-url]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/tree/deno
195
+ [umd-url]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/tree/umd
196
+ [esm-url]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/tree/esm
197
+ [branches-url]: https://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network/blob/main/branches.md
198
+
199
+ [suthaharan-single-hop-sensor-network-data]: http://www.uncg.edu/cmp/downloads/lwsndr.html
200
+
201
+ [odc-by-1.0]: http://opendatacommons.org/licenses/by/1.0/
202
+
203
+ [cc-by-4.0]: http://creativecommons.org/licenses/by/4.0/
204
+
205
+ [apache-license]: https://www.apache.org/licenses/LICENSE-2.0
206
+
207
+ <!-- <related-links> -->
208
+
209
+ [@stdlib/datasets/suthaharan-multi-hop-sensor-network]: https://www.npmjs.com/package/@stdlib/datasets-suthaharan-multi-hop-sensor-network
210
+
211
+ <!-- </related-links> -->
212
+
213
+ </section>
214
+
215
+ <!-- /.links -->
package/bin/cli ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @license Apache-2.0
5
+ *
6
+ * Copyright (c) 2018 The Stdlib Authors.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ // MODULES //
24
+
25
+ var createReadStream = require( 'fs' ).createReadStream;
26
+ var resolve = require( 'path' ).resolve;
27
+ var readFileSync = require( '@stdlib/fs-read-file' ).sync;
28
+ var stdout = require( '@stdlib/streams-node-stdout' );
29
+ var CLI = require( '@stdlib/cli-ctor' );
30
+
31
+
32
+ // MAIN //
33
+
34
+ /**
35
+ * Main execution sequence.
36
+ *
37
+ * @private
38
+ */
39
+ function main() {
40
+ var flags;
41
+ var cli;
42
+
43
+ // Create a command-line interface:
44
+ cli = new CLI({
45
+ 'pkg': require( './../package.json' ),
46
+ 'options': require( './../etc/cli_opts.json' ),
47
+ 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
48
+ 'encoding': 'utf8'
49
+ })
50
+ });
51
+
52
+ // Get any provided command-line options:
53
+ flags = cli.flags();
54
+ if ( flags.help || flags.version ) {
55
+ return;
56
+ }
57
+ if ( flags.format === 'ndjson' ) {
58
+ ndjson();
59
+ } else {
60
+ csv();
61
+ }
62
+
63
+ /**
64
+ * Prints data as newline-delimited JSON (ndjson).
65
+ *
66
+ * @private
67
+ */
68
+ function ndjson() {
69
+ var data;
70
+ var i;
71
+
72
+ data = require( './../data/data.json' );
73
+ for ( i = 0; i < data.length; i++ ) {
74
+ console.log( JSON.stringify( data[i] ) ); // eslint-disable-line no-console
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Prints data as lines of comma-separated values (CSV).
80
+ *
81
+ * @private
82
+ */
83
+ function csv() {
84
+ var fpath = resolve( __dirname, '..', 'data', 'data.csv' );
85
+ createReadStream( fpath )
86
+ .pipe( stdout )
87
+ .on( 'close', onClose );
88
+ }
89
+
90
+ /**
91
+ * Exits the CLI.
92
+ *
93
+ * @private
94
+ */
95
+ function onClose() {
96
+ cli.close( 0 );
97
+ }
98
+ }
99
+
100
+ main();
package/docs/usage.txt ADDED
@@ -0,0 +1,9 @@
1
+
2
+ Usage: suthaharan-single-hop-sensor-network [options]
3
+
4
+ Options:
5
+
6
+ -h, --help Print this message.
7
+ -V, --version Print the package version.
8
+ --format fmt Output format: 'csv' or 'ndjson'.
9
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "string": [
3
+ "format"
4
+ ],
5
+ "boolean": [
6
+ "help",
7
+ "version"
8
+ ],
9
+ "alias": {
10
+ "help": [
11
+ "h"
12
+ ],
13
+ "version": [
14
+ "V"
15
+ ]
16
+ }
17
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@stdlib/datasets-suthaharan-single-hop-sensor-network-cli",
3
+ "version": "0.1.0",
4
+ "description": "Labeled wireless sensor network data set collected from a simple single-hop wireless sensor network deployment using TelosB motes.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "bin": {
17
+ "suthaharan-single-hop-sensor-network": "./bin/cli"
18
+ },
19
+ "homepage": "https://stdlib.io",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git://github.com/stdlib-js/datasets-suthaharan-single-hop-sensor-network.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/stdlib-js/stdlib/issues"
26
+ },
27
+ "dependencies": {
28
+ "@stdlib/cli-ctor": "^0.1.0",
29
+ "@stdlib/fs-read-file": "^0.1.0",
30
+ "@stdlib/streams-node-stdout": "^0.1.0"
31
+ },
32
+ "devDependencies": {
33
+ "@stdlib/assert-is-browser": "^0.1.0",
34
+ "@stdlib/assert-is-windows": "^0.1.0",
35
+ "@stdlib/process-exec-path": "^0.1.0",
36
+ "@stdlib/regexp-eol": "^0.1.0",
37
+ "proxyquire": "^2.0.0",
38
+ "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
39
+ "istanbul": "^0.4.1",
40
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
41
+ },
42
+ "keywords": [
43
+ "stdlib",
44
+ "datasets",
45
+ "dataset",
46
+ "data",
47
+ "sample",
48
+ "sensor",
49
+ "network",
50
+ "machine learning",
51
+ "ml",
52
+ "labeled",
53
+ "mote",
54
+ "motes",
55
+ "outliers",
56
+ "outlier",
57
+ "statistics",
58
+ "stats"
59
+ ],
60
+ "funding": {
61
+ "type": "opencollective",
62
+ "url": "https://opencollective.com/stdlib"
63
+ }
64
+ }
@@ -0,0 +1,208 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 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
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var resolve = require( 'path' ).resolve;
24
+ var exec = require( 'child_process' ).exec;
25
+ var tape = require( 'tape' );
26
+ var IS_BROWSER = require( '@stdlib/assert-is-browser' );
27
+ var IS_WINDOWS = require( '@stdlib/assert-is-windows' );
28
+ var EXEC_PATH = require( '@stdlib/process-exec-path' );
29
+ var RE_EOL = require( '@stdlib/regexp-eol' ).REGEXP;
30
+ var readFileSync = require( '@stdlib/fs-read-file' ).sync;
31
+
32
+
33
+ // VARIABLES //
34
+
35
+ var fpath = resolve( __dirname, '..', 'bin', 'cli' );
36
+ var opts = {
37
+ 'skip': IS_BROWSER || IS_WINDOWS
38
+ };
39
+
40
+
41
+ // FIXTURES //
42
+
43
+ var PKG_VERSION = require( './../package.json' ).version;
44
+
45
+
46
+ // TESTS //
47
+
48
+ tape( 'command-line interface', function test( t ) {
49
+ t.ok( true, __filename );
50
+ t.end();
51
+ });
52
+
53
+ tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
54
+ var expected;
55
+ var cmd;
56
+
57
+ expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
58
+ 'encoding': 'utf8'
59
+ });
60
+ cmd = [
61
+ EXEC_PATH,
62
+ fpath,
63
+ '--help'
64
+ ];
65
+
66
+ exec( cmd.join( ' ' ), done );
67
+
68
+ function done( error, stdout, stderr ) {
69
+ if ( error ) {
70
+ t.fail( error.message );
71
+ } else {
72
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
73
+ t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
74
+ }
75
+ t.end();
76
+ }
77
+ });
78
+
79
+ tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
80
+ var expected;
81
+ var cmd;
82
+
83
+ expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
84
+ 'encoding': 'utf8'
85
+ });
86
+ cmd = [
87
+ EXEC_PATH,
88
+ fpath,
89
+ '-h'
90
+ ];
91
+
92
+ exec( cmd.join( ' ' ), done );
93
+
94
+ function done( error, stdout, stderr ) {
95
+ if ( error ) {
96
+ t.fail( error.message );
97
+ } else {
98
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
99
+ t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
100
+ }
101
+ t.end();
102
+ }
103
+ });
104
+
105
+ tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
106
+ var cmd = [
107
+ EXEC_PATH,
108
+ fpath,
109
+ '--version'
110
+ ];
111
+
112
+ exec( cmd.join( ' ' ), done );
113
+
114
+ function done( error, stdout, stderr ) {
115
+ if ( error ) {
116
+ t.fail( error.message );
117
+ } else {
118
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
119
+ t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
120
+ }
121
+ t.end();
122
+ }
123
+ });
124
+
125
+ tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
126
+ var cmd = [
127
+ EXEC_PATH,
128
+ fpath,
129
+ '-V'
130
+ ];
131
+
132
+ exec( cmd.join( ' ' ), done );
133
+
134
+ function done( error, stdout, stderr ) {
135
+ if ( error ) {
136
+ t.fail( error.message );
137
+ } else {
138
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
139
+ t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
140
+ }
141
+ t.end();
142
+ }
143
+ });
144
+
145
+ tape( 'the command-line interface prints the dataset as comma-separated values', opts, function test( t ) {
146
+ var expected;
147
+ var opts;
148
+ var cmd;
149
+
150
+ cmd = [
151
+ EXEC_PATH,
152
+ fpath
153
+ ];
154
+
155
+ expected = readFileSync( resolve( __dirname, '..', 'data', 'data.csv' ) );
156
+
157
+ opts = {
158
+ 'maxBuffer': 50000*1024
159
+ };
160
+ exec( cmd.join( ' ' ), opts, done );
161
+
162
+ function done( error, stdout, stderr ) {
163
+ if ( error ) {
164
+ t.fail( error.message );
165
+ } else {
166
+ stdout = stdout.toString();
167
+ expected = expected.toString();
168
+ t.strictEqual( stdout, expected, 'prints CSV' );
169
+ t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
170
+ }
171
+ t.end();
172
+ }
173
+ });
174
+
175
+ tape( 'the command-line interface prints the dataset as newline-delimited JSON', opts, function test( t ) {
176
+ var expected;
177
+ var opts;
178
+ var cmd;
179
+
180
+ cmd = [
181
+ EXEC_PATH,
182
+ fpath,
183
+ '--format ndjson'
184
+ ];
185
+
186
+ expected = require( './../data/data.json' );
187
+
188
+ opts = {
189
+ 'maxBuffer': 50000*1024
190
+ };
191
+ exec( cmd.join( ' ' ), opts, done );
192
+
193
+ function done( error, stdout, stderr ) {
194
+ var str;
195
+ var i;
196
+ if ( error ) {
197
+ t.fail( error.message );
198
+ } else {
199
+ stdout = stdout.toString().split( RE_EOL );
200
+ for ( i = 0; i < expected.length; i++ ) {
201
+ str = JSON.stringify( expected[ i ] );
202
+ t.strictEqual( stdout[ i ], str, 'returns expected JSON string' );
203
+ }
204
+ t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
205
+ }
206
+ t.end();
207
+ }
208
+ });