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

uniformize

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniformize - npm Package Compare versions

Comparing version 1.0.8 to 2.0.0

dist/types.d.ts

77

dist/index.js
"use strict";
// src/index.ts
Object.defineProperty(String.prototype, "removeAccents", {
value: function() {
return this.normalize("NFD").replace(/\p{Diacritic}/gu, "");
},
enumerable: false
});
Object.defineProperty(String.prototype, "standardize", {
value: function(noTrim) {
if (!noTrim) return this.removeAccents().toLowerCase();
return this.removeAccents().toLowerCase().trim();
},
enumerable: false
});
Object.defineProperty(String.prototype, "toTitle", {
value: function(toLowerCase) {
const text = toLowerCase ? this.toLowerCase() : this;
return text.charAt(0).toUpperCase() + text.slice(1);
},
enumerable: false
});
Object.defineProperty(String.prototype, "capitalize", {
value: function(toLowerCase) {
const text = toLowerCase ? this.toLowerCase() : this;
text.replace(/(^\w{1})|(\s+\w{1})/g, (char) => char.toUpperCase());
},
enumerable: false
});
Object.defineProperty(String.prototype, "subText", {
value: function(query, strict) {
if (strict) return this.standardize() === query?.standardize();
return this.standardize().includes(query?.standardize());
},
enumerable: false
});
Object.defineProperty(String.prototype, "unidecode", {
value: function(keepAccent) {
const emojiRegex = /[\p{Emoji}]/gu;
const decoded = this.replace(emojiRegex, "").trim();
if (keepAccent) return decoded;
return decoded.standardize();
},
enumerable: false
});
Object.defineProperty(String.prototype, "removeBacktick", {
value: function() {
return this.replace(/`/g, "");
},
enumerable: false
});
String.prototype.removeAccents = function() {
return this.normalize("NFD").replace(/\p{Diacritic}/gu, "");
};
String.prototype.standardize = function(noTrim) {
if (!noTrim) return this.removeAccents().toLowerCase();
return this.removeAccents().toLowerCase().trim();
};
String.prototype.toTitle = function(toLowerCase) {
const text = toLowerCase ? this.toLowerCase() : this;
return text.charAt(0).toUpperCase() + text.slice(1);
};
String.prototype.capitalize = function(toLowerCase) {
const text = toLowerCase ? this.toLowerCase() : this;
return text.replace(/(^\w{1})|(\s+\w{1})/g, (char) => char.toUpperCase());
};
String.prototype.subText = function(query, strict) {
if (strict) return this.standardize() === query?.standardize();
return this.standardize().includes(query?.standardize() ?? "");
};
String.prototype.unidecode = function(keepAccent) {
const emojiRegex = /[\p{Emoji}]/gu;
const decoded = this.replace(emojiRegex, "").trim();
if (keepAccent) return decoded;
return decoded.standardize();
};
String.prototype.removeBacktick = function() {
return this.replace(/`/g, "");
};
//# sourceMappingURL=index.js.map

@@ -5,5 +5,5 @@ {

"main": "dist/index.js",
"types": "dist/global.d.ts",
"types": "dist/types.d.ts",
"type": "commonjs",
"version": "1.0.8",
"version": "2.0.0",
"repository": {

@@ -24,4 +24,4 @@ "type": "git",

"cp": {
"win32": "xcopy /i /Y .\\src\\global.d.ts .\\dist",
"darwin": "cp ./src/global.d.ts ./dist"
"win32": "xcopy /i /Y .\\src\\types.d.ts .\\dist",
"darwin": "cp ./src/types.d.ts ./dist"
}

@@ -28,0 +28,0 @@ },

@@ -18,9 +18,6 @@ # Uniformize

As already said, it extends the `String` prototype, by using the global module. So, in your `tsconfig.json` :
```json
{
"compilerOptions": {
"typeRoots": ["node_modules/@types", "node_modules/uniformize"]
}
}
At the root (your `index.ts` file for example), import the package once to extend the `String` prototype:
```ts
import "uniformize";
```

@@ -27,0 +24,0 @@

@@ -1,42 +0,26 @@

Object.defineProperty(String.prototype, "removeAccents", {
value: function () {
return this.normalize("NFD").replace(/\p{Diacritic}/gu, "");
},
enumerable: false,
});
String.prototype.removeAccents = function () {
return this.normalize("NFD").replace(/\p{Diacritic}/gu, "");
};
Object.defineProperty(String.prototype, "standardize", {
value: function (noTrim?: boolean) {
if (!noTrim) return this.removeAccents().toLowerCase();
return this.removeAccents().toLowerCase().trim();
},
enumerable: false,
});
String.prototype.standardize = function (noTrim?: boolean) {
if (!noTrim) return this.removeAccents().toLowerCase();
return this.removeAccents().toLowerCase().trim();
};
Object.defineProperty(String.prototype, "toTitle", {
value: function (toLowerCase?: boolean) {
String.prototype.toTitle = function (toLowerCase?: boolean) {
const text = toLowerCase ? this.toLowerCase() : this;
return text.charAt(0).toUpperCase() + text.slice(1);
},
enumerable: false,
});
};
Object.defineProperty(String.prototype, "capitalize", {
value: function (toLowerCase?: boolean) {
String.prototype.capitalize = function (toLowerCase?: boolean) {
const text = toLowerCase ? this.toLowerCase() : this;
text.replace(/(^\w{1})|(\s+\w{1})/g, (char: string) => char.toUpperCase());
},
enumerable: false,
});
return text.replace(/(^\w{1})|(\s+\w{1})/g, (char: string) => char.toUpperCase());
};
Object.defineProperty(String.prototype, "subText", {
value: function (query?: string | null, strict?: boolean) {
if (strict) return this.standardize() === query?.standardize();
return this.standardize().includes(query?.standardize());
},
enumerable: false,
});
String.prototype.subText = function (query?: string | null, strict?: boolean) {
if (strict) return this.standardize() === query?.standardize();
return this.standardize().includes(query?.standardize() ?? "");
};
Object.defineProperty(String.prototype, "unidecode", {
value: function (keepAccent?: boolean) {
String.prototype.unidecode = function (keepAccent?: boolean) {
const emojiRegex = /[\p{Emoji}]/gu;

@@ -46,11 +30,6 @@ const decoded = this.replace(emojiRegex, "").trim();

return decoded.standardize();
},
enumerable: false,
});
};
Object.defineProperty(String.prototype, "removeBacktick", {
value: function () {
return this.replace(/`/g, "");
},
enumerable: false,
});
String.prototype.removeBacktick = function () {
return this.replace(/`/g, "");
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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