@waiting/shared-core
Advanced tools
Comparing version 14.0.0 to 14.1.0
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 13.2.0 | ||
* @version 14.0.0 | ||
* @author waiting | ||
@@ -398,3 +398,9 @@ * @license MIT | ||
/** | ||
* Convert 'tb_user-detail' to tbUserDetail | ||
* Convert snake to camelcase | ||
* | ||
* @example | ||
* - 'tb_user_detail' to 'tbUserDetail' | ||
* - 'tb_user-detail' to 'tbUserDetail' | ||
* - 'tb_user_2_good' to 'tbUser2Good' | ||
* - 'tb_user_2good' to 'tbUser2good' | ||
* @see SnakeToCamel of @waiting/shared-types | ||
@@ -411,3 +417,8 @@ */ | ||
/** | ||
* Convert 'tb_user-detail' to TbUserDetail | ||
* Convert snake to pascal case | ||
* @example | ||
* - 'tb_user_detail' to 'TbUserDetail' | ||
* - 'tb_user-detail' to 'TbUserDetail' | ||
* - 'tb_user_2_good' to 'TbUser2Good' | ||
* - 'tb_user_2good' to 'TbUser2good' | ||
* @see SnakeToPascal of @waiting/shared-types | ||
@@ -421,2 +432,18 @@ */ | ||
} | ||
/** | ||
* Convert camelcase to snakecase | ||
* | ||
* @example | ||
* - 'tbUserDetail' to 'tb_user_detail' | ||
* - 'tbUserDetail' to 'tb_user-detail' | ||
* - `tbUserDetail` to 'tb_user-detail' | ||
* - `tbUser2Good` to 'tb_user_2_good' | ||
* - `tbUser2good` to 'tb_user_2good' | ||
* - `3TbUser2good` to '3_Tb_user_2good' | ||
* - `3tbUser2good` to '3tb_user_2good' | ||
*/ | ||
function camelToSnakeCase(input) { | ||
return input.replace(/[A-Z]/ug, match => `_${match.toLowerCase()}`) | ||
.replace(/(?<=\w)\d+/ug, match => `_${match}`); | ||
} | ||
@@ -554,2 +581,3 @@ /** | ||
exports.buf2ab = buf2ab; | ||
exports.camelToSnakeCase = camelToSnakeCase; | ||
exports.chmodAsync = chmodAsync; | ||
@@ -556,0 +584,0 @@ exports.closeAsync = closeAsync; |
import { SnakeToCamel, SnakeToPascal } from '@waiting/shared-types'; | ||
/** | ||
* Convert 'tb_user-detail' to tbUserDetail | ||
* Convert snake to camelcase | ||
* | ||
* @example | ||
* - 'tb_user_detail' to 'tbUserDetail' | ||
* - 'tb_user-detail' to 'tbUserDetail' | ||
* - 'tb_user_2_good' to 'tbUser2Good' | ||
* - 'tb_user_2good' to 'tbUser2good' | ||
* @see SnakeToCamel of @waiting/shared-types | ||
@@ -8,5 +14,23 @@ */ | ||
/** | ||
* Convert 'tb_user-detail' to TbUserDetail | ||
* Convert snake to pascal case | ||
* @example | ||
* - 'tb_user_detail' to 'TbUserDetail' | ||
* - 'tb_user-detail' to 'TbUserDetail' | ||
* - 'tb_user_2_good' to 'TbUser2Good' | ||
* - 'tb_user_2good' to 'TbUser2good' | ||
* @see SnakeToPascal of @waiting/shared-types | ||
*/ | ||
export declare function snakeToPascal<T extends string = string>(input: T): SnakeToPascal<T>; | ||
/** | ||
* Convert camelcase to snakecase | ||
* | ||
* @example | ||
* - 'tbUserDetail' to 'tb_user_detail' | ||
* - 'tbUserDetail' to 'tb_user-detail' | ||
* - `tbUserDetail` to 'tb_user-detail' | ||
* - `tbUser2Good` to 'tb_user_2_good' | ||
* - `tbUser2good` to 'tb_user_2good' | ||
* - `3TbUser2good` to '3_Tb_user_2good' | ||
* - `3tbUser2good` to '3tb_user_2good' | ||
*/ | ||
export declare function camelToSnakeCase<T extends string = string, Target extends string = string>(input: T): Target; |
/** | ||
* Convert 'tb_user-detail' to tbUserDetail | ||
* Convert snake to camelcase | ||
* | ||
* @example | ||
* - 'tb_user_detail' to 'tbUserDetail' | ||
* - 'tb_user-detail' to 'tbUserDetail' | ||
* - 'tb_user_2_good' to 'tbUser2Good' | ||
* - 'tb_user_2good' to 'tbUser2good' | ||
* @see SnakeToCamel of @waiting/shared-types | ||
@@ -14,3 +20,8 @@ */ | ||
/** | ||
* Convert 'tb_user-detail' to TbUserDetail | ||
* Convert snake to pascal case | ||
* @example | ||
* - 'tb_user_detail' to 'TbUserDetail' | ||
* - 'tb_user-detail' to 'TbUserDetail' | ||
* - 'tb_user_2_good' to 'TbUser2Good' | ||
* - 'tb_user_2good' to 'TbUser2good' | ||
* @see SnakeToPascal of @waiting/shared-types | ||
@@ -24,1 +35,17 @@ */ | ||
} | ||
/** | ||
* Convert camelcase to snakecase | ||
* | ||
* @example | ||
* - 'tbUserDetail' to 'tb_user_detail' | ||
* - 'tbUserDetail' to 'tb_user-detail' | ||
* - `tbUserDetail` to 'tb_user-detail' | ||
* - `tbUser2Good` to 'tb_user_2_good' | ||
* - `tbUser2good` to 'tb_user_2good' | ||
* - `3TbUser2good` to '3_Tb_user_2good' | ||
* - `3tbUser2good` to '3tb_user_2good' | ||
*/ | ||
export function camelToSnakeCase(input) { | ||
return input.replace(/[A-Z]/ug, match => `_${match.toLowerCase()}`) | ||
.replace(/(?<=\w)\d+/ug, match => `_${match}`); | ||
} |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "14.0.0", | ||
"version": "14.1.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@waiting/shared-types": "^14.0.0", | ||
"@waiting/shared-types": "^14.1.0", | ||
"rxjs": "7" | ||
@@ -95,3 +95,3 @@ }, | ||
}, | ||
"gitHead": "23e372c5bf4b82d845f4e2b631d5f782c8ea5fcc" | ||
"gitHead": "315bf970e4e081c1483a8917d46de68f9827bc5a" | ||
} |
@@ -6,3 +6,9 @@ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ | ||
/** | ||
* Convert 'tb_user-detail' to tbUserDetail | ||
* Convert snake to camelcase | ||
* | ||
* @example | ||
* - 'tb_user_detail' to 'tbUserDetail' | ||
* - 'tb_user-detail' to 'tbUserDetail' | ||
* - 'tb_user_2_good' to 'tbUser2Good' | ||
* - 'tb_user_2good' to 'tbUser2good' | ||
* @see SnakeToCamel of @waiting/shared-types | ||
@@ -21,3 +27,8 @@ */ | ||
/** | ||
* Convert 'tb_user-detail' to TbUserDetail | ||
* Convert snake to pascal case | ||
* @example | ||
* - 'tb_user_detail' to 'TbUserDetail' | ||
* - 'tb_user-detail' to 'TbUserDetail' | ||
* - 'tb_user_2_good' to 'TbUser2Good' | ||
* - 'tb_user_2good' to 'TbUser2good' | ||
* @see SnakeToPascal of @waiting/shared-types | ||
@@ -32,1 +43,19 @@ */ | ||
/** | ||
* Convert camelcase to snakecase | ||
* | ||
* @example | ||
* - 'tbUserDetail' to 'tb_user_detail' | ||
* - 'tbUserDetail' to 'tb_user-detail' | ||
* - `tbUserDetail` to 'tb_user-detail' | ||
* - `tbUser2Good` to 'tb_user_2_good' | ||
* - `tbUser2good` to 'tb_user_2good' | ||
* - `3TbUser2good` to '3_Tb_user_2good' | ||
* - `3tbUser2good` to '3tb_user_2good' | ||
*/ | ||
export function camelToSnakeCase<T extends string = string, Target extends string = string>(input: T): Target { | ||
return input.replace(/[A-Z]/ug, match => `_${match.toLowerCase()}`) | ||
.replace(/(?<=\w)\d+/ug, match => `_${match}`) as Target | ||
} | ||
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
81854
2193