appwrite-utils
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -50,2 +50,4 @@ import { DateTime } from "luxon"; | ||
anyToAnyArray(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
if (Array.isArray(value)) { | ||
@@ -68,2 +70,4 @@ return value; | ||
anyToStringArray(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
if (Array.isArray(value)) { | ||
@@ -84,2 +88,4 @@ return value.map((item) => String(item)); | ||
anyToNumberArray(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
if (Array.isArray(value)) { | ||
@@ -94,2 +100,4 @@ return value.map((item) => Number(item)); | ||
trim(value) { | ||
if (value === null || value === undefined || value === "") | ||
return ""; | ||
try { | ||
@@ -108,2 +116,4 @@ return value.trim(); | ||
removeStartEndQuotes(value) { | ||
if (value === null || value === undefined || value === "") | ||
return ""; | ||
return value.replace(/^["']|["']$/g, ""); | ||
@@ -118,2 +128,4 @@ }, | ||
trySplitByDifferentSeparators(value) { | ||
if (value === null || value === undefined || value === "") | ||
return []; | ||
const separators = [",", ";", "|", ":", "/", "\\"]; | ||
@@ -145,2 +157,4 @@ let bestSplit = []; | ||
joinValues(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -154,2 +168,4 @@ return values.join(""); | ||
joinBySpace(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -163,2 +179,4 @@ return values.join(" "); | ||
joinByComma(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -172,2 +190,4 @@ return values.join(","); | ||
joinByPipe(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -181,2 +201,4 @@ return values.join("|"); | ||
joinBySemicolon(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -190,2 +212,4 @@ return values.join(";"); | ||
joinByColon(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -199,2 +223,4 @@ return values.join(":"); | ||
joinBySlash(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -208,2 +234,4 @@ return values.join("/"); | ||
joinByHyphen(values) { | ||
if (values === null || values === undefined) | ||
return values; | ||
try { | ||
@@ -217,2 +245,4 @@ return values.join("-"); | ||
splitByComma(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -226,2 +256,4 @@ return value.split(","); | ||
splitByPipe(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -235,2 +267,4 @@ return value.split("|"); | ||
splitBySemicolon(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -244,2 +278,4 @@ return value.split(";"); | ||
splitByColon(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -253,2 +289,4 @@ return value.split(":"); | ||
splitBySlash(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -262,2 +300,4 @@ return value.split("/"); | ||
splitByBackslash(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -271,2 +311,4 @@ return value.split("\\"); | ||
splitBySpace(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -280,2 +322,4 @@ return value.split(" "); | ||
splitByDot(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -289,2 +333,4 @@ return value.split("."); | ||
splitByUnderscore(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -298,2 +344,4 @@ return value.split("_"); | ||
splitByHyphen(value) { | ||
if (value === null || value === undefined || value === "") | ||
return value; | ||
try { | ||
@@ -312,2 +360,4 @@ return value.split("-"); | ||
pickFirstElement(value) { | ||
if (value === null || value === undefined || value.length === 0) | ||
return value; | ||
try { | ||
@@ -314,0 +364,0 @@ return value[0]; |
{ | ||
"name": "appwrite-utils", | ||
"module": "dist/index.js", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/index.d.ts", |
@@ -54,2 +54,3 @@ import { DateTime } from "luxon"; | ||
anyToAnyArray(value: any): any[] { | ||
if (value === null || value === undefined || value === "") return value; | ||
if (Array.isArray(value)) { | ||
@@ -72,2 +73,3 @@ return value; | ||
anyToStringArray(value: any): string[] { | ||
if (value === null || value === undefined || value === "") return value; | ||
if (Array.isArray(value)) { | ||
@@ -88,2 +90,3 @@ return value.map((item) => String(item)); | ||
anyToNumberArray(value: any): number[] { | ||
if (value === null || value === undefined || value === "") return value; | ||
if (Array.isArray(value)) { | ||
@@ -98,2 +101,3 @@ return value.map((item) => Number(item)); | ||
trim(value: string): string { | ||
if (value === null || value === undefined || value === "") return ""; | ||
try { | ||
@@ -112,2 +116,3 @@ return value.trim(); | ||
removeStartEndQuotes(value: string): string { | ||
if (value === null || value === undefined || value === "") return ""; | ||
return value.replace(/^["']|["']$/g, ""); | ||
@@ -123,2 +128,3 @@ }, | ||
trySplitByDifferentSeparators(value: string): string[] { | ||
if (value === null || value === undefined || value === "") return []; | ||
const separators = [",", ";", "|", ":", "/", "\\"]; | ||
@@ -160,2 +166,3 @@ let bestSplit: string[] = []; | ||
joinValues(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -169,2 +176,3 @@ return values.join(""); | ||
joinBySpace(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -178,2 +186,3 @@ return values.join(" "); | ||
joinByComma(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -187,2 +196,3 @@ return values.join(","); | ||
joinByPipe(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -196,2 +206,3 @@ return values.join("|"); | ||
joinBySemicolon(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -205,2 +216,3 @@ return values.join(";"); | ||
joinByColon(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -214,2 +226,3 @@ return values.join(":"); | ||
joinBySlash(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -223,2 +236,3 @@ return values.join("/"); | ||
joinByHyphen(values: any[]): any { | ||
if (values === null || values === undefined) return values; | ||
try { | ||
@@ -232,2 +246,3 @@ return values.join("-"); | ||
splitByComma(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -241,2 +256,3 @@ return value.split(","); | ||
splitByPipe(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -250,2 +266,3 @@ return value.split("|"); | ||
splitBySemicolon(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -259,2 +276,3 @@ return value.split(";"); | ||
splitByColon(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -268,2 +286,3 @@ return value.split(":"); | ||
splitBySlash(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -277,2 +296,3 @@ return value.split("/"); | ||
splitByBackslash(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -286,2 +306,3 @@ return value.split("\\"); | ||
splitBySpace(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -295,2 +316,3 @@ return value.split(" "); | ||
splitByDot(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -304,2 +326,3 @@ return value.split("."); | ||
splitByUnderscore(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -313,2 +336,3 @@ return value.split("_"); | ||
splitByHyphen(value: string): any { | ||
if (value === null || value === undefined || value === "") return value; | ||
try { | ||
@@ -327,2 +351,4 @@ return value.split("-"); | ||
pickFirstElement(value: any[]): any { | ||
if (value === null || value === undefined || value.length === 0) | ||
return value; | ||
try { | ||
@@ -329,0 +355,0 @@ return value[0]; |
344245
8970