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

microsoft-capitalize

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

microsoft-capitalize - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [1.0.3](https://github.com/Kikobeats/microsoft-capitalize/compare/v1.0.2...v1.0.3) (2020-08-01)
### Bug Fixes
* ensure first word is capitalized ([18b9eef](https://github.com/Kikobeats/microsoft-capitalize/commit/18b9eef4eac0faa5d714d89446da27e2f2375357))
### [1.0.2](https://github.com/Kikobeats/microsoft-capitalize/compare/v1.0.1...v1.0.2) (2020-07-24)

@@ -7,0 +14,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://nicedoc.io/Kikobeats/microsoft-capitalize",
"version": "1.0.2",
"version": "1.0.3",
"main": "src/index.js",

@@ -8,0 +8,0 @@ "author": {

'use strict'
const capitalize = str =>
str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()
const head = str => str.charAt(0)
const tail = str => str.slice(1)
const upperHead = str => head(str).toUpperCase()
const capitalize = str => upperHead(str) + tail(str).toLowerCase()
const isUpperCaseWord = str =>

@@ -18,9 +23,14 @@ str.split('').every(letter => letter === letter.toUpperCase())

// respect special words
exceptions.forEach(word => {
const re = new RegExp(`\\b(?:${word})\\b`, 'gi')
if (re.test(str)) {
title = title.replace(re, word)
}
})
if (exceptions.length) {
exceptions.forEach(word => {
const re = new RegExp(`\\b(?:${word})\\b`, 'gi')
if (re.test(str)) {
title = title.replace(re, word)
}
})
// still be sure first word is capitalized even it's an exception
title = upperHead(title) + tail(title)
}
// respect uppercase words

@@ -27,0 +37,0 @@ title = title.split(' ')

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