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

string-wks

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

string-wks - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "string-wks",
"version": "1.0.1",
"version": "1.0.2",
"description": "Some string manipulation functions that I need to use commonly",

@@ -5,0 +5,0 @@ "main": "string.js",

@@ -1,7 +0,15 @@

//Capitalize first letter: HellO USER => Hello user
exports.capitalize = function (string) {
//exporting functions
exports.capitalize = capitalize;
exports.noSpace = noSpace;
exports.escape = escape;
exports.simplify = simplify;
exports.kebab = kebab;
//capitalize first letter of a string and turn others to small caps. capitalize("hello") > Hello
function capitalize(str) {
//crop fist letter
const firstLetter = string.substring(0, 1);
const firstLetter = str.substring(0, 1);
//crop the other letters expect for the first one
const otherLetters = string.substring(1, string.length);
const otherLetters = str.substring(1, str.length);
//capitalize first Letter and assemble it with lowercase other Letters

@@ -11,15 +19,25 @@ const finalString = firstLetter.toUpperCase() + otherLetters.toLowerCase();

return finalString;
};
}
//simplify: HELLo user30,c => hellouser30c
exports.simplify = function(string) {
//regular expression to replaces all non-alphanumeric characters.
const regExp = /[^a-z0-9]/gi;
//using the regExp
const cleaned = string.replace(regExp, "");
//removing spaces from the cleaned string
const finall = cleaned.replace(" ", "");
//return the finall version
return finall;
//noSpace. remove all spaces in your noSpace("He ll o") > "Hello"
function noSpace(str) {
return str.replace(" ", "");
}
//remove all non-alphanumeric characters from string. escape("hello&#9!_WORLD") >hello9WORLD
function escape(str) {
//regular expression
const regExp = /[^a-z0-9]/gi;
return str.replace(regExp, "");
}
//simplify
function simplify(str){
let text = str;
text = escape(text);
text = noSpace(text);
return text.toLowerCase();
}
//kebab case
function kebab(str) {
return escape(str).toLowerCase().replace(" ", "-");
}
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