This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+24 -11
View File
@@ -2,9 +2,13 @@
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Bundle size][bundlephobia-image]][bundlephobia-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Greenkeeper badge](https://badges.greenkeeper.io/blakeembrey/no-case.svg)](https://greenkeeper.io/)
> Transform into a lower cased string with spaces between words.
Transform a string to lower space cased. Optional locale and replacement character supported.
Supports Unicode (non-ASCII characters) and non-string entities, such as objects with a `toString` property, numbers and booleans. Empty values (`null` and `undefined`) will result in an empty string.
## Installation
@@ -14,16 +18,23 @@ npm install no-case --save
## Usage
```js
import { noCase } from "no-case";
```javascript
var noCase = require('no-case')
noCase("string"); //=> "string"
noCase("dot.case"); //=> "dot case"
noCase("PascalCase"); //=> "pascal case"
noCase("version 1.2.10"); //=> "version 1 2 10"
noCase(null) //=> ""
noCase('string') //=> "string"
noCase('dot.case') //=> "dot case"
noCase('camelCase') //=> "camel case"
noCase('Beyoncé Knowles') //=> "beyoncé knowles"
noCase('A STRING', 'tr') //=> "a strıng"
noCase('HELLO WORLD!', null, '_') //=> "hello_world"
```
The function also accepts [`options`](https://github.com/blakeembrey/change-case#options).
## Typings
Includes a [TypeScript definition](no-case.d.ts).
## License
@@ -33,5 +44,7 @@ MIT
[npm-url]: https://npmjs.org/package/no-case
[downloads-image]: https://img.shields.io/npm/dm/no-case.svg?style=flat
[downloads-url]: https://npmjs.org/package/no-case
[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/no-case.svg
[bundlephobia-url]: https://bundlephobia.com/result?p=no-case
[travis-image]: https://img.shields.io/travis/blakeembrey/no-case.svg?style=flat
[travis-url]: https://travis-ci.org/blakeembrey/no-case
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/no-case.svg?style=flat
[coveralls-url]: https://coveralls.io/r/blakeembrey/no-case?branch=master
+3
View File
@@ -0,0 +1,3 @@
declare function noCase (value: string, locale?: string, replacement?: string): string;
export = noCase;
+40
View File
@@ -0,0 +1,40 @@
var lowerCase = require('lower-case')
var NON_WORD_REGEXP = require('./vendor/non-word-regexp')
var CAMEL_CASE_REGEXP = require('./vendor/camel-case-regexp')
var CAMEL_CASE_UPPER_REGEXP = require('./vendor/camel-case-upper-regexp')
/**
* Sentence case a string.
*
* @param {string} str
* @param {string} locale
* @param {string} replacement
* @return {string}
*/
module.exports = function (str, locale, replacement) {
if (str == null) {
return ''
}
replacement = typeof replacement !== 'string' ? ' ' : replacement
function replace (match, index, value) {
if (index === 0 || index === (value.length - match.length)) {
return ''
}
return replacement
}
str = String(str)
// Support camel case ("camelCase" -> "camel Case").
.replace(CAMEL_CASE_REGEXP, '$1 $2')
// Support odd camel case ("CAMELCase" -> "CAMEL Case").
.replace(CAMEL_CASE_UPPER_REGEXP, '$1 $2')
// Remove all non-word characters and replace with a single space.
.replace(NON_WORD_REGEXP, replace)
// Lower case the entire string.
return lowerCase(str, locale)
}
+40 -69
View File
@@ -1,114 +1,85 @@
{
"_args": [
[
"no-case@3.0.3",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"no-case@2.3.2",
"/home/node/nuxt"
]
],
"_from": "no-case@3.0.3",
"_id": "no-case@3.0.3",
"_from": "no-case@2.3.2",
"_id": "no-case@2.3.2",
"_inBundle": false,
"_integrity": "sha512-ehY/mVQCf9BL0gKfsJBvFJen+1V//U+0HQMPrWct40ixE4jnv0bfvxDbWtAHL9EcaPEOJHVVYKoQn1TlZUB8Tw==",
"_integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==",
"_location": "/no-case",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "no-case@3.0.3",
"raw": "no-case@2.3.2",
"name": "no-case",
"escapedName": "no-case",
"rawSpec": "3.0.3",
"rawSpec": "2.3.2",
"saveSpec": null,
"fetchSpec": "3.0.3"
"fetchSpec": "2.3.2"
},
"_requiredBy": [
"/dot-case",
"/pascal-case"
"/camel-case",
"/param-case"
],
"_resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.3.tgz",
"_spec": "3.0.3",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
"_spec": "2.3.2",
"_where": "/home/node/nuxt",
"author": {
"name": "Blake Embrey",
"email": "hello@blakeembrey.com",
"url": "http://blakeembrey.me"
},
"bugs": {
"url": "https://github.com/blakeembrey/change-case/issues"
"url": "https://github.com/blakeembrey/no-case/issues"
},
"dependencies": {
"lower-case": "^2.0.1",
"tslib": "^1.10.0"
"lower-case": "^1.1.1"
},
"description": "Transform into a lower cased string with spaces between words",
"description": "Remove case from a string",
"devDependencies": {
"@size-limit/preset-small-lib": "^2.2.1",
"@types/jest": "^24.0.23",
"@types/node": "^12.12.14",
"jest": "^24.9.0",
"rimraf": "^3.0.0",
"ts-jest": "^24.2.0",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"typescript": "^3.7.2"
"chai": "^4.0.2",
"istanbul": "^0.4.3",
"jsesc": "^2.2.0",
"mocha": "^3.0.0",
"standard": "^10.0.2",
"xregexp": "^3.1.1"
},
"files": [
"dist/",
"dist.es2015/",
"no-case.js",
"no-case.d.ts",
"vendor",
"LICENSE"
],
"gitHead": "1c1377a692d328ae01221b2a1532bade38e1eaa3",
"homepage": "https://github.com/blakeembrey/change-case/tree/master/packages/no-case#readme",
"jest": {
"roots": [
"<rootDir>/src/"
],
"transform": {
"\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
},
"jsnext:main": "dist.es2015/index.js",
"homepage": "https://github.com/blakeembrey/no-case",
"keywords": [
"no",
"case",
"space",
"lower",
"convert",
"transform"
"trim"
],
"license": "MIT",
"main": "dist/index.js",
"module": "dist.es2015/index.js",
"main": "no-case.js",
"name": "no-case",
"repository": {
"type": "git",
"url": "git://github.com/blakeembrey/change-case.git"
"url": "git://github.com/blakeembrey/no-case.git"
},
"scripts": {
"build": "rimraf dist/ dist.es2015/ && tsc && tsc -P tsconfig.es2015.json",
"lint": "tslint \"src/**/*\" --project tsconfig.json",
"prepare": "npm run build",
"size": "size-limit",
"specs": "jest --coverage",
"test": "npm run build && npm run lint && npm run specs"
"build": "node build.js",
"lint": "standard",
"test": "npm run lint && npm run test-cov",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec --bail"
},
"sideEffects": false,
"size-limit": [
{
"path": "dist/index.js",
"limit": "550 B"
}
],
"typings": "dist/index.d.ts",
"version": "3.0.3"
"standard": {
"ignore": [
"coverage/**"
]
},
"typings": "no-case.d.ts",
"version": "2.3.2"
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long