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

match-casing

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

match-casing - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

license

42

index.js

@@ -1,31 +0,31 @@

'use strict';
'use strict'
module.exports = casing;
module.exports = casing
function casing(value, base) {
var length;
var index;
var char;
var rest;
var cap;
var length
var index
var char
var rest
var cap
if (base.toUpperCase() === base) {
return value.toUpperCase();
return value.toUpperCase()
}
if (base.toLowerCase() === base) {
return value.toLowerCase();
return value.toLowerCase()
}
length = base.length;
index = -1;
length = base.length
index = -1
while (++index < length) {
char = base.charAt(index);
char = base.charAt(index)
if (char.toUpperCase() !== char.toLowerCase()) {
rest = base.slice(index + 1);
rest = base.slice(index + 1)
cap = char === char.toUpperCase() && rest === rest.toLowerCase();
break;
cap = char === char.toUpperCase() && rest === rest.toLowerCase()
break
}

@@ -35,10 +35,12 @@ }

if (cap) {
length = value.length;
index = -1;
length = value.length
index = -1
while (++index < length) {
char = value.charAt(index).toUpperCase();
char = value.charAt(index).toUpperCase()
if (char !== char.toLowerCase()) {
return value.slice(0, index) + char + value.slice(index + 1).toLowerCase();
return (
value.slice(0, index) + char + value.slice(index + 1).toLowerCase()
)
}

@@ -48,3 +50,3 @@ }

return value;
return value
}
{
"name": "match-casing",
"version": "1.0.1",
"version": "1.0.2",
"description": "Match the case of `value` to that of `base`",

@@ -14,5 +14,5 @@ "license": "MIT",

"bugs": "https://github.com/wooorm/match-casing/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],

@@ -24,19 +24,19 @@ "files": [

"devDependencies": {
"browserify": "^14.1.0",
"esmangle": "^1.0.1",
"nyc": "^11.0.0",
"remark-cli": "^4.0.0",
"remark-preset-wooorm": "^3.0.0",
"browserify": "^16.0.0",
"nyc": "^14.0.0",
"prettier": "^1.12.1",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.0.0",
"xo": "^0.18.0"
"tinyify": "^2.5.0",
"xo": "^0.24.0"
},
"scripts": {
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js --bare -s matchCasing > match-casing.js",
"build-mangle": "esmangle < match-casing.js > match-casing.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"build-bundle": "browserify . -s matchCasing -o match-casing.js",
"build-mangle": "browserify . -s matchCasing -p tinyify -o match-casing.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
"test": "npm run format && npm run build && npm run test-coverage"
},

@@ -49,4 +49,12 @@ "nyc": {

},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"space": true,
"prettier": true,
"esnext": false,

@@ -53,0 +61,0 @@ "ignores": [

@@ -1,3 +0,8 @@

# match-casing [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
# match-casing
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
Match the case of `value` to that of `base`.

@@ -16,21 +21,21 @@

```js
var casing = require('match-casing');
var casing = require('match-casing')
casing('foo', 'BAZ'); //=> 'FOO'
casing('foo', 'Baz'); //=> 'Foo'
casing('foo', 'baz'); //=> 'foo'
casing('foo', 'BaZ'); //=> 'foo'
casing('foo', 'BAZ') // => 'FOO'
casing('foo', 'Baz') // => 'Foo'
casing('foo', 'baz') // => 'foo'
casing('foo', 'BaZ') // => 'foo'
casing('FOO', 'BAZ'); //=> 'FOO'
casing('FOO', 'Baz'); //=> 'Foo'
casing('FOO', 'baz'); //=> 'foo'
casing('FOO', 'BaZ'); //=> 'FOO'
casing('FOO', 'BAZ') // => 'FOO'
casing('FOO', 'Baz') // => 'Foo'
casing('FOO', 'baz') // => 'foo'
casing('FOO', 'BaZ') // => 'FOO'
casing('Foo', 'BAZ'); //=> 'FOO'
casing('Foo', 'Baz'); //=> 'Foo'
casing('Foo', 'baz'); //=> 'foo'
casing('Foo', 'BaZ'); //=> 'Foo'
casing('Foo', 'BAZ') // => 'FOO'
casing('Foo', 'Baz') // => 'Foo'
casing('Foo', 'baz') // => 'foo'
casing('Foo', 'BaZ') // => 'Foo'
casing('’90S', '’twas'); //=> '’90s'
casing('’N’', 'a'); //=> '’n’'
casing('’90S', '’twas') // => '’90s'
casing('’N’', 'a') // => '’n’'
```

@@ -62,14 +67,22 @@

[travis-badge]: https://img.shields.io/travis/wooorm/match-casing.svg
[build-badge]: https://img.shields.io/travis/wooorm/match-casing.svg
[travis]: https://travis-ci.org/wooorm/match-casing
[build]: https://travis-ci.org/wooorm/match-casing
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/match-casing.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/match-casing.svg
[codecov]: https://codecov.io/github/wooorm/match-casing
[coverage]: https://codecov.io/github/wooorm/match-casing
[downloads-badge]: https://img.shields.io/npm/dm/match-casing.svg
[downloads]: https://www.npmjs.com/package/match-casing
[size-badge]: https://img.shields.io/bundlephobia/minzip/match-casing.svg
[size]: https://bundlephobia.com/result?p=match-casing
[npm-install]: https://docs.npmjs.com/cli/install
[license]: LICENSE
[license]: license
[author]: http://wooorm.com
[author]: https://wooorm.com
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