@cobalt-ui/utils
Advanced tools
Comparing version 0.4.0 to 0.5.0
# @cobalt-ui/utils | ||
## 0.5.0 | ||
### Minor Changes | ||
- 9e80004: Add objKey utility | ||
## 0.4.0 | ||
@@ -4,0 +10,0 @@ |
@@ -9,6 +9,6 @@ const TRAILING_SPACE_RE = /\s*$/; | ||
export class Indenter { | ||
char = ' '; | ||
count = 2; | ||
includeEmptyLines = false; | ||
constructor(opts) { | ||
this.char = ' '; | ||
this.count = 2; | ||
this.includeEmptyLines = false; | ||
if (typeof opts?.character === 'string') | ||
@@ -15,0 +15,0 @@ this.char = opts.character; |
@@ -0,4 +1,7 @@ | ||
/** UTF-8 char ranges */ | ||
export declare const CHARACTER_RE: string[]; | ||
export declare const CASECHANGE_RE: RegExp; | ||
export declare const KEBAB_COVERT_RE: RegExp; | ||
export declare const CAMEL_CONVERT_RE: RegExp; | ||
export declare const VALID_KEY: RegExp; | ||
/** convert string to kebab-case */ | ||
@@ -8,1 +11,3 @@ export declare function kebabinate(input: string): string; | ||
export declare function camelize(input: string): string; | ||
/** wrap bad obj keynames in strings */ | ||
export declare function objKey(name: string, wrapper?: string): string; |
@@ -0,4 +1,24 @@ | ||
/** UTF-8 char ranges */ | ||
export const CHARACTER_RE = [ | ||
'0-9', | ||
'A-Za-z', | ||
'\u00C0-\u00FF', | ||
'\u0100-\u017F', | ||
'\u0180-\u024F', | ||
'\u0370-\u03FF', | ||
'\u0400-\u04FF', | ||
'\u0530-\u058F', | ||
'\u0590-\u05FF', | ||
'\u0600-\u06FF', | ||
'\u0900-\u097F', | ||
'\u1100-\u11FF', | ||
'\u3040-\u309F', | ||
'\u30A0-\u30FF', | ||
'\u3400-\u4DBF', | ||
'\u4E00-\u9FFF', // CJK | ||
]; | ||
export const CASECHANGE_RE = /[a-zâ-ž][A-ZÀ-Ž]/g; | ||
export const KEBAB_COVERT_RE = /[_\.]/g; | ||
export const CAMEL_CONVERT_RE = /[^-_\.\s][-_\.\s]+[^-_\.\s]/g; | ||
export const KEBAB_COVERT_RE = /[_.]/g; | ||
export const CAMEL_CONVERT_RE = /[^-_.\s][-_.\s]+[^-_.\s]/g; | ||
export const VALID_KEY = new RegExp(`^[${CHARACTER_RE.join('')}]+$`); | ||
/** convert string to kebab-case */ | ||
@@ -15,2 +35,6 @@ export function kebabinate(input) { | ||
} | ||
/** wrap bad obj keynames in strings */ | ||
export function objKey(name, wrapper = "'") { | ||
return VALID_KEY.test(name) ? name : `${wrapper}${name}${wrapper}`; | ||
} | ||
//# sourceMappingURL=string.js.map |
{ | ||
"name": "@cobalt-ui/utils", | ||
"description": "Generic codegen utilities", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Drew Powers", |
@@ -30,3 +30,3 @@ export interface IndentOptions { | ||
indent(str: string, level: number): string { | ||
const { char, count, includeEmptyLines } = this; | ||
const {char, count, includeEmptyLines} = this; | ||
const prefix = new Array(count * level + 1).join(char); | ||
@@ -33,0 +33,0 @@ return str |
@@ -0,4 +1,25 @@ | ||
/** UTF-8 char ranges */ | ||
export const CHARACTER_RE = [ | ||
'0-9', // Numeric | ||
'A-Za-z', // Basic Latin | ||
'\u00C0-\u00FF', // Latin-1 Supplement | ||
'\u0100-\u017F', // Latin Extended-A | ||
'\u0180-\u024F', // Latin Extended-B | ||
'\u0370-\u03FF', // Greek & Coptic | ||
'\u0400-\u04FF', // Cyrillic | ||
'\u0530-\u058F', // Armenian | ||
'\u0590-\u05FF', // Hebrew | ||
'\u0600-\u06FF', // Arabic | ||
'\u0900-\u097F', // Devanagari | ||
'\u1100-\u11FF', // Hangul Jamo | ||
'\u3040-\u309F', // Hiragana | ||
'\u30A0-\u30FF', // Katakana | ||
'\u3400-\u4DBF', // CJK Extension A | ||
'\u4E00-\u9FFF', // CJK | ||
]; | ||
export const CASECHANGE_RE = /[a-zâ-ž][A-ZÀ-Ž]/g; | ||
export const KEBAB_COVERT_RE = /[_\.]/g; | ||
export const CAMEL_CONVERT_RE = /[^-_\.\s][-_\.\s]+[^-_\.\s]/g; | ||
export const KEBAB_COVERT_RE = /[_.]/g; | ||
export const CAMEL_CONVERT_RE = /[^-_.\s][-_.\s]+[^-_.\s]/g; | ||
export const VALID_KEY = new RegExp(`^[${CHARACTER_RE.join('')}]+$`); | ||
@@ -17,1 +38,6 @@ /** convert string to kebab-case */ | ||
} | ||
/** wrap bad obj keynames in strings */ | ||
export function objKey(name: string, wrapper = "'"): string { | ||
return VALID_KEY.test(name) ? name : `${wrapper}${name}${wrapper}`; | ||
} |
Sorry, the diff of this file is not supported yet
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
16632
258