@stdlib/string-kebabcase 0.0.4 → 0.0.7

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/LICENSE CHANGED
File without changes
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md CHANGED
@@ -101,110 +101,19 @@ out = kebabcase( str );
101
101
 
102
102
  <!-- /.examples -->
103
103
 
104
- * * *
105
-
106
- <section class="cli">
107
-
108
- ## CLI
109
-
110
- <section class="installation">
111
-
112
- ## Installation
113
-
114
- To use the module as a general utility, install the module globally
115
-
116
- ```bash
117
- npm install -g @stdlib/string-kebabcase
118
- ```
119
-
120
- </section>
121
-
122
- <!-- CLI usage documentation. -->
123
-
124
- <section class="usage">
125
-
126
- ### Usage
127
-
128
- ```text
129
- Usage: kebabcase [options] [<string>]
130
-
131
- Options:
132
-
133
- -h, --help Print this message.
134
- -V, --version Print the package version.
135
- --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
136
- ```
137
-
138
- </section>
139
-
140
- <!-- /.usage -->
141
-
142
- <!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
143
-
144
- <section class="notes">
145
-
146
- ### Notes
147
-
148
- - If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
149
-
150
- ```bash
151
- # Not escaped...
152
- $ echo -n $'beEp booP\nisMobile' | kebabcase --split /\r?\n/
153
104
 
154
- # Escaped...
155
- $ echo -n $'beEp booP\nisMobile' | kebabcase --split /\\r?\\n/
156
- ```
157
-
158
- - The implementation ignores trailing delimiters.
159
-
160
- </section>
161
-
162
- <!-- /.notes -->
163
-
164
- <section class="examples">
165
-
166
- ### Examples
167
-
168
- ```bash
169
- $ kebabcase 'hello world!'
170
- hello-world
171
- ```
172
-
173
- To use as a [standard stream][standard-streams],
174
-
175
- ```bash
176
- $ echo -n 'beEp booP' | kebabcase
177
- beep-boop
178
- ```
179
-
180
- By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option.
181
-
182
- ```bash
183
- $ echo -n 'beep_boop\tisMobile' | kebabcase --split '\t'
184
- beep-boop
185
- is-mobile
186
- ```
187
-
188
- </section>
189
-
190
- <!-- /.examples -->
191
-
192
- </section>
193
-
194
- <!-- /.cli -->
195
105
 
196
106
  <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
197
107
 
198
108
  <section class="related">
199
109
 
200
- * * *
201
-
202
110
  ## See Also
203
111
 
204
- - <span class="package-name">[`@stdlib/string/camelcase`][@stdlib/string/camelcase]</span><span class="delimiter">: </span><span class="description">convert a string to camel case.</span>
205
- - <span class="package-name">[`@stdlib/string/constantcase`][@stdlib/string/constantcase]</span><span class="delimiter">: </span><span class="description">convert a string to constant case.</span>
206
- - <span class="package-name">[`@stdlib/string/pascalcase`][@stdlib/string/pascalcase]</span><span class="delimiter">: </span><span class="description">convert a string to Pascal case.</span>
207
- - <span class="package-name">[`@stdlib/string/snakecase`][@stdlib/string/snakecase]</span><span class="delimiter">: </span><span class="description">convert a string to snake case.</span>
112
+ - <span class="package-name">[`@stdlib/string-kebabcase-cli`][@stdlib/string-kebabcase-cli]</span><span class="delimiter">: </span><span class="description">CLI package for use as a command-line utility.</span>
113
+ - <span class="package-name">[`@stdlib/string-camelcase`][@stdlib/string/camelcase]</span><span class="delimiter">: </span><span class="description">convert a string to camel case.</span>
114
+ - <span class="package-name">[`@stdlib/string-constantcase`][@stdlib/string/constantcase]</span><span class="delimiter">: </span><span class="description">convert a string to constant case.</span>
115
+ - <span class="package-name">[`@stdlib/string-pascalcase`][@stdlib/string/pascalcase]</span><span class="delimiter">: </span><span class="description">convert a string to Pascal case.</span>
116
+ - <span class="package-name">[`@stdlib/string-snakecase`][@stdlib/string/snakecase]</span><span class="delimiter">: </span><span class="description">convert a string to snake case.</span>
208
117
 
209
118
  </section>
210
119
 
@@ -236,7 +145,7 @@ See [LICENSE][stdlib-license].
236
145
 
237
146
  ## Copyright
238
147
 
239
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
148
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
240
149
 
241
150
  </section>
242
151
 
@@ -246,11 +155,13 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
246
155
 
247
156
  <section class="links">
248
157
 
158
+ [@stdlib/string-kebabcase-cli]: https://www.npmjs.com/package/@stdlib/string-kebabcase-cli
159
+
249
160
  [npm-image]: http://img.shields.io/npm/v/@stdlib/string-kebabcase.svg
250
161
  [npm-url]: https://npmjs.org/package/@stdlib/string-kebabcase
251
162
 
252
- [test-image]: https://github.com/stdlib-js/string-kebabcase/actions/workflows/test.yml/badge.svg?branch=v0.0.4
253
- [test-url]: https://github.com/stdlib-js/string-kebabcase/actions/workflows/test.yml?query=branch:v0.0.4
163
+ [test-image]: https://github.com/stdlib-js/string-kebabcase/actions/workflows/test.yml/badge.svg?branch=v0.0.7
164
+ [test-url]: https://github.com/stdlib-js/string-kebabcase/actions/workflows/test.yml?query=branch:v0.0.7
254
165
 
255
166
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-kebabcase/main.svg
256
167
  [coverage-url]: https://codecov.io/github/stdlib-js/string-kebabcase?branch=main
@@ -263,12 +174,16 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
263
174
  -->
264
175
 
265
176
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
266
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
177
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
267
178
 
268
179
  [stdlib]: https://github.com/stdlib-js/stdlib
269
180
 
270
181
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
271
182
 
183
+ [cli-section]: https://github.com/stdlib-js/string-kebabcase#cli
184
+ [cli-url]: https://github.com/stdlib-js/string-kebabcase/tree/cli
185
+ [@stdlib/string-kebabcase]: https://github.com/stdlib-js/string-kebabcase/tree/main
186
+
272
187
  [umd]: https://github.com/umdjs/umd
273
188
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
274
189
 
@@ -0,0 +1,5 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import kebabcase
3
+ from '../docs/types/index';
4
+ export = kebabcase
5
+ ;
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";var a=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var t=a((b,i)=>{"use strict";var s=require("@stdlib/assert-is-string/dist").isPrimitive,u=require("@stdlib/error-tools-fmtprodmsg/dist"),n=require("@stdlib/string-base-kebabcase/dist");function o(r){if(!s(r))throw new TypeError(u("1Oj3B",r));return n(r)}i.exports=o});var v=t();module.exports=v;
2
+ /** @license Apache-2.0 */
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../tmp/main.js", "../tmp/index.js"],
4
+ "sourcesContent": ["/** @license Apache-2.0 */\n'use strict';\nvar isString = require( '@stdlib/assert-is-string/dist' ).isPrimitive;\nvar format = require( '@stdlib/error-tools-fmtprodmsg/dist' );\nvar base = require( '@stdlib/string-base-kebabcase/dist' );\nfunction kebabCase(str) {\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Oj3B', str ) );\n\t}\n\treturn base( str );\n}\nmodule.exports = kebabCase;\n", "/** @license Apache-2.0 */\n'use strict';\nvar main = require( './main.js' );\nmodule.exports = main;\n"],
5
+ "mappings": "2EAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,cAEA,IAAIC,EAAW,QAAS,+BAAgC,EAAE,YACtDC,EAAS,QAAS,qCAAsC,EACxDC,EAAO,QAAS,oCAAqC,EACzD,SAASC,EAAUC,EAAK,CACvB,GAAK,CAACJ,EAAUI,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,QAASG,CAAI,CAAE,EAE7C,OAAOF,EAAME,CAAI,CAClB,CACAL,EAAO,QAAUI,ICTjB,IAAIE,EAAO,IACX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "format", "base", "kebabCase", "str", "main"]
7
+ }
@@ -22,7 +22,7 @@
22
22
  * Converts a string to kebab case.
23
23
  *
24
24
  * @param str - string to convert
25
- * @returns a kebab-cased string
25
+ * @returns kebab-cased string
26
26
  *
27
27
  * @example
28
28
  * var str = kebabcase( 'fooBar' );
package/lib/index.js CHANGED
@@ -35,9 +35,9 @@
35
35
 
36
36
  // MODULES //
37
37
 
38
- var kebabcase = require( './main.js' );
38
+ var main = require( './main.js' );
39
39
 
40
40
 
41
41
  // EXPORTS //
42
42
 
43
- module.exports = kebabcase;
43
+ module.exports = main;
package/lib/main.js CHANGED
@@ -21,17 +21,8 @@
21
21
  // MODULES //
22
22
 
23
23
  var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
24
- var lowercase = require( '@stdlib/string-lowercase' );
25
- var replace = require( '@stdlib/string-replace' );
26
24
  var format = require( '@stdlib/string-format' );
27
- var trim = require( '@stdlib/string-trim' );
28
-
29
-
30
- // VARIABLES //
31
-
32
- var RE_WHITESPACE = /\s+/g;
33
- var RE_SPECIAL = /[!"'(),–.:;<>?`{}|~\/\\\[\]_#$*&^@%]+/g; // eslint-disable-line no-useless-escape
34
- var RE_CAMEL = /([a-z0-9])([A-Z])/g;
25
+ var base = require( '@stdlib/string-base-kebabcase' );
35
26
 
36
27
 
37
28
  // MAIN //
@@ -40,7 +31,7 @@ var RE_CAMEL = /([a-z0-9])([A-Z])/g;
40
31
  * Converts a string to kebab case.
41
32
  *
42
33
  * @param {string} str - string to convert
43
- * @throws {TypeError} must provide a string primitive
34
+ * @throws {TypeError} must provide a string
44
35
  * @returns {string} kebab-cased string
45
36
  *
46
37
  * @example
@@ -67,11 +58,7 @@ function kebabCase( str ) {
67
58
  if ( !isString( str ) ) {
68
59
  throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) );
69
60
  }
70
- str = replace( str, RE_SPECIAL, ' ' );
71
- str = replace( str, RE_CAMEL, '$1 $2' );
72
- str = trim( str );
73
- str = replace( str, RE_WHITESPACE, '-' );
74
- return lowercase( str );
61
+ return base( str );
75
62
  }
76
63
 
77
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/string-kebabcase",
3
- "version": "0.0.4",
3
+ "version": "0.0.7",
4
4
  "description": "Convert a string to kebab case.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -13,9 +13,6 @@
13
13
  "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
14
  }
15
15
  ],
16
- "bin": {
17
- "kebabcase": "./bin/cli"
18
- },
19
16
  "main": "./lib",
20
17
  "directories": {
21
18
  "benchmark": "./benchmark",
@@ -40,29 +37,16 @@
40
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
41
38
  },
42
39
  "dependencies": {
43
- "@stdlib/assert-is-regexp-string": "^0.0.x",
44
- "@stdlib/assert-is-string": "^0.0.x",
45
- "@stdlib/cli-ctor": "^0.0.x",
46
- "@stdlib/fs-read-file": "^0.0.x",
47
- "@stdlib/process-read-stdin": "^0.0.x",
48
- "@stdlib/regexp-eol": "^0.0.x",
49
- "@stdlib/streams-node-stdin": "^0.0.x",
50
- "@stdlib/string-format": "^0.0.x",
51
- "@stdlib/string-lowercase": "^0.0.x",
52
- "@stdlib/string-replace": "^0.0.x",
53
- "@stdlib/string-trim": "^0.0.x",
54
- "@stdlib/utils-regexp-from-string": "^0.0.x"
40
+ "@stdlib/assert-is-string": "^0.0.8",
41
+ "@stdlib/string-base-kebabcase": "^0.0.2",
42
+ "@stdlib/string-format": "^0.0.3",
43
+ "@stdlib/error-tools-fmtprodmsg": "^0.0.2"
55
44
  },
56
45
  "devDependencies": {
57
- "@stdlib/assert-is-browser": "^0.0.x",
58
- "@stdlib/assert-is-windows": "^0.0.x",
59
- "@stdlib/bench": "^0.0.x",
60
- "@stdlib/process-exec-path": "^0.0.x",
61
- "@stdlib/string-from-code-point": "^0.0.x",
62
46
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
63
47
  "proxyquire": "^2.0.0",
64
48
  "istanbul": "^0.4.1",
65
- "tap-spec": "5.x.x"
49
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
66
50
  },
67
51
  "engines": {
68
52
  "node": ">=0.10.0",
@@ -94,7 +78,7 @@
94
78
  ],
95
79
  "__stdlib__": {},
96
80
  "funding": {
97
- "type": "patreon",
98
- "url": "https://www.patreon.com/athan"
81
+ "type": "opencollective",
82
+ "url": "https://opencollective.com/stdlib"
99
83
  }
100
84
  }
package/bin/cli DELETED
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @license Apache-2.0
5
- *
6
- * Copyright (c) 2021 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 resolve = require( 'path' ).resolve;
26
- var readFileSync = require( '@stdlib/fs-read-file' ).sync;
27
- var CLI = require( '@stdlib/cli-ctor' );
28
- var stdin = require( '@stdlib/process-read-stdin' );
29
- var stdinStream = require( '@stdlib/streams-node-stdin' );
30
- var RE_EOL = require( '@stdlib/regexp-eol' ).REGEXP;
31
- var isRegExpString = require( '@stdlib/assert-is-regexp-string' );
32
- var reFromString = require( '@stdlib/utils-regexp-from-string' );
33
- var kebabcase = require( './../lib' );
34
-
35
-
36
- // MAIN //
37
-
38
- /**
39
- * Main execution sequence.
40
- *
41
- * @private
42
- * @returns {void}
43
- */
44
- function main() {
45
- var split;
46
- var flags;
47
- var args;
48
- var cli;
49
-
50
- // Create a command-line interface:
51
- cli = new CLI({
52
- 'pkg': require( './../package.json' ),
53
- 'options': require( './../etc/cli_opts.json' ),
54
- 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
55
- 'encoding': 'utf8'
56
- })
57
- });
58
-
59
- // Get any provided command-line options:
60
- flags = cli.flags();
61
- if ( flags.help || flags.version ) {
62
- return;
63
- }
64
-
65
- // Get any provided command-line arguments:
66
- args = cli.args();
67
-
68
- // Check if we are receiving data from `stdin`...
69
- if ( !stdinStream.isTTY ) {
70
- if ( flags.split ) {
71
- if ( !isRegExpString( flags.split ) ) {
72
- flags.split = '/'+flags.split+'/';
73
- }
74
- split = reFromString( flags.split );
75
- } else {
76
- split = RE_EOL;
77
- }
78
- return stdin( onRead );
79
- }
80
- console.log( kebabcase( args[ 0 ] ) ); // eslint-disable-line no-console
81
-
82
- /**
83
- * Callback invoked upon reading from `stdin`.
84
- *
85
- * @private
86
- * @param {(Error|null)} error - error object
87
- * @param {Buffer} data - data
88
- * @returns {void}
89
- */
90
- function onRead( error, data ) {
91
- var lines;
92
- var i;
93
- if ( error ) {
94
- return cli.error( error );
95
- }
96
- lines = data.toString().split( split );
97
-
98
- // Remove any trailing separators (e.g., trailing newline)...
99
- if ( lines[ lines.length-1 ] === '' ) {
100
- lines.pop();
101
- }
102
- for ( i = 0; i < lines.length; i++ ) {
103
- console.log( kebabcase( lines[ i ] ) ); // eslint-disable-line no-console
104
- }
105
- }
106
- }
107
-
108
- main();
package/docs/repl.txt DELETED
@@ -1,23 +0,0 @@
1
-
2
- {{alias}}( str )
3
- Converts a string to kebab case.
4
-
5
- Parameters
6
- ----------
7
- str: string
8
- Input string.
9
-
10
- Returns
11
- -------
12
- out: string
13
- Kebab-cased string.
14
-
15
- Examples
16
- --------
17
- > var out = {{alias}}( 'Hello World!' )
18
- 'hello-world'
19
- > out = {{alias}}( 'I am a tiny little teapot' )
20
- 'i-am-a-tiny-little-teapot'
21
-
22
- See Also
23
- --------
@@ -1,44 +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
- import kebabcase = require( './index' );
20
-
21
-
22
- // TESTS //
23
-
24
- // The function returns a string...
25
- {
26
- kebabcase( 'Hello World!' ); // $ExpectType string
27
- }
28
-
29
- // The function does not compile if provided a value other than a string...
30
- {
31
- kebabcase( true ); // $ExpectError
32
- kebabcase( false ); // $ExpectError
33
- kebabcase( null ); // $ExpectError
34
- kebabcase( undefined ); // $ExpectError
35
- kebabcase( 5 ); // $ExpectError
36
- kebabcase( [] ); // $ExpectError
37
- kebabcase( {} ); // $ExpectError
38
- kebabcase( ( x: number ): number => x ); // $ExpectError
39
- }
40
-
41
- // The function does not compile if provided insufficient arguments...
42
- {
43
- kebabcase(); // $ExpectError
44
- }
package/docs/usage.txt DELETED
@@ -1,8 +0,0 @@
1
-
2
- Usage: kebabcase [options] [<string>]
3
-
4
- Options:
5
-
6
- -h, --help Print this message.
7
- -V, --version Print the package version.
8
- --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
package/etc/cli_opts.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "string": [
3
- "split"
4
- ],
5
- "boolean": [
6
- "help",
7
- "version"
8
- ],
9
- "alias": {
10
- "help": [
11
- "h"
12
- ],
13
- "version": [
14
- "V"
15
- ]
16
- }
17
- }