Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

to-case

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-case - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

.travis.yml

7

History.md
2.0.0 - January 21, 2016
------------------------
* drop component support
* update all dependencies
* cleanup code style
* add travis ci
1.0.2 - January 5, 2016

@@ -3,0 +10,0 @@ -----------------------

66

lib/cases.js
var camel = require('to-camel-case');
var capital = require('to-capital-case');
var constant = require('to-constant-case');
var dot = require('to-dot-case');
var none = require('to-no-case');
var pascal = require('to-pascal-case');
var sentence = require('to-sentence-case');
var slug = require('to-slug-case');
var snake = require('to-snake-case');
var space = require('to-space-case');
var title = require('to-title-case');
var camel = require('to-camel-case')
var capital = require('to-capital-case')
var constant = require('to-constant-case')
var dot = require('to-dot-case')
var none = require('to-no-case')
var pascal = require('to-pascal-case')
var sentence = require('to-sentence-case')
var slug = require('to-slug-case')
var snake = require('to-snake-case')
var space = require('to-space-case')
var title = require('to-title-case')

@@ -18,3 +18,3 @@ /**

exports.camel = camel;
exports.camel = camel

@@ -25,3 +25,3 @@ /**

exports.pascal = pascal;
exports.pascal = pascal

@@ -32,3 +32,3 @@ /**

exports.dot = dot;
exports.dot = dot

@@ -39,3 +39,3 @@ /**

exports.slug = slug;
exports.slug = slug

@@ -46,3 +46,3 @@ /**

exports.snake = snake;
exports.snake = snake

@@ -53,3 +53,3 @@ /**

exports.space = space;
exports.space = space

@@ -60,3 +60,3 @@ /**

exports.constant = constant;
exports.constant = constant

@@ -67,3 +67,3 @@ /**

exports.capital = capital;
exports.capital = capital

@@ -74,3 +74,3 @@ /**

exports.title = title;
exports.title = title

@@ -81,3 +81,3 @@ /**

exports.sentence = sentence;
exports.sentence = sentence

@@ -93,4 +93,4 @@ /**

exports.lower = function (string) {
return none(string).toLowerCase();
};
return none(string).toLowerCase()
}

@@ -106,4 +106,4 @@ /**

exports.upper = function (string) {
return none(string).toUpperCase();
};
return none(string).toUpperCase()
}

@@ -118,11 +118,11 @@ /**

exports.inverse = function (string) {
var chars = string.split('');
var chars = string.split('')
for (var i = 0, char; char = chars[i]; i++) {
if (!/[a-z]/i.test(char)) continue;
var upper = char.toUpperCase();
var lower = char.toLowerCase();
chars[i] = char == upper ? lower : upper;
if (!/[a-z]/i.test(char)) continue
var upper = char.toUpperCase()
var lower = char.toLowerCase()
chars[i] = char == upper ? lower : upper
}
return chars.join('');
};
return chars.join('')
}

@@ -133,2 +133,2 @@ /**

exports.none = none;
exports.none = none
var cases = require('./cases');
var cases = require('./cases')
/**
* Expose `determineCase`.
* Export `determineCase`.
*/
module.exports = exports = determineCase;
module.exports = exports = determineCase
/**
* Expose `cases`.
* Export `cases`.
*/
exports.cases = cases;
exports.cases = cases

@@ -25,7 +25,7 @@ /**

for (var key in cases) {
if (key == 'none') continue;
var convert = cases[key];
if (convert(string) == string) return key;
if (key == 'none') continue
var convert = cases[key]
if (convert(string) == string) return key
}
return null;
return null
}

@@ -41,11 +41,11 @@

exports.add = function(name, convert){
exports[name] = cases[name] = convert;
};
exports[name] = cases[name] = convert
}
/**
* Add all the `cases`.
* Export all the `cases`.
*/
for (var key in cases) {
exports.add(key, cases[key]);
}
exports.add(key, cases[key])
}
{
"name": "to-case",
"version": "2.0.0",
"description": "Simple case conversion and detection for strings.",
"repository": "git://github.com/ianstormtaylor/to-case.git",
"license": "MIT",
"version": "1.0.2",
"description": "Simple case conversion and detection for strings.",
"main": "lib/index.js",
"dependencies": {
"to-camel-case": "^1.0.0",
"to-capital-case": "^1.0.0",
"to-constant-case": "^1.0.0",
"to-dot-case": "^1.0.0",
"to-no-case": "^1.0.0",
"to-pascal-case": "^1.0.0",
"to-sentence-case": "^1.0.0",
"to-slug-case": "^1.0.0",
"to-snake-case": "^1.0.0",
"to-space-case": "^1.0.0",
"to-title-case": "^1.0.0"
},
"devDependencies": {
"mocha": "^2.3.4"
},
"keywords": [
"camel",
"camelcase",
"case",
"upper",
"uppercase",
"casing",
"lower",
"lowercase",
"pascal",
"pascalcase",
"sentence",
"sentencecase",
"slug",
"slugcase",
"snake",
"snakecase",
"string",
"title",
"titlecase",
"camel",
"camelcase",
"snake",
"snakecase"
],
"main": "lib/index.js",
"dependencies": {
"to-camel-case": "git+http://github.com/ianstormtaylor/to-camel-case#0.2.1",
"to-capital-case": "~0.1.1",
"to-sentence-case": "~0.1.1",
"to-pascal-case": "0.0.2",
"to-constant-case": "~0.1.2",
"to-snake-case": "~0.1.2",
"to-dot-case": "~0.1.2",
"to-slug-case": "~0.1.2",
"to-space-case": "~0.1.2",
"to-no-case": "~0.1.2",
"to-title-case": "~0.1.2"
},
"devDependencies": {
"mocha": "~1.15.1"
}
"upper",
"uppercase"
]
}

@@ -1,65 +0,91 @@

# to-case
Simple case detection and conversion for strings.
# to-case [![Build Status](https://travis-ci.org/ianstormtaylor/to-case.svg?branch=master)](https://travis-ci.org/ianstormtaylor/to-case)
Simple case conversion and detection for strings. Part of the series of case helpers. For the individual libraries see:
- [`to-camel-case`](https://github.com/ianstormtaylor/to-camel-case)
- [`to-constant-case`](https://github.com/ianstormtaylor/to-constant-case)
- [`to-capital-case`](https://github.com/ianstormtaylor/to-capital-case)
- [`to-dot-case`](https://github.com/ianstormtaylor/to-dot-case)
- [`to-no-case`](https://github.com/ianstormtaylor/to-no-case)
- [`to-pascal-case`](https://github.com/ianstormtaylor/to-pascal-case)
- [`to-sentence-case`](https://github.com/ianstormtaylor/to-sentence-case)
- [`to-slug-case`](https://github.com/ianstormtaylor/to-slug-case)
- [`to-snake-case`](https://github.com/ianstormtaylor/to-snake-case)
- [`to-space-case`](https://github.com/ianstormtaylor/to-space-case)
- [`to-title-case`](https://github.com/ianstormtaylor/to-title-case)
## Installation
$ component install ianstormtaylor/to-case
$ npm install to-case
```
$ npm install to-case
```
## Example
Case detection:
Case conversion:
```js
var Case = require('to-case');
var to = require('to-case')
Case('thisIsAString'); // "camel"
Case('This Is A String'); // "capital"
Case('THIS_IS_A_STRING'); // "constant"
Case('this.is.a.string'); // "dot"
Case('this is a string.'); // "lower"
Case('ThisIsAString'); // "pascal"
Case('This is a string.'); // "sentence"
Case('this-is-a-string'); // "slug"
Case('this_is_a_string'); // "snake"
Case('this is a string'); // "space"
Case('This Is a String'); // "title"
Case('THIS IS A STRING'); // "upper"
to.camel('what_the_heck') // "whatTheHeck"
to.capital('what the heck') // "What The Heck"
to.constant('whatTheHeck') // "WHAT_THE_HECK"
to.dot('whatTheHeck') // "what.the.heck"
to.inverse('whaT tHe HeCK') // "WHAt ThE HeCK"
to.lower('whatTheHeck') // "what the heck"
to.pascal('what.the.heck') // "WhatTheHeck"
to.sentence('WHAT THE HECK.') // "What the heck."
to.slug('whatTheHeck') // "what-the-heck"
to.snake('whatTheHeck') // "what_the_heck"
to.space('what.the.heck') // "what the heck"
to.title('what the heck') // "What the Heck"
to.upper('whatTheHeck') // "WHAT THE HECK"
```
Case conversion:
Case detection:
```js
var to = require('to-case');
var to = require('to-case')
to.camel('what_the_heck'); // "whatTheHeck"
to.capital('what the heck'); // "What The Heck"
to.constant('whatTheHeck'); // "WHAT_THE_HECK"
to.dot('whatTheHeck'); // "what.the.heck"
to.inverse('whaT tHe HeCK'); // "WHAt ThE HeCK"
to.lower('whatTheHeck'); // "what the heck"
to.pascal('what.the.heck'); // "WhatTheHeck"
to.sentence('WHAT THE HECK.'); // "What the heck."
to.slug('whatTheHeck'); // "what-the-heck"
to.snake('whatTheHeck'); // "what_the_heck"
to.space('what.the.heck'); // "what the heck"
to.title('what the heck'); // "What the Heck"
to.upper('whatTheHeck'); // "WHAT THE HECK"
to('thisIsAString') // "camel"
to('This Is A String') // "capital"
to('THIS_IS_A_STRING') // "constant"
to('this.is.a.string') // "dot"
to('this is a string.') // "lower"
to('ThisIsAString') // "pascal"
to('This is a string.') // "sentence"
to('this-is-a-string') // "slug"
to('this_is_a_string') // "snake"
to('this is a string') // "space"
to('This Is a String') // "title"
to('THIS IS A STRING') // "upper"
```
## API
### Case(string)
### to(string)
Determine the case of a `string`.
Determine the case of a `string`.
### Case[case]\(string\)
### to[case]\(string\)
Convert a `string` to a `case`.
Convert a `string` to a `case`.
### Case.add(name, converter)
### to.add(name, converter)
Add a case with the given `name` and a `converter` function.
Add a case with the given `name` and a `converter` function.
## License
MIT
The MIT License (MIT)
Copyright © 2016, Ian Storm Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc