@stdlib/string-capitalize
Advanced tools
Sorry, the diff of this file is not supported yet
| /// <reference path="../docs/types/index.d.ts" /> | ||
| import capitalize from '../docs/types/index'; | ||
| export = capitalize; |
| "use strict";var a=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=a(function(c,i){ | ||
| var u=require('@stdlib/assert-is-string/dist').isPrimitive,s=require('@stdlib/error-tools-fmtprodmsg/dist'),n=require('@stdlib/string-base-capitalize/dist');function m(r){if(!u(r))throw new TypeError(s('1OX3F',r));return n(r)}i.exports=m | ||
| });var o=t();module.exports=o; | ||
| /** @license Apache-2.0 */ | ||
| //# sourceMappingURL=index.js.map |
| { | ||
| "version": 3, | ||
| "sources": ["../lib/main.js", "../lib/index.js"], | ||
| "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-capitalize' );\n\n\n// MAIN //\n\n/**\n* Capitalizes the first character in a string.\n*\n* @param {string} str - input string\n* @throws {TypeError} must provide a string\n* @returns {string} capitalized string\n*\n* @example\n* var out = capitalize( 'last man standing' );\n* // returns 'Last man standing'\n*\n* @example\n* var out = capitalize( 'presidential election' );\n* // returns 'Presidential election'\n*\n* @example\n* var out = capitalize( 'javaScript' );\n* // returns 'JavaScript'\n*\n* @example\n* var out = capitalize( 'Hidden Treasures' );\n* // returns 'Hidden Treasures'\n*/\nfunction capitalize( str ) {\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\treturn base( str );\n}\n\n\n// EXPORTS //\n\nmodule.exports = capitalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Capitalize the first character in a string.\n*\n* @module @stdlib/string-capitalize\n*\n* @example\n* var capitalize = require( '@stdlib/string-capitalize' );\n*\n* var out = capitalize( 'last man standing' );\n* // returns 'Last man standing'\n*\n* out = capitalize( 'Hidden Treasures' );\n* // returns 'Hidden Treasures';\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], | ||
| "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,gCAAiC,EA4BrD,SAASC,EAAYC,EAAM,CAC1B,GAAK,CAACJ,EAAUI,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,OAAOF,EAAME,CAAI,CAClB,CAKAL,EAAO,QAAUI,ICzBjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", | ||
| "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "format", "base", "capitalize", "str", "main"] | ||
| } |
+63
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2018 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| 'use strict'; | ||
| // MODULES // | ||
| var isString = require( '@stdlib/assert-is-string' ).isPrimitive; | ||
| var format = require( '@stdlib/string-format' ); | ||
| var base = require( '@stdlib/string-base-capitalize' ); | ||
| // MAIN // | ||
| /** | ||
| * Capitalizes the first character in a string. | ||
| * | ||
| * @param {string} str - input string | ||
| * @throws {TypeError} must provide a string | ||
| * @returns {string} capitalized string | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'last man standing' ); | ||
| * // returns 'Last man standing' | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'presidential election' ); | ||
| * // returns 'Presidential election' | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'javaScript' ); | ||
| * // returns 'JavaScript' | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'Hidden Treasures' ); | ||
| * // returns 'Hidden Treasures' | ||
| */ | ||
| function capitalize( str ) { | ||
| if ( !isString( str ) ) { | ||
| throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); | ||
| } | ||
| return base( str ); | ||
| } | ||
| // EXPORTS // | ||
| module.exports = capitalize; |
@@ -19,3 +19,3 @@ /* | ||
| // TypeScript Version: 2.0 | ||
| // TypeScript Version: 4.1 | ||
@@ -22,0 +22,0 @@ /** |
+2
-2
@@ -38,3 +38,3 @@ /** | ||
| var capitalize = require( './capitalize.js' ); | ||
| var main = require( './main.js' ); | ||
@@ -44,2 +44,2 @@ | ||
| module.exports = capitalize; | ||
| module.exports = main; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| Copyright (c) 2016-2022 The Stdlib Authors. | ||
| Copyright (c) 2016-2023 The Stdlib Authors. |
+7
-22
| { | ||
| "name": "@stdlib/string-capitalize", | ||
| "version": "0.0.9", | ||
| "version": "0.1.0", | ||
| "description": "Capitalize the first character in a string.", | ||
@@ -16,5 +16,2 @@ "license": "Apache-2.0", | ||
| ], | ||
| "bin": { | ||
| "capitalize": "./bin/cli" | ||
| }, | ||
| "main": "./lib", | ||
@@ -44,23 +41,11 @@ "directories": { | ||
| "dependencies": { | ||
| "@stdlib/assert-is-regexp-string": "^0.0.x", | ||
| "@stdlib/assert-is-string": "^0.0.x", | ||
| "@stdlib/cli-ctor": "^0.0.x", | ||
| "@stdlib/fs-read-file": "^0.0.x", | ||
| "@stdlib/process-read-stdin": "^0.0.x", | ||
| "@stdlib/regexp-eol": "^0.0.x", | ||
| "@stdlib/streams-node-stdin": "^0.0.x", | ||
| "@stdlib/string-format": "^0.0.x", | ||
| "@stdlib/utils-regexp-from-string": "^0.0.x" | ||
| "@stdlib/assert-is-string": "^0.1.0", | ||
| "@stdlib/string-base-capitalize": "^0.1.0", | ||
| "@stdlib/string-format": "^0.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@stdlib/assert-is-browser": "^0.0.x", | ||
| "@stdlib/assert-is-windows": "^0.0.x", | ||
| "@stdlib/bench": "^0.0.x", | ||
| "@stdlib/process-exec-path": "^0.0.x", | ||
| "@stdlib/string-from-code-point": "^0.0.x", | ||
| "@stdlib/string-replace": "^0.0.x", | ||
| "tape": "git+https://github.com/kgryte/tape.git#fix/globby", | ||
| "proxyquire": "^2.0.0", | ||
| "istanbul": "^0.4.1", | ||
| "tap-spec": "5.x.x" | ||
| "tap-min": "git+https://github.com/Planeshifter/tap-min.git" | ||
| }, | ||
@@ -98,5 +83,5 @@ "engines": { | ||
| "funding": { | ||
| "type": "patreon", | ||
| "url": "https://www.patreon.com/athan" | ||
| "type": "opencollective", | ||
| "url": "https://opencollective.com/stdlib" | ||
| } | ||
| } |
+26
-102
@@ -21,2 +21,13 @@ <!-- | ||
| <details> | ||
| <summary> | ||
| About stdlib... | ||
| </summary> | ||
| <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> | ||
| <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> | ||
| <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> | ||
| <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> | ||
| </details> | ||
| # capitalize | ||
@@ -48,3 +59,3 @@ | ||
| Capitalizes the first character in a `string`. | ||
| Capitalizes the first character in a string. | ||
@@ -72,5 +83,3 @@ ```javascript | ||
| var str; | ||
| str = capitalize( 'last man standing' ); | ||
| var str = capitalize( 'last man standing' ); | ||
| // returns 'Last man standing' | ||
@@ -92,94 +101,4 @@ | ||
| * * * | ||
| <section class="cli"> | ||
| ## CLI | ||
| <section class="installation"> | ||
| ## Installation | ||
| To use the module as a general utility, install the module globally | ||
| ```bash | ||
| npm install -g @stdlib/string-capitalize | ||
| ``` | ||
| </section> | ||
| <!-- CLI usage documentation. --> | ||
| <section class="usage"> | ||
| ### Usage | ||
| ```text | ||
| Usage: capitalize [options] [<string>] | ||
| Options: | ||
| -h, --help Print this message. | ||
| -V, --version Print the package version. | ||
| --split sep Delimiter for stdin data. Default: '/\\r?\\n/'. | ||
| ``` | ||
| </section> | ||
| <!-- /.usage --> | ||
| <!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
| <section class="notes"> | ||
| ### Notes | ||
| - If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes. | ||
| ```bash | ||
| # Not escaped... | ||
| $ echo -n $'beep\nboop' | capitalize --split /\r?\n/ | ||
| # Escaped... | ||
| $ echo -n $'beep\nboop' | capitalize --split /\\r?\\n/ | ||
| ``` | ||
| - The implementation ignores trailing delimiters. | ||
| </section> | ||
| <!-- /.notes --> | ||
| <section class="examples"> | ||
| ### Examples | ||
| ```bash | ||
| $ capitalize beep | ||
| Beep | ||
| ``` | ||
| To use as a [standard stream][standard-streams], | ||
| ```bash | ||
| $ echo -n 'beEp' | capitalize | ||
| BeEp | ||
| ``` | ||
| 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. | ||
| ```bash | ||
| $ echo -n 'beep\tbOOP' | capitalize --split '\t' | ||
| Beep | ||
| BOOP | ||
| ``` | ||
| </section> | ||
| <!-- /.examples --> | ||
| </section> | ||
| <!-- /.cli --> | ||
| <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
@@ -189,8 +108,7 @@ | ||
| * * * | ||
| ## See Also | ||
| - <span class="package-name">[`@stdlib/string/uncapitalize`][@stdlib/string/uncapitalize]</span><span class="delimiter">: </span><span class="description">uncapitalize the first character of a string.</span> | ||
| - <span class="package-name">[`@stdlib/string/uppercase`][@stdlib/string/uppercase]</span><span class="delimiter">: </span><span class="description">convert a string to uppercase.</span> | ||
| - <span class="package-name">[`@stdlib/string-capitalize-cli`][@stdlib/string-capitalize-cli]</span><span class="delimiter">: </span><span class="description">CLI package for use as a command-line utility.</span> | ||
| - <span class="package-name">[`@stdlib/string-uncapitalize`][@stdlib/string/uncapitalize]</span><span class="delimiter">: </span><span class="description">uncapitalize the first character of a string.</span> | ||
| - <span class="package-name">[`@stdlib/string-uppercase`][@stdlib/string/uppercase]</span><span class="delimiter">: </span><span class="description">convert a string to uppercase.</span> | ||
@@ -227,3 +145,3 @@ </section> | ||
| Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. | ||
| Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. | ||
@@ -238,7 +156,9 @@ </section> | ||
| [@stdlib/string-capitalize-cli]: https://www.npmjs.com/package/@stdlib/string-capitalize-cli | ||
| [npm-image]: http://img.shields.io/npm/v/@stdlib/string-capitalize.svg | ||
| [npm-url]: https://npmjs.org/package/@stdlib/string-capitalize | ||
| [test-image]: https://github.com/stdlib-js/string-capitalize/actions/workflows/test.yml/badge.svg?branch=v0.0.9 | ||
| [test-url]: https://github.com/stdlib-js/string-capitalize/actions/workflows/test.yml?query=branch:v0.0.9 | ||
| [test-image]: https://github.com/stdlib-js/string-capitalize/actions/workflows/test.yml/badge.svg?branch=v0.1.0 | ||
| [test-url]: https://github.com/stdlib-js/string-capitalize/actions/workflows/test.yml?query=branch:v0.1.0 | ||
@@ -256,3 +176,3 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-capitalize/main.svg | ||
| [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg | ||
| [chat-url]: https://gitter.im/stdlib-js/stdlib/ | ||
| [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im | ||
@@ -263,2 +183,6 @@ [stdlib]: https://github.com/stdlib-js/stdlib | ||
| [cli-section]: https://github.com/stdlib-js/string-capitalize#cli | ||
| [cli-url]: https://github.com/stdlib-js/string-capitalize/tree/cli | ||
| [@stdlib/string-capitalize]: https://github.com/stdlib-js/string-capitalize/tree/main | ||
| [umd]: https://github.com/umdjs/umd | ||
@@ -265,0 +189,0 @@ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules |
Sorry, the diff of this file is not supported yet
| {{alias}}( str ) | ||
| Capitalizes the first character in a `string`. | ||
| Parameters | ||
| ---------- | ||
| str: string | ||
| Input string. | ||
| Returns | ||
| ------- | ||
| out: string | ||
| Capitalized string. | ||
| Examples | ||
| -------- | ||
| > var out = {{alias}}( 'beep' ) | ||
| 'Beep' | ||
| > out = {{alias}}( 'Boop' ) | ||
| 'Boop' | ||
| See Also | ||
| -------- | ||
| /* | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2019 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import capitalize = require( './index' ); | ||
| // TESTS // | ||
| // The function returns a string... | ||
| { | ||
| capitalize( 'abc' ); // $ExpectType string | ||
| } | ||
| // The function does not compile if provided a value other than a string... | ||
| { | ||
| capitalize( true ); // $ExpectError | ||
| capitalize( false ); // $ExpectError | ||
| capitalize( null ); // $ExpectError | ||
| capitalize( undefined ); // $ExpectError | ||
| capitalize( 5 ); // $ExpectError | ||
| capitalize( [] ); // $ExpectError | ||
| capitalize( {} ); // $ExpectError | ||
| capitalize( ( x: number ): number => x ); // $ExpectError | ||
| } | ||
| // The function does not compile if provided insufficient arguments... | ||
| { | ||
| capitalize(); // $ExpectError | ||
| } |
| Usage: capitalize [options] [<string>] | ||
| Options: | ||
| -h, --help Print this message. | ||
| -V, --version Print the package version. | ||
| --split sep Delimiter for stdin data. Default: '/\\r?\\n/'. |
| { | ||
| "string": [ | ||
| "split" | ||
| ], | ||
| "boolean": [ | ||
| "help", | ||
| "version" | ||
| ], | ||
| "alias": { | ||
| "help": [ | ||
| "h" | ||
| ], | ||
| "version": [ | ||
| "V" | ||
| ] | ||
| } | ||
| } |
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2018 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| 'use strict'; | ||
| // MODULES // | ||
| var isString = require( '@stdlib/assert-is-string' ).isPrimitive; | ||
| var format = require( '@stdlib/string-format' ); | ||
| // MAIN // | ||
| /** | ||
| * Capitalizes the first character in a string. | ||
| * | ||
| * @param {string} str - input string | ||
| * @throws {TypeError} must provide a string primitive | ||
| * @returns {string} capitalized string | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'last man standing' ); | ||
| * // returns 'Last man standing' | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'presidential election' ); | ||
| * // returns 'Presidential election' | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'javaScript' ); | ||
| * // returns 'JavaScript' | ||
| * | ||
| * @example | ||
| * var out = capitalize( 'Hidden Treasures' ); | ||
| * // returns 'Hidden Treasures' | ||
| */ | ||
| function capitalize( str ) { | ||
| if ( !isString( str ) ) { | ||
| throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); | ||
| } | ||
| if ( str === '' ) { | ||
| return ''; | ||
| } | ||
| return str.charAt( 0 ).toUpperCase() + str.slice( 1 ); | ||
| } | ||
| // EXPORTS // | ||
| module.exports = capitalize; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3
-66.67%4
-60%27290
-2.7%11
-8.33%140
-26.32%204
-27.14%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated