|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2021 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 | +# pkg2standalone |
| 22 | + |
| 23 | +> Return the standalone package name associated with a provided internal package name. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var pkg2standalone = require( '@stdlib/namespace/pkg2standalone' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### pkg2standalone( pkg ) |
| 44 | + |
| 45 | +Returns the standalone package name associated with a provided internal package name. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var v = pkg2standalone( '@stdlib/math/base/special/sin' ); |
| 49 | +// returns '@stdlib/math-base-special-sin' |
| 50 | +``` |
| 51 | + |
| 52 | +If provided an unrecognized `pkg`, the function returns `null`. |
| 53 | + |
| 54 | +```javascript |
| 55 | +var v = pkg2standalone( 'unrecognized_pkg_beep_boop_bop_bip' ); |
| 56 | +// returns null |
| 57 | +``` |
| 58 | + |
| 59 | +</section> |
| 60 | + |
| 61 | +<!-- /.usage --> |
| 62 | + |
| 63 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 64 | + |
| 65 | +<section class="notes"> |
| 66 | + |
| 67 | +</section> |
| 68 | + |
| 69 | +<!-- /.notes --> |
| 70 | + |
| 71 | +<!-- Package usage examples. --> |
| 72 | + |
| 73 | +<section class="examples"> |
| 74 | + |
| 75 | +## Examples |
| 76 | + |
| 77 | +<!-- TODO: better example --> |
| 78 | + |
| 79 | +<!-- eslint no-undef: "error" --> |
| 80 | + |
| 81 | +```javascript |
| 82 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 83 | +var aliases = require( '@stdlib/namespace/aliases' ); |
| 84 | +var alias2pkg = require( '@stdlib/namespace/alias2pkg' ); |
| 85 | +var pkg2standalone = require( '@stdlib/namespace/pkg2standalone' ); |
| 86 | + |
| 87 | +var list; |
| 88 | +var len; |
| 89 | +var idx; |
| 90 | +var v1; |
| 91 | +var v2; |
| 92 | +var i; |
| 93 | + |
| 94 | +list = aliases(); |
| 95 | +len = list.length; |
| 96 | + |
| 97 | +for ( i = 0; i < 100; i++ ) { |
| 98 | + idx = discreteUniform( 0, len-1 ); |
| 99 | + v1 = alias2pkg( list[ idx ] ); |
| 100 | + v2 = pkg2standalone( v1 ); |
| 101 | + console.log( 'alias: %s. pkg: %s.', list[ idx ], v1 ); |
| 102 | + console.log( 'pkg: %s. standalone: %s.', v1, v2 ); |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +</section> |
| 107 | + |
| 108 | +<!-- /.examples --> |
| 109 | + |
| 110 | +<!-- Section for describing a command-line interface. --> |
| 111 | + |
| 112 | +* * * |
| 113 | + |
| 114 | +<section class="cli"> |
| 115 | + |
| 116 | +## CLI |
| 117 | + |
| 118 | +<!-- CLI usage documentation. --> |
| 119 | + |
| 120 | +<section class="usage"> |
| 121 | + |
| 122 | +### Usage |
| 123 | + |
| 124 | +```text |
| 125 | +Usage: stdlib-pkg2standalone [options] <pkg> |
| 126 | +
|
| 127 | +Options: |
| 128 | +
|
| 129 | + -h, --help Print this message. |
| 130 | + -V, --version Print the package version. |
| 131 | +``` |
| 132 | + |
| 133 | +</section> |
| 134 | + |
| 135 | +<!-- /.usage --> |
| 136 | + |
| 137 | +<!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 138 | + |
| 139 | +<section class="notes"> |
| 140 | + |
| 141 | +</section> |
| 142 | + |
| 143 | +<!-- /.notes --> |
| 144 | + |
| 145 | +<!-- CLI usage examples. --> |
| 146 | + |
| 147 | +<section class="examples"> |
| 148 | + |
| 149 | +### Examples |
| 150 | + |
| 151 | +```bash |
| 152 | +$ stdlib-pkg2standalone '@stdlib/math/base/special/sin' |
| 153 | +@stdlib/math-base-special-sin |
| 154 | +``` |
| 155 | + |
| 156 | +</section> |
| 157 | + |
| 158 | +<!-- /.examples --> |
| 159 | + |
| 160 | +</section> |
| 161 | + |
| 162 | +<!-- /.cli --> |
| 163 | + |
| 164 | +<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 165 | + |
| 166 | +<section class="references"> |
| 167 | + |
| 168 | +</section> |
| 169 | + |
| 170 | +<!-- /.references --> |
| 171 | + |
| 172 | +<!-- <license> --> |
| 173 | + |
| 174 | +## License |
| 175 | + |
| 176 | +The data files (databases) are licensed under an [Open Data Commons Public Domain Dedication & License 1.0][pddl-1.0] and their contents are licensed under [Creative Commons Zero v1.0 Universal][cc0]. The software is licensed under [Apache License, Version 2.0][apache-license]. |
| 177 | + |
| 178 | +<!-- </license> --> |
| 179 | + |
| 180 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 181 | + |
| 182 | +<section class="links"> |
| 183 | + |
| 184 | +[pddl-1.0]: http://opendatacommons.org/licenses/pddl/1.0/ |
| 185 | + |
| 186 | +[cc0]: https://creativecommons.org/publicdomain/zero/1.0 |
| 187 | + |
| 188 | +[apache-license]: https://www.apache.org/licenses/LICENSE-2.0 |
| 189 | + |
| 190 | +</section> |
| 191 | + |
| 192 | +<!-- /.links --> |
0 commit comments