namirasoft-core
Advanced tools
Comparing version 1.4.26 to 1.4.27
@@ -7,2 +7,3 @@ export declare class NamingConvention { | ||
static formatter_sentence: (word: string, index: number) => string; | ||
static splitter_multi: (name: string, ...splitters: ((name: string) => string[])[]) => string[]; | ||
static splitter_normal: (name: string, delimiter: string) => string[]; | ||
@@ -12,2 +13,4 @@ static splitter_pascal: (name: string, delimiter: string) => string[]; | ||
static splitter_none: (name: string) => string[]; | ||
static splitter_all: (name: string) => string[]; | ||
static auto: NamingConvention; | ||
static lower_case: NamingConvention; | ||
@@ -14,0 +17,0 @@ static UPPER_CASE: NamingConvention; |
@@ -75,2 +75,13 @@ "use strict"; | ||
}; | ||
NamingConvention.splitter_multi = (name, ...splitters) => { | ||
let ans = [name]; | ||
for (let i = 0; i < splitters.length; i++) { | ||
const splitter = splitters[i]; | ||
let words = []; | ||
for (let word of ans) | ||
words.push(...splitter(word)); | ||
ans = words; | ||
} | ||
return ans; | ||
}; | ||
NamingConvention.splitter_normal = (name, delimiter) => { | ||
@@ -80,7 +91,3 @@ return name.split(delimiter); | ||
NamingConvention.splitter_pascal = (name, delimiter) => { | ||
let words = NamingConvention.splitter_uppercase(name); | ||
let ans = []; | ||
for (let word of words) | ||
ans.push(...NamingConvention.splitter_normal(word, delimiter)); | ||
return ans; | ||
return NamingConvention.splitter_multi(name, NamingConvention.splitter_uppercase, (w) => NamingConvention.splitter_normal(w, delimiter)); | ||
}; | ||
@@ -93,2 +100,6 @@ NamingConvention.splitter_uppercase = (name) => { | ||
}; | ||
NamingConvention.splitter_all = (name) => { | ||
return NamingConvention.splitter_multi(name, (w) => NamingConvention.splitter_normal(w, ' '), (w) => NamingConvention.splitter_normal(w, '/'), (w) => NamingConvention.splitter_normal(w, '-'), (w) => NamingConvention.splitter_normal(w, '_'), (w) => NamingConvention.splitter_normal(w, '\\'), (w) => NamingConvention.splitter_normal(w, '.'), (w) => NamingConvention.splitter_normal(w, '.'), NamingConvention.splitter_uppercase); | ||
}; | ||
NamingConvention.auto = new NamingConvention("auto", "", false, () => { throw new Error("NamingConvention.auto can not be used to format"); }, NamingConvention.splitter_all); | ||
NamingConvention.lower_case = new NamingConvention("lowercase", "", false, NamingConvention.formatter_lower, NamingConvention.splitter_none); | ||
@@ -95,0 +106,0 @@ NamingConvention.UPPER_CASE = new NamingConvention("UPPERCASE", "", false, NamingConvention.formatter_upper, NamingConvention.splitter_none); |
@@ -11,3 +11,3 @@ { | ||
"private": false, | ||
"version": "1.4.26", | ||
"version": "1.4.27", | ||
"author": "Amir Abolhasani", | ||
@@ -14,0 +14,0 @@ "license": "MIT", |
@@ -33,2 +33,15 @@ export class NamingConvention | ||
}; | ||
public static splitter_multi = (name: string, ...splitters: ((name: string) => string[])[]) => | ||
{ | ||
let ans = [name]; | ||
for (let i = 0; i < splitters.length; i++) | ||
{ | ||
const splitter = splitters[i]; | ||
let words = []; | ||
for (let word of ans) | ||
words.push(...splitter(word)); | ||
ans = words; | ||
} | ||
return ans; | ||
}; | ||
public static splitter_normal = (name: string, delimiter: string) => | ||
@@ -40,7 +53,3 @@ { | ||
{ | ||
let words = NamingConvention.splitter_uppercase(name); | ||
let ans = []; | ||
for (let word of words) | ||
ans.push(...NamingConvention.splitter_normal(word, delimiter)); | ||
return ans; | ||
return NamingConvention.splitter_multi(name, NamingConvention.splitter_uppercase, (w) => NamingConvention.splitter_normal(w, delimiter)); | ||
}; | ||
@@ -55,2 +64,17 @@ public static splitter_uppercase = (name: string) => | ||
}; | ||
public static splitter_all = (name: string) => | ||
{ | ||
return NamingConvention.splitter_multi(name, | ||
(w) => NamingConvention.splitter_normal(w, ' '), | ||
(w) => NamingConvention.splitter_normal(w, '/'), | ||
(w) => NamingConvention.splitter_normal(w, '-'), | ||
(w) => NamingConvention.splitter_normal(w, '_'), | ||
(w) => NamingConvention.splitter_normal(w, '\\'), | ||
(w) => NamingConvention.splitter_normal(w, '.'), | ||
(w) => NamingConvention.splitter_normal(w, '.'), | ||
NamingConvention.splitter_uppercase | ||
); | ||
}; | ||
public static auto: NamingConvention = new NamingConvention("auto", "", false, () => { throw new Error("NamingConvention.auto can not be used to format") }, NamingConvention.splitter_all); | ||
public static lower_case: NamingConvention = new NamingConvention("lowercase", "", false, NamingConvention.formatter_lower, NamingConvention.splitter_none); | ||
@@ -57,0 +81,0 @@ public static UPPER_CASE: NamingConvention = new NamingConvention("UPPERCASE", "", false, NamingConvention.formatter_upper, NamingConvention.splitter_none); |
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
423182
5637