sec commit
This commit is contained in:
26
node_modules/tiny-case/README.md
generated
vendored
Normal file
26
node_modules/tiny-case/README.md
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# tiny-case
|
||||
|
||||
Extremely minimal string casing utilities that mimic most of lodash's casing behavior, e.g.
|
||||
numbers are considered seperate "words".
|
||||
|
||||
```sh
|
||||
npm i tiny-case
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {
|
||||
camelCase,
|
||||
pascalCase,
|
||||
snakeCase,
|
||||
kebabCase,
|
||||
titleCase,
|
||||
sentenceCase,
|
||||
words,
|
||||
upperFirst,
|
||||
} from 'tiny-case'
|
||||
|
||||
words('hi-there john') // ['hi', 'there', 'john']
|
||||
words(' 1ApplePlease ') // ['1', 'Apple', 'Please']
|
||||
```
|
||||
15
node_modules/tiny-case/index.d.ts
generated
vendored
Normal file
15
node_modules/tiny-case/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export function words(str: string): string[]
|
||||
|
||||
export function upperFirst(str: string): string
|
||||
|
||||
export function camelCase(str: string): string
|
||||
|
||||
export function pascalCase(str: string): string
|
||||
|
||||
export function snakeCase(str: string): string
|
||||
|
||||
export function kebabCase(str: string): string
|
||||
|
||||
export function sentenceCase(str: string): string
|
||||
|
||||
export function titleCase(str: string): string
|
||||
39
node_modules/tiny-case/index.js
generated
vendored
Normal file
39
node_modules/tiny-case/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
const reWords = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g
|
||||
|
||||
const words = (str) => str.match(reWords) || []
|
||||
|
||||
const upperFirst = (str) => str[0].toUpperCase() + str.slice(1)
|
||||
|
||||
const join = (str, d) => words(str).join(d).toLowerCase()
|
||||
|
||||
const camelCase = (str) =>
|
||||
words(str).reduce(
|
||||
(acc, next) =>
|
||||
`${acc}${
|
||||
!acc
|
||||
? next.toLowerCase()
|
||||
: next[0].toUpperCase() + next.slice(1).toLowerCase()
|
||||
}`,
|
||||
'',
|
||||
)
|
||||
|
||||
const pascalCase = (str) => upperFirst(camelCase(str))
|
||||
|
||||
const snakeCase = (str) => join(str, '_')
|
||||
|
||||
const kebabCase = (str) => join(str, '-')
|
||||
|
||||
const sentenceCase = (str) => upperFirst(join(str, ' '))
|
||||
|
||||
const titleCase = (str) => words(str).map(upperFirst).join(' ')
|
||||
|
||||
module.exports = {
|
||||
words,
|
||||
upperFirst,
|
||||
camelCase,
|
||||
pascalCase,
|
||||
snakeCase,
|
||||
kebabCase,
|
||||
sentenceCase,
|
||||
titleCase,
|
||||
}
|
||||
13
node_modules/tiny-case/package.json
generated
vendored
Normal file
13
node_modules/tiny-case/package.json
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "tiny-case",
|
||||
"version": "1.0.3",
|
||||
"description": "Tiny Casing utils",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jquense/tiny-case.git"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"author": "Jason Quense",
|
||||
"license": "MIT"
|
||||
}
|
||||
82
node_modules/tiny-case/test.js
generated
vendored
Normal file
82
node_modules/tiny-case/test.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
const assert = require('assert')
|
||||
const t = require('.')
|
||||
|
||||
CamelCase: {
|
||||
;[
|
||||
['hi there', 'hiThere'],
|
||||
['hi-there', 'hiThere'],
|
||||
['hi_there_1', 'hiThere1'],
|
||||
[' hi_there ', 'hiThere'],
|
||||
['1ApplePlease', '1ApplePlease'],
|
||||
['CON_STAT', 'conStat'],
|
||||
['CaseStatus', 'caseStatus'],
|
||||
].forEach(([input, expected]) => {
|
||||
assert.strictEqual(
|
||||
t.camelCase(input),
|
||||
expected,
|
||||
`${t.camelCase(input)} !== ${expected}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
PascalCase: {
|
||||
;[
|
||||
['hi there', 'HiThere'],
|
||||
['hi-there', 'HiThere'],
|
||||
['hi_there_1', 'HiThere1'],
|
||||
[' hi_there ', 'HiThere'],
|
||||
['1ApplePlease', '1ApplePlease'],
|
||||
].forEach(([input, expected]) => {
|
||||
assert.strictEqual(
|
||||
t.pascalCase(input),
|
||||
expected,
|
||||
`${t.pascalCase(input)} !== ${expected}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
SnakeCase: {
|
||||
;[
|
||||
['hi there', 'hi_there'],
|
||||
['hi-there', 'hi_there'],
|
||||
['hi_there_1', 'hi_there_1'],
|
||||
[' hi_there ', 'hi_there'],
|
||||
['1ApplePlease', '1_apple_please'],
|
||||
].forEach(([input, expected]) => {
|
||||
assert.strictEqual(
|
||||
t.snakeCase(input),
|
||||
expected,
|
||||
`${t.snakeCase(input)} !== ${expected}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
SentenceCase: {
|
||||
;[
|
||||
['hi there', 'Hi there'],
|
||||
['hi-There', 'Hi there'],
|
||||
['hi_there_1', 'Hi there 1'],
|
||||
[' hi_there ', 'Hi there'],
|
||||
].forEach(([input, expected]) => {
|
||||
assert.strictEqual(
|
||||
t.sentenceCase(input),
|
||||
expected,
|
||||
`${t.sentenceCase(input)} !== ${expected}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
TitleCase: {
|
||||
;[
|
||||
['hi there', 'Hi There'],
|
||||
['hi-There', 'Hi There'],
|
||||
['hi_there_1', 'Hi There 1'],
|
||||
[' hi_there ', 'Hi There'],
|
||||
].forEach(([input, expected]) => {
|
||||
assert.strictEqual(
|
||||
t.titleCase(input),
|
||||
expected,
|
||||
`${t.titleCase(input)} !== ${expected}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
1
node_modules/tiny-case/tsconfig.json
generated
vendored
Normal file
1
node_modules/tiny-case/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
Reference in New Issue
Block a user