Comparing version 1.1.4 to 1.2.0
{ | ||
"name": "node-caps", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "An easy-to-use module to capitalise an string or array", | ||
@@ -9,6 +9,49 @@ "module": "./src/esm/index.esm.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"lint": "prettier --write ." | ||
}, | ||
"author": "simp.", | ||
"license": "ISC" | ||
} | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-angular": "^11.0.0", | ||
"husky": "^4.3.0", | ||
"lint-staged": "^10.4.2", | ||
"prettier": "^2.1.2" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*{.js,.ts,.d.ts,.json}": "prettier --write ." | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-angular" | ||
], | ||
"rules": { | ||
"scope-case": [ | ||
2, | ||
"always", | ||
"pascal-case" | ||
], | ||
"type-enum": [ | ||
2, | ||
"always", | ||
[ | ||
"chore", | ||
"feat", | ||
"fix", | ||
"revert", | ||
"style", | ||
"test", | ||
"deps", | ||
"docs", | ||
"ci" | ||
] | ||
] | ||
} | ||
} | ||
} |
@@ -6,11 +6,12 @@ # node-caps | ||
# Explanation | ||
```js | ||
const Caps = require('node-caps'); | ||
Caps.def() /* Default, will only capitalise the first letter of the first word */ | ||
Caps.keep() /* Like Default, but will keep the rest normal */ | ||
Caps.all() /* All, will capitalise all words */ | ||
Caps.array() /* Array, like All but using an array */ | ||
Caps.sent() /* Captialises first word like Default, but capitalises every word after the dot */ | ||
Caps.dash() /* Like Array, but without using an array to split the elements, but an dash (-) */ | ||
Caps.reg() /* Converts an country name to the right capitalization */ | ||
const Caps = require("node-caps"); | ||
Caps.def(); /* Default, will only capitalise the first letter of the first word */ | ||
Caps.keep(); /* Like Default, but will keep the rest normal */ | ||
Caps.all(); /* All, will capitalise all words */ | ||
Caps.array(); /* Array, like All but using an array */ | ||
Caps.sent(); /* Captialises first word like Default, but capitalises every word after the dot */ | ||
Caps.dash(); /* Like Array, but without using an array to split the elements, but an dash (-) */ | ||
Caps.reg(); /* Converts an country name to the right capitalization */ | ||
``` | ||
@@ -21,56 +22,63 @@ | ||
**Default** | ||
```js | ||
const Caps = require('node-caps'); | ||
const Caps = require("node-caps"); | ||
// Or | ||
import Caps from 'node-caps'; | ||
import Caps from "node-caps"; | ||
Caps.def('hi There') /* Expected output: 'Hi there' */ | ||
Caps.def("hi There"); /* Expected output: 'Hi there' */ | ||
``` | ||
**Keep** | ||
```js | ||
const Caps = require('node-caps'); | ||
const Caps = require("node-caps"); | ||
// Or | ||
import Caps from 'node-caps'; | ||
import Caps from "node-caps"; | ||
Caps.def('hi There') /* Expected output: 'Hi There' */ | ||
Caps.def("hi There"); /* Expected output: 'Hi There' */ | ||
``` | ||
**All** | ||
```js | ||
const Caps = require('node-caps'); | ||
const Caps = require("node-caps"); | ||
// Or | ||
import Caps from 'node-caps'; | ||
import Caps from "node-caps"; | ||
Caps.all('hi there') /* Expected output: 'Hi There' */ | ||
Caps.all("hi there"); /* Expected output: 'Hi There' */ | ||
``` | ||
**Array** | ||
```js | ||
const Caps = require('node-caps'); | ||
const Caps = require("node-caps"); | ||
// Or | ||
import Caps from 'node-caps'; | ||
import Caps from "node-caps"; | ||
Caps.array(['hi', 'there']) /* Expected output: ['Hi', 'There'] */ | ||
Caps.array(["hi", "there"]); /* Expected output: ['Hi', 'There'] */ | ||
``` | ||
**Sent** | ||
```js | ||
const Caps = require('node-caps'); | ||
const Caps = require("node-caps"); | ||
// Or | ||
import Caps from 'node-caps'; | ||
import Caps from "node-caps"; | ||
Caps.array('hi. there') /* Expected output: 'Hi. There' */ | ||
Caps.array("hi. there"); /* Expected output: 'Hi. There' */ | ||
``` | ||
**Dash** | ||
```js | ||
const Caps = require('node-caps'); | ||
const Caps = require("node-caps"); | ||
// Or | ||
import Caps from 'node-caps'; | ||
import Caps from "node-caps"; | ||
Caps.dash('hi-there') /* Expected output: 'Hi-There' */ | ||
Caps.dash("hi-there"); /* Expected output: 'Hi-There' */ | ||
``` | ||
**Reg** | ||
```js | ||
@@ -86,3 +94,2 @@ const Caps = require('node-caps'); | ||
***Copyright (c) 2020 simp. & Salvage*** | ||
**_Copyright (c) 2020 simp. & Salvage_** |
@@ -1,10 +0,2 @@ | ||
import Caps from '../func'; | ||
export const { | ||
def, | ||
keep, | ||
all, | ||
array, | ||
sent, | ||
dash, | ||
reg | ||
} = Caps; | ||
import Caps from "../func"; | ||
export const { def, keep, all, array, sent, dash, reg } = Caps; |
module.exports = { | ||
def: (str) => { | ||
if (!str || typeof str !== 'string') throw new TypeError(`Parameter str must be typeof String, recieved type "${typeof str}"`); | ||
const first = str.search(/[a-zA-Z]/); | ||
return str.slice(0, first) + str.slice(first, first + 1).toUpperCase() + str.slice(first + 1).toLowerCase(); | ||
}, | ||
keep: (str) => { | ||
if (!str || typeof str !== 'string') throw new TypeError(`Parameter str must be typeof String, recieved type ${typeof str}`) | ||
const first = str.search(/[a-zA-Z]/); | ||
return str.slice(0, first) + str.slice(first, first + 1).toUpperCase() + str.slice(first + 1); | ||
}, | ||
all: (str) => { | ||
if (!str || typeof str !== 'string') throw new TypeError(`Parameter str must be typeof String, recieved type "${typeof str}"`); | ||
return str.split(' ').map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return s.slice(0, first) + s.slice(first, first + 1).toUpperCase() + s.slice(first + 1); | ||
}).join(' ') | ||
}, | ||
array: (str) => { | ||
if (!str || typeof str[0] !== 'string' && str.length > 1) throw new TypeError(`Parameter str must be typeof Array, recieved type "${typeof str}"`); | ||
try { | ||
return str.map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return s.slice(0, first) + s.slice(first, first + 1).toUpperCase() + s.slice(first + 1); | ||
}); | ||
} catch (err){ | ||
let error = new TypeError(`Parameter str must be typeof Array, recieved type ${typeof str}`); | ||
throw error; | ||
} | ||
}, | ||
sent: (str) => { | ||
if (!str || typeof str !== 'string') throw new TypeError(`Parameter str must be typeof String, recieved type "${typeof str}"`); | ||
return ((str.split('.')).map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return s.slice(0, first) + s.slice(first, first + 1).toUpperCase() + s.slice(first + 1); | ||
}).join('.')) | ||
}, | ||
dash: (str) => { | ||
if (!str || typeof str !== 'string') throw new TypeError(`Parameter str must be typeof String, recieved type "${typeof str}"`); | ||
return ((str.split('-')).map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return s.slice(0, first) + s.slice(first, first + 1).toUpperCase() + s.slice(first + 1); | ||
}).join('.')) | ||
}, | ||
reg: (str) =>{ | ||
if(str.match(/-/) && str.split('-')[1].length < 3) return ((str.split('-')).map((s, i) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
if(i > 0) return s.toUpperCase(); | ||
else return s.slice(first, first+1).toUpperCase() + s.slice(first+1); | ||
}).join('-')); | ||
return str.split(' ').map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return s.slice(0, first) + s.slice(first, first + 1).toUpperCase() + s.slice(first + 1); | ||
}).join(' ') | ||
}, | ||
} | ||
def: (str) => { | ||
if (!str || typeof str !== "string") | ||
throw new TypeError( | ||
`Parameter str must be typeof String, recieved type "${typeof str}"` | ||
); | ||
const first = str.search(/[a-zA-Z]/); | ||
return ( | ||
str.slice(0, first) + | ||
str.slice(first, first + 1).toUpperCase() + | ||
str.slice(first + 1).toLowerCase() | ||
); | ||
}, | ||
keep: (str) => { | ||
if (!str || typeof str !== "string") | ||
throw new TypeError( | ||
`Parameter str must be typeof String, recieved type ${typeof str}` | ||
); | ||
const first = str.search(/[a-zA-Z]/); | ||
return ( | ||
str.slice(0, first) + | ||
str.slice(first, first + 1).toUpperCase() + | ||
str.slice(first + 1) | ||
); | ||
}, | ||
all: (str) => { | ||
if (!str || typeof str !== "string") | ||
throw new TypeError( | ||
`Parameter str must be typeof String, recieved type "${typeof str}"` | ||
); | ||
return str | ||
.split(" ") | ||
.map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return ( | ||
s.slice(0, first) + | ||
s.slice(first, first + 1).toUpperCase() + | ||
s.slice(first + 1) | ||
); | ||
}) | ||
.join(" "); | ||
}, | ||
array: (str) => { | ||
if (!str || (typeof str[0] !== "string" && str.length > 1)) | ||
throw new TypeError( | ||
`Parameter str must be typeof Array, recieved type "${typeof str}"` | ||
); | ||
try { | ||
return str.map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return ( | ||
s.slice(0, first) + | ||
s.slice(first, first + 1).toUpperCase() + | ||
s.slice(first + 1) | ||
); | ||
}); | ||
} catch (err) { | ||
let error = new TypeError( | ||
`Parameter str must be typeof Array, recieved type ${typeof str}` | ||
); | ||
throw error; | ||
} | ||
}, | ||
sent: (str) => { | ||
if (!str || typeof str !== "string") | ||
throw new TypeError( | ||
`Parameter str must be typeof String, recieved type "${typeof str}"` | ||
); | ||
return str | ||
.split(".") | ||
.map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return ( | ||
s.slice(0, first) + | ||
s.slice(first, first + 1).toUpperCase() + | ||
s.slice(first + 1) | ||
); | ||
}) | ||
.join("."); | ||
}, | ||
dash: (str) => { | ||
if (!str || typeof str !== "string") | ||
throw new TypeError( | ||
`Parameter str must be typeof String, recieved type "${typeof str}"` | ||
); | ||
return str | ||
.split("-") | ||
.map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return ( | ||
s.slice(0, first) + | ||
s.slice(first, first + 1).toUpperCase() + | ||
s.slice(first + 1) | ||
); | ||
}) | ||
.join("."); | ||
}, | ||
reg: (str) => { | ||
if (str.match(/-/) && str.split("-")[1].length < 3) | ||
return str | ||
.split("-") | ||
.map((s, i) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
if (i > 0) return s.toUpperCase(); | ||
else | ||
return s.slice(first, first + 1).toUpperCase() + s.slice(first + 1); | ||
}) | ||
.join("-"); | ||
return str | ||
.split(" ") | ||
.map((s) => { | ||
const first = s.search(/[a-zA-Z]/); | ||
return ( | ||
s.slice(0, first) + | ||
s.slice(first, first + 1).toUpperCase() + | ||
s.slice(first + 1) | ||
); | ||
}) | ||
.join(" "); | ||
}, | ||
}; |
@@ -1,5 +0,5 @@ | ||
const Caps = require('./func/index'); | ||
const Caps = require("./func/index"); | ||
module.exports = { | ||
...Caps, | ||
version: require('../package.json').version | ||
} | ||
...Caps, | ||
version: require("../package.json").version, | ||
}; |
@@ -8,2 +8,2 @@ declare function def(str: string): string; | ||
declare function reg(str: string): string; | ||
export { def, array, keep, all, sent, dash, reg }; | ||
export { def, array, keep, all, sent, dash, reg }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
7893
136
1
93
0
5