Socket
Socket
Sign inDemoInstall

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 2.0.0 to 2.0.1

15

index.js

@@ -9,9 +9,4 @@ /**

export function matchCasing(value, base) {
var index = -1
/** @type {string} */
var char
/** @type {string} */
var rest
/** @type {boolean} */
var cap
let index = -1
let cap = false

@@ -27,6 +22,6 @@ if (base.toUpperCase() === base) {

while (++index < base.length) {
char = base.charAt(index)
const char = base.charAt(index)
if (char.toUpperCase() !== char.toLowerCase()) {
rest = base.slice(index + 1)
const rest = base.slice(index + 1)
cap = char === char.toUpperCase() && rest === rest.toLowerCase()

@@ -41,3 +36,3 @@ break

while (++index < value.length) {
char = value.charAt(index).toUpperCase()
const char = value.charAt(index).toUpperCase()

@@ -44,0 +39,0 @@ if (char !== char.toLowerCase()) {

{
"name": "match-casing",
"version": "2.0.0",
"version": "2.0.1",
"description": "Match the case of `value` to that of `base`",

@@ -34,4 +34,4 @@ "license": "MIT",

"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",

@@ -41,10 +41,10 @@ "tape": "^5.0.0",

"typescript": "^4.0.0",
"xo": "^0.38.0"
"xo": "^0.46.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"prepublishOnly": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"

@@ -61,7 +61,3 @@ },

"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},

@@ -76,4 +72,5 @@ "remarkConfig": {

"detail": true,
"strict": true
"strict": true,
"ignoreCatch": true
}
}

@@ -10,9 +10,34 @@ # match-casing

## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`matchCasing(value, base)`](#matchcasingvalue-base)
* [Types](#types)
* [Algorithm](#algorithm)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package matches the case (lowercase, uppercase, capitalized) of a string to
that of another string.
## When should I use this?
This package is useful if a user wrote some word, and you want to suggest a
replacement, and want to make sure that the suggestion matches that of the
original.
## Install
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
[npm][]:
```sh

@@ -22,2 +47,16 @@ npm install match-casing

In Deno with [Skypack][]:
```js
import {matchCasing} from 'https://cdn.skypack.dev/match-casing@2?dts'
```
In browsers with [Skypack][]:
```html
<script type="module">
import {matchCasing} from 'https://cdn.skypack.dev/match-casing@2?min'
</script>
```
## Use

@@ -49,3 +88,3 @@

This package exports the following identifiers: `matchCasing`.
This package exports the following identifier: `matchCasing`.
There is no default export.

@@ -57,2 +96,7 @@

## Types
This package is fully typed with [TypeScript][].
There are no extra exported types.
## Algorithm

@@ -67,5 +111,30 @@

The third case, where `value` takes on a capitalized, deals with initial
non-alphabetical characters as expected.
The third case deals with initial non-alphabetical characters as expected.
## Compatibility
This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
It also works in Deno and modern browsers.
## Security
This package is safe.
## Related
* [`words/emoji-emotion`](https://github.com/words/emoji-emotion)
— list of emoji rated for valence
* [`wooorm/emoticon`](https://github.com/wooorm/emoticon)
— info on ASCII emoticons
* [`wooorm/strip-skin-tone`](https://github.com/wooorm/strip-skin-tone)
— Strip skin-tones from emoji
* [`wooorm.com/checkmoji`](https://wooorm.com/checkmoji/)
— Check emoji across platforms
## Contribute
Yes please!
See [How to Contribute to Open Source][contribute].
## License

@@ -95,4 +164,12 @@

[skypack]: https://www.skypack.dev
[license]: license
[author]: https://wooorm.com
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[typescript]: https://www.typescriptlang.org
[contribute]: https://opensource.guide/how-to-contribute/
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