@limitless.claver/stringify
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -7,3 +7,4 @@ "use strict"; | ||
const ncrypt_1 = __importDefault(require("./ncrypt")); | ||
require('dotenv').config(); | ||
const dotenv_1 = __importDefault(require("dotenv")); | ||
dotenv_1.default.config(); | ||
/** | ||
@@ -116,3 +117,3 @@ * The Stringify class provides a set of utility methods for working with strings. | ||
static toCamelCase(str) { | ||
return str.replace(/[-_]+(.)?/g, (_, c) => c ? c.toUpperCase() : ''); | ||
return str.replace(/[-_]+(.)?/g, (_, c) => (c ? c.toUpperCase() : '')); | ||
} | ||
@@ -278,3 +279,3 @@ /** | ||
*/ | ||
static padLeft(str, length, paddingChar = " ") { | ||
static padLeft(str, length, paddingChar = ' ') { | ||
const padding = paddingChar.repeat(length); | ||
@@ -293,3 +294,3 @@ return (padding + str).slice(-length); | ||
*/ | ||
static padRight(str, length, paddingChar = " ") { | ||
static padRight(str, length, paddingChar = ' ') { | ||
const padding = paddingChar.repeat(length); | ||
@@ -308,3 +309,3 @@ return (str + padding).slice(0, length); | ||
*/ | ||
static truncate(str, maxLength, suffix = "...") { | ||
static truncate(str, maxLength, suffix = '...') { | ||
if (str.length > maxLength) { | ||
@@ -311,0 +312,0 @@ return str.slice(0, maxLength - suffix.length) + suffix; |
@@ -5,11 +5,12 @@ { | ||
"type": "git", | ||
"url": "https://github.com/limitless-kode/stringify.git" | ||
"url": "git+https://github.com/limitless-kode/stringify.git" | ||
}, | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "String helper method for all string and JSON manipulations", | ||
"main": "./dist/index.js", | ||
"scripts": { | ||
"start": "tsc && node dist/index.js", | ||
"dev": "ts-node-dev --respawn --transpileOnly ../test/index.ts", | ||
"build": "tsc" | ||
"test": "jest --config jestconfig.json", | ||
"build": "tsc", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"lint": "tslint -p tsconfig.json" | ||
}, | ||
@@ -26,6 +27,16 @@ "keywords": [ | ||
"license": "MIT", | ||
"bugs": { | ||
"email": "limitless.claver@gmail.com", | ||
"url": "https://github.com/limitless-kode/stringify/issues" | ||
}, | ||
"homepage": "https://github.com/limitless-kode/stringify#readme", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.0", | ||
"@types/node": "^18.15.8", | ||
"jest": "^29.5.0", | ||
"nodemon": "^2.0.22", | ||
"prettier": "^2.8.7", | ||
"ts-jest": "^29.0.5", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.9.5" | ||
@@ -32,0 +43,0 @@ }, |
@@ -1,5 +0,3 @@ | ||
import Stringify from "./stringify"; | ||
import Stringify from './stringify'; | ||
export { | ||
Stringify | ||
} | ||
export { Stringify }; |
import Ncrypt from './ncrypt'; | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
require('dotenv').config(); | ||
/** | ||
@@ -9,5 +9,5 @@ * The Stringify class provides a set of utility methods for working with strings. | ||
*/ | ||
export default class Stringify extends Ncrypt{ | ||
export default class Stringify extends Ncrypt { | ||
constructor(key?: string) { | ||
super(process.env.ENCRYPTION_KEY || key as string); | ||
super(process.env.ENCRYPTION_KEY || (key as string)); | ||
} | ||
@@ -59,3 +59,3 @@ | ||
static toEncryptedString(value: any) { | ||
try{ | ||
try { | ||
const stringify = new Stringify(); | ||
@@ -78,3 +78,3 @@ return stringify.encrypt(JSON.stringify(value)); | ||
static toDecryptedString(value: string) { | ||
try{ | ||
try { | ||
const stringify = new Stringify(); | ||
@@ -87,3 +87,2 @@ return stringify.decrypt(value); | ||
/** | ||
@@ -99,3 +98,3 @@ * Decrypts an encrypted string to a JSON object using the encryption key | ||
static toDecryptedJSON(value: string) { | ||
try{ | ||
try { | ||
const stringify = new Stringify(); | ||
@@ -122,3 +121,3 @@ return JSON.parse(stringify.decrypt(value)); | ||
static toCamelCase(str: string): string { | ||
return str.replace(/[-_]+(.)?/g, (_, c) => c ? c.toUpperCase() : ''); | ||
return str.replace(/[-_]+(.)?/g, (_, c) => (c ? c.toUpperCase() : '')); | ||
} | ||
@@ -207,3 +206,2 @@ | ||
// ===================================================================== | ||
@@ -270,3 +268,2 @@ // URL Encoding | ||
// ===================================================================== | ||
@@ -301,3 +298,3 @@ // String formatting | ||
*/ | ||
static padLeft(str: string, length: number, paddingChar: string = " "): string { | ||
static padLeft(str: string, length: number, paddingChar: string = ' '): string { | ||
const padding = paddingChar.repeat(length); | ||
@@ -317,3 +314,3 @@ return (padding + str).slice(-length); | ||
*/ | ||
static padRight(str: string, length: number, paddingChar: string = " "): string { | ||
static padRight(str: string, length: number, paddingChar: string = ' '): string { | ||
const padding = paddingChar.repeat(length); | ||
@@ -333,3 +330,3 @@ return (str + padding).slice(0, length); | ||
*/ | ||
static truncate(str: string, maxLength: number, suffix: string = "..."): string { | ||
static truncate(str: string, maxLength: number, suffix: string = '...'): string { | ||
if (str.length > maxLength) { | ||
@@ -341,2 +338,2 @@ return str.slice(0, maxLength - suffix.length) + suffix; | ||
} | ||
} | ||
} |
@@ -5,2 +5,4 @@ { | ||
"module": "commonjs", | ||
"allowJs": true, | ||
"declaration": true, | ||
"outDir": "./dist", | ||
@@ -7,0 +9,0 @@ "strict": true, |
Sorry, the diff of this file is not supported yet
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
52209
24
944
0
0
9