@mongez/reinforcements 1.0.26 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -5
- package/cjs/obj.d.ts +1 -1
- package/cjs/obj.js +1 -1
- package/cjs/utilities/object/objExcept.d.ts +1 -1
- package/cjs/utilities/object/objGet.js +3 -1
- package/cjs/utilities/object/objMap.d.ts +1 -1
- package/cjs/utilities/object/objOnly.d.ts +1 -1
- package/cjs/utilities/object/objSet.d.ts +1 -1
- package/cjs/utilities/object/objSort.d.ts +1 -1
- package/cjs/utilities/str/toCamelCase.d.ts +1 -1
- package/cjs/utilities/str/toCamelCase.js +3 -2
- package/cjs/utilities/str/toStudlyCase.js +1 -1
- package/esm/obj.d.ts +1 -1
- package/esm/obj.js +1 -1
- package/esm/utilities/object/objExcept.d.ts +1 -1
- package/esm/utilities/object/objGet.js +3 -1
- package/esm/utilities/object/objMap.d.ts +1 -1
- package/esm/utilities/object/objOnly.d.ts +1 -1
- package/esm/utilities/object/objSet.d.ts +1 -1
- package/esm/utilities/object/objSort.d.ts +1 -1
- package/esm/utilities/str/toCamelCase.d.ts +1 -1
- package/esm/utilities/str/toCamelCase.js +3 -2
- package/esm/utilities/str/toStudlyCase.js +1 -1
- package/package.json +9 -6
- package/cjs/utilities/str/sprintf.d.ts +0 -4
- package/esm/utilities/str/sprintf.d.ts +0 -4
package/README.md
CHANGED
|
@@ -671,7 +671,7 @@ console.log(capitalize(words)); // Hello World
|
|
|
671
671
|
|
|
672
672
|
### Convert string to camel case
|
|
673
673
|
|
|
674
|
-
Convert string to camel case, each word in string Separated by **whitespace** **underscores** or **dashes** `toCamelCase(string: string): string`.
|
|
674
|
+
Convert string to camel case, each word in string Separated by **whitespace** **underscores** or **dashes** `toCamelCase(string: string, separator: string = "\\s+|-|/|_|\\."): string`.
|
|
675
675
|
|
|
676
676
|
```js
|
|
677
677
|
import { toCamelCase } from "@mongez/reinforcements";
|
|
@@ -681,6 +681,8 @@ const words = "hello world";
|
|
|
681
681
|
console.log(toCamelCase(words)); // helloWorld
|
|
682
682
|
```
|
|
683
683
|
|
|
684
|
+
Any of following will be used as a separator for the text, `.` | `-` | `whitespace` | `/`, you can set the separator as second argument though.
|
|
685
|
+
|
|
684
686
|
### Convert string to snake case
|
|
685
687
|
|
|
686
688
|
Convert string to snake case, each word in string Separated by **whitespace** or **dashes** `toSnakeCase(string: string): string`.
|
|
@@ -697,7 +699,7 @@ console.log(toSnakeCase(words)); // hello_world
|
|
|
697
699
|
|
|
698
700
|
### Convert string to studly case
|
|
699
701
|
|
|
700
|
-
Convert string to studly case, each word in string Separated by **whitespace**, **underscores** or **dashes** `toStudlyCase(string: string, separator: string = "
|
|
702
|
+
Convert string to studly case, each word in string Separated by **whitespace**, **underscores** or **dashes** `toStudlyCase(string: string, separator: string = "-|\\.|_|\\s"): string`.
|
|
701
703
|
|
|
702
704
|
The final output will be capitalizing each word and glue it together without any separators such as **whitespace**, **under scores** or **dashes**.
|
|
703
705
|
|
|
@@ -1038,13 +1040,21 @@ function sendEmail(e: any) {
|
|
|
1038
1040
|
<button click={sendEmail}>Send Email</button>;
|
|
1039
1041
|
```
|
|
1040
1042
|
|
|
1043
|
+
## Tests
|
|
1044
|
+
|
|
1045
|
+
To run tests run `npm run test` or `yarn test`
|
|
1046
|
+
|
|
1041
1047
|
## Change Log
|
|
1042
1048
|
|
|
1043
|
-
- 1.0.
|
|
1049
|
+
- 1.0.27 (11 Aug 2022)
|
|
1050
|
+
- Added test.
|
|
1051
|
+
- `toCamelCase` now will use the dot `.` as separator.
|
|
1052
|
+
- `toCamelCase`'s separator is not explicit as second argument.
|
|
1053
|
+
- 1.0.26 (08 Jun 2022)
|
|
1044
1054
|
- Removed `sprintf-js` from dependencies.
|
|
1045
|
-
- 1.0.25 (
|
|
1055
|
+
- 1.0.25 (08 Jun 2022)
|
|
1046
1056
|
- Fixed Flatten method with empty arrays.
|
|
1047
|
-
- 1.0.23 (
|
|
1057
|
+
- 1.0.23 (03 Jun 2022)
|
|
1048
1058
|
- Added [debounce](#debounce) function.
|
|
1049
1059
|
- Added `/` to be replaced in `toCamelCase` `toStudlyCase` and `toSnakeCase`.
|
|
1050
1060
|
- 1.0.22 (10 Feb 2022)
|
package/cjs/obj.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export default class Obj {
|
|
|
68
68
|
* @param {array} keys
|
|
69
69
|
* @returns {Array<any>}
|
|
70
70
|
*/
|
|
71
|
-
static map(object: object, callback:
|
|
71
|
+
static map(object: object, callback: (key: string, value: any) => any): Array<any>;
|
|
72
72
|
/**
|
|
73
73
|
* Flatten the given object into one big fat object
|
|
74
74
|
*/
|
package/cjs/obj.js
CHANGED
|
@@ -63,7 +63,7 @@ var Obj = /** @class */ (function () {
|
|
|
63
63
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
64
64
|
objects[_i] = arguments[_i];
|
|
65
65
|
}
|
|
66
|
-
return immutable.mergeDeep
|
|
66
|
+
return immutable.mergeDeep(arguments);
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* Sort the given object by its keys
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
function objGet(object, key, $default) {
|
|
12
12
|
if ($default === void 0) { $default = null; }
|
|
13
13
|
try {
|
|
14
|
-
var value = key
|
|
14
|
+
var value = key
|
|
15
|
+
.split(".")
|
|
16
|
+
.reduce(function (obj, property) { return obj[property]; }, object);
|
|
15
17
|
return undefined === value ? $default : value;
|
|
16
18
|
}
|
|
17
19
|
catch (err) {
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param {function} callback
|
|
6
6
|
* @returns {Array<any>}
|
|
7
7
|
*/
|
|
8
|
-
export default function objMap(object: any, callback: any): Array<any>;
|
|
8
|
+
export default function objMap(object: any, callback: (key: string, value: any) => any): Array<any>;
|
|
9
9
|
//# sourceMappingURL=objMap.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function toCamelCase(string: string): string;
|
|
1
|
+
export default function toCamelCase(string: string, separator?: string): string;
|
|
2
2
|
//# sourceMappingURL=toCamelCase.d.ts.map
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var capitalize = require('./capitalize.js');
|
|
4
4
|
|
|
5
|
-
function toCamelCase(string) {
|
|
6
|
-
|
|
5
|
+
function toCamelCase(string, separator) {
|
|
6
|
+
if (separator === void 0) { separator = "\\s+|-|/|_|\\."; }
|
|
7
|
+
var regex = new RegExp(separator + "|(?=[A-Z])", "g");
|
|
7
8
|
return string
|
|
8
9
|
.split(regex)
|
|
9
10
|
.map(function (word, index) { return (index > 0 ? capitalize(word) : word.toLowerCase()); })
|
|
@@ -11,7 +11,7 @@ var capitalize = require('./capitalize.js');
|
|
|
11
11
|
* @see String.capitalize
|
|
12
12
|
*/
|
|
13
13
|
function toStudlyCase(string, separator) {
|
|
14
|
-
if (separator === void 0) { separator = "
|
|
14
|
+
if (separator === void 0) { separator = "-|\\.|_|/|\\s"; }
|
|
15
15
|
var regex = new RegExp(separator, "g");
|
|
16
16
|
return string
|
|
17
17
|
.split(regex)
|
package/esm/obj.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export default class Obj {
|
|
|
68
68
|
* @param {array} keys
|
|
69
69
|
* @returns {Array<any>}
|
|
70
70
|
*/
|
|
71
|
-
static map(object: object, callback:
|
|
71
|
+
static map(object: object, callback: (key: string, value: any) => any): Array<any>;
|
|
72
72
|
/**
|
|
73
73
|
* Flatten the given object into one big fat object
|
|
74
74
|
*/
|
package/esm/obj.js
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
function objGet(object, key, $default) {
|
|
10
10
|
if ($default === void 0) { $default = null; }
|
|
11
11
|
try {
|
|
12
|
-
var value = key
|
|
12
|
+
var value = key
|
|
13
|
+
.split(".")
|
|
14
|
+
.reduce(function (obj, property) { return obj[property]; }, object);
|
|
13
15
|
return undefined === value ? $default : value;
|
|
14
16
|
}
|
|
15
17
|
catch (err) {
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param {function} callback
|
|
6
6
|
* @returns {Array<any>}
|
|
7
7
|
*/
|
|
8
|
-
export default function objMap(object: any, callback: any): Array<any>;
|
|
8
|
+
export default function objMap(object: any, callback: (key: string, value: any) => any): Array<any>;
|
|
9
9
|
//# sourceMappingURL=objMap.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function toCamelCase(string: string): string;
|
|
1
|
+
export default function toCamelCase(string: string, separator?: string): string;
|
|
2
2
|
//# sourceMappingURL=toCamelCase.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import capitalize from './capitalize.js';
|
|
2
2
|
|
|
3
|
-
function toCamelCase(string) {
|
|
4
|
-
|
|
3
|
+
function toCamelCase(string, separator) {
|
|
4
|
+
if (separator === void 0) { separator = "\\s+|-|/|_|\\."; }
|
|
5
|
+
var regex = new RegExp(separator + "|(?=[A-Z])", "g");
|
|
5
6
|
return string
|
|
6
7
|
.split(regex)
|
|
7
8
|
.map(function (word, index) { return (index > 0 ? capitalize(word) : word.toLowerCase()); })
|
|
@@ -9,7 +9,7 @@ import capitalize from './capitalize.js';
|
|
|
9
9
|
* @see String.capitalize
|
|
10
10
|
*/
|
|
11
11
|
function toStudlyCase(string, separator) {
|
|
12
|
-
if (separator === void 0) { separator = "
|
|
12
|
+
if (separator === void 0) { separator = "-|\\.|_|/|\\s"; }
|
|
13
13
|
var regex = new RegExp(separator, "g");
|
|
14
14
|
return string
|
|
15
15
|
.split(regex)
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mongez/reinforcements",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "A lightweight package to give a massive reinforcements to variant types of data in Nodejs/Javascript",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"immutable": "^4.
|
|
7
|
+
"immutable": "^4.1.0"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "jest tests"
|
|
8
11
|
},
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
|
11
14
|
"url": "https://github.com/hassanzohdy/reinforcements"
|
|
12
15
|
},
|
|
13
16
|
"devDependencies": {
|
|
14
|
-
"@types/jest": "^
|
|
15
|
-
"jest": "^28.1.
|
|
17
|
+
"@types/jest": "^28.1.6",
|
|
18
|
+
"jest": "^28.1.3",
|
|
16
19
|
"jest-esm-jsx-transform": "^1.0.0",
|
|
17
|
-
"ts-jest": "^28.0.
|
|
18
|
-
"typescript": "^4.
|
|
20
|
+
"ts-jest": "^28.0.7",
|
|
21
|
+
"typescript": "^4.7.4"
|
|
19
22
|
},
|
|
20
23
|
"keywords": [
|
|
21
24
|
"array",
|