Socket
Socket
Sign inDemoInstall

pascalcase

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 1.0.0

29

index.js
/*!
* pascalcase <https://github.com/jonschlinkert/pascalcase>
*
* Copyright (c) 2015, Jon Schlinkert.
* Copyright (c) 2015-present, Jon ("Schlink") Schlinkert.
* Licensed under the MIT License.
*/
function pascalcase(str) {
if (typeof str !== 'string') {
throw new TypeError('expected a string.');
const titlecase = input => input[0].toLocaleUpperCase() + input.slice(1);
module.exports = value => {
if (value === null || value === void 0) return '';
if (typeof value.toString !== 'function') return '';
let input = value.toString().trim();
if (input === '') return '';
if (input.length === 1) return input.toLocaleUpperCase();
let match = input.match(/[a-zA-Z0-9]+/g);
if (match) {
return match.map(m => titlecase(m)).join('');
}
str = str.replace(/([A-Z])/g, ' $1');
if (str.length === 1) { return str.toUpperCase(); }
str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase();
str = str.charAt(0).toUpperCase() + str.slice(1);
return str.replace(/[\W_]+(\w|$)/g, function (_, ch) {
return ch.toUpperCase();
});
}
module.exports = pascalcase;
return input;
};
{
"name": "pascalcase",
"description": "Convert a string to pascal-case.",
"version": "0.1.1",
"version": "1.0.0",
"homepage": "https://github.com/jonschlinkert/pascalcase",

@@ -17,3 +17,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"engines": {
"node": ">=0.10.0"
"node": ">=8"
},

@@ -24,4 +24,4 @@ "scripts": {

"devDependencies": {
"mocha": "*",
"should": "*"
"gulp-format-md": "^2.0.0",
"mocha": "^6.2.0"
},

@@ -34,16 +34,28 @@ "keywords": [

"pascal-case",
"pascal case",
"pascalcase",
"string"
"string",
"UpperCamelCase"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"pad-left",
"pad-right",
"ansi-colors",
"word-wrap",
"repeat-string",
"randomatic",
"justified"
]
},
"lint": {
"reflinks": true
}
}
}
}

@@ -1,11 +0,13 @@

# pascalcase [![NPM version](https://badge.fury.io/js/pascalcase.svg)](http://badge.fury.io/js/pascalcase)
# pascalcase [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/pascalcase.svg?style=flat)](https://www.npmjs.com/package/pascalcase) [![NPM monthly downloads](https://img.shields.io/npm/dm/pascalcase.svg?style=flat)](https://npmjs.org/package/pascalcase) [![NPM total downloads](https://img.shields.io/npm/dt/pascalcase.svg?style=flat)](https://npmjs.org/package/pascalcase) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/pascalcase.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/pascalcase)
> Convert a string to pascal-case.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/)
Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=8):
```sh
$ npm i pascalcase --save
$ npm install --save pascalcase
```

@@ -16,66 +18,75 @@

```js
var pascalcase = require('pascalcase');
const pascalcase = require('pascalcase');
pascalcase('a');
//=> 'A'
console.log(pascalcase('a')); //=> 'A'
console.log(pascalcase('foo bar baz')); //=> 'FooBarBaz'
console.log(pascalcase(' foo bar baz ')); //=> 'FooBarBaz'
console.log(pascalcase('foo_bar-baz')); //=> 'FooBarBaz'
console.log(pascalcase('foo.bar.baz')); //=> 'FooBarBaz'
console.log(pascalcase('foo/bar/baz')); //=> 'FooBarBaz'
console.log(pascalcase('foo[bar)baz')); //=> 'FooBarBaz'
console.log(pascalcase('#foo+bar*baz')); //=> 'FooBarBaz'
console.log(pascalcase('$foo~bar`baz')); //=> 'FooBarBaz'
console.log(pascalcase('_foo_bar-baz-')); //=> 'FooBarBaz'
console.log(pascalcase('foo 2 bar 5 baz')); //=> 'Foo2Bar5Baz'
console.log(pascalcase('foo2bar5baz')); //=> 'Foo2bar5baz'
```
pascalcase('foo bar baz');
//=> 'FooBarBaz'
## About
pascalcase('foo_bar-baz');
//=> 'FooBarBaz'
<details>
<summary><strong>Contributing</strong></summary>
pascalcase('foo.bar.baz');
//=> 'FooBarBaz'
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
pascalcase('foo/bar/baz');
//=> 'FooBarBaz'
</details>
pascalcase('foo[bar)baz');
//=> 'FooBarBaz'
<details>
<summary><strong>Running Tests</strong></summary>
pascalcase('#foo+bar*baz');
//=> 'FooBarBaz'
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
pascalcase('$foo~bar`baz');
//=> 'FooBarBaz'
pascalcase('_foo_bar-baz-');
//=> 'FooBarBaz'
```sh
$ npm install && npm test
```
## Related projects
</details>
* [justified](https://github.com/jonschlinkert/justified): Wrap words to a specified length and justified the text.
* [pad-left](https://github.com/jonschlinkert/pad-left): Left pad a string with zeros or a specified string. Fastest implementation.
* [pad-right](https://github.com/jonschlinkert/pad-right): Right pad a string with zeros or a specified string. Fastest implementation.
* [repeat-string](https://github.com/jonschlinkert/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string.
* [word-wrap](https://github.com/jonschlinkert/word-wrap): Wrap words to a specified length.
<details>
<summary><strong>Building docs</strong></summary>
## Running tests
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
Install dev dependencies:
To generate the readme, run the following command:
```sh
$ npm i -d && npm test
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
## Contributing
</details>
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/pascalcase/issues/new)
### Related projects
## Author
You might also be interested in these projects:
* [ansi-colors](https://www.npmjs.com/package/ansi-colors): Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in… [more](https://github.com/doowb/ansi-colors) | [homepage](https://github.com/doowb/ansi-colors "Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).")
* [justified](https://www.npmjs.com/package/justified): Wraps words to a specified length and justifies the text in each line. | [homepage](https://github.com/jonschlinkert/justified "Wraps words to a specified length and justifies the text in each line.")
* [randomatic](https://www.npmjs.com/package/randomatic): Generate randomized strings of a specified length using simple character sequences. The original generate-password. | [homepage](https://github.com/jonschlinkert/randomatic "Generate randomized strings of a specified length using simple character sequences. The original generate-password.")
* [word-wrap](https://www.npmjs.com/package/word-wrap): Wrap words to a specified length. | [homepage](https://github.com/jonschlinkert/word-wrap "Wrap words to a specified length.")
### Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
## License
### License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 19, 2015._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on August 08, 2019._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc