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

decamelize

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decamelize - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

20

index.js
'use strict';
module.exports = function (str, sep) {
if (typeof str !== 'string') {
const xRegExp = require('xregexp');
module.exports = (text, separator) => {
if (typeof text !== 'string') {
throw new TypeError('Expected a string');
}
sep = typeof sep === 'undefined' ? '_' : sep;
separator = typeof separator === 'undefined' ? '_' : separator;
return str
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
const regex1 = xRegExp('([\\p{Ll}\\d])(\\p{Lu})', 'g');
const regex2 = xRegExp('(\\p{Lu}+)(\\p{Lu}[\\p{Ll}\\d]+)', 'g');
return text
// TODO: Use this instead of `xregexp` when targeting Node.js 10:
// .replace(/([\p{Lowercase_Letter}\d])(\p{Uppercase_Letter})/gu, `$1${separator}$2`)
// .replace(/(\p{Lowercase_Letter}+)(\p{Uppercase_Letter}[\p{Lowercase_Letter}\d]+)/gu, `$1${separator}$2`)
.replace(regex1, `$1${separator}$2`)
.replace(regex2, `$1${separator}$2`)
.toLowerCase();
};
{
"name": "decamelize",
"version": "1.2.0",
"description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow",
"license": "MIT",
"repository": "sindresorhus/decamelize",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"decamelize",
"decamelcase",
"camelcase",
"lowercase",
"case",
"dash",
"hyphen",
"string",
"str",
"text",
"convert"
],
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "decamelize",
"version": "2.0.0",
"description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow",
"license": "MIT",
"repository": "sindresorhus/decamelize",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"decamelize",
"decamelcase",
"camelcase",
"lowercase",
"case",
"dash",
"hyphen",
"string",
"str",
"text",
"convert"
],
"dependencies": {
"xregexp": "4.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}

@@ -10,3 +10,3 @@ # decamelize [![Build Status](https://travis-ci.org/sindresorhus/decamelize.svg?branch=master)](https://travis-ci.org/sindresorhus/decamelize)

```
$ npm install --save decamelize
$ npm install decamelize
```

@@ -13,0 +13,0 @@

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