@vpmedia/simplify 1.0.3 → 1.1.0
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/CHANGES.md +8 -0
- package/README.md +2 -2
- package/lefthook.yml +12 -3
- package/package.json +13 -15
- package/src/index.js +2 -0
- package/src/util/addLeadingZero.js +16 -0
- package/src/util/addLeadingZero.test.js +11 -0
- package/types/util/getObjValueByPath.d.ts +1 -1
- package/types/util/setObjValueByPath.d.ts +1 -1
package/CHANGES.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 1.1.0
|
|
7
|
+
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 1.0.4
|
|
11
|
+
|
|
12
|
+
- Reverted package module exports to main
|
|
13
|
+
|
|
6
14
|
## 1.0.3
|
|
7
15
|
|
|
8
16
|
- Added deep object value getter / setter helpers
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @vpmedia/simplify
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/@vpmedia%2Fsimplify)
|
|
4
|
+
[](https://github.com/vpmedia/simplify/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
6
|
@vpmedia/simplify TBD
|
|
7
7
|
|
package/lefthook.yml
CHANGED
|
@@ -5,9 +5,18 @@
|
|
|
5
5
|
pre-commit:
|
|
6
6
|
parallel: false
|
|
7
7
|
commands:
|
|
8
|
-
|
|
8
|
+
lint_yaml:
|
|
9
|
+
glob: "*.{yml,yaml}"
|
|
10
|
+
run: |
|
|
11
|
+
set -e
|
|
12
|
+
yq 'true' {staged_files} > /dev/null
|
|
13
|
+
lint_json:
|
|
14
|
+
glob: "*.{json}"
|
|
15
|
+
run: |
|
|
16
|
+
set -e
|
|
17
|
+
jq empty {staged_files}
|
|
18
|
+
lint_js:
|
|
9
19
|
glob: "*.{js,ts,jsx,tsx}"
|
|
10
20
|
run: |
|
|
11
21
|
set -e
|
|
12
|
-
./node_modules/.bin/eslint
|
|
13
|
-
git add {staged_files} &> /dev/null || true
|
|
22
|
+
./node_modules/.bin/eslint {staged_files}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/simplify",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "@vpmedia/simplify",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,30 +15,28 @@
|
|
|
15
15
|
"keywords": [
|
|
16
16
|
"utils"
|
|
17
17
|
],
|
|
18
|
-
"
|
|
18
|
+
"main": "./src/index.js",
|
|
19
19
|
"types": "./types/index.d.ts",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@babel/preset-env": "^7.23.
|
|
22
|
+
"@babel/preset-env": "^7.23.9",
|
|
23
23
|
"@jest/globals": "^29.7.0",
|
|
24
|
-
"@types/jest": "^29.5.
|
|
25
|
-
"eslint": "^8.
|
|
26
|
-
"eslint-
|
|
27
|
-
"eslint-plugin-
|
|
28
|
-
"eslint-plugin-
|
|
29
|
-
"eslint-plugin-jsdoc": "^46.8.2",
|
|
30
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
24
|
+
"@types/jest": "^29.5.12",
|
|
25
|
+
"eslint": "^8.56.0",
|
|
26
|
+
"eslint-plugin-import": "^2.29.1",
|
|
27
|
+
"eslint-plugin-jest": "^27.6.3",
|
|
28
|
+
"eslint-plugin-jsdoc": "^48.0.4",
|
|
31
29
|
"jest": "^29.7.0",
|
|
32
30
|
"jest-environment-jsdom": "^29.7.0",
|
|
33
|
-
"lefthook": "^1.
|
|
34
|
-
"prettier": "^3.
|
|
35
|
-
"typescript": "^5.
|
|
31
|
+
"lefthook": "^1.6.1",
|
|
32
|
+
"prettier": "^3.2.4",
|
|
33
|
+
"typescript": "^5.3.3"
|
|
36
34
|
},
|
|
37
35
|
"scripts": {
|
|
38
36
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
39
|
-
"lint": "eslint
|
|
37
|
+
"lint": "eslint \"**/*.{js,jsx}\"",
|
|
40
38
|
"typecheck": "tsc",
|
|
41
|
-
"format": "prettier --write \"**/*.{css,js,jsx
|
|
39
|
+
"format": "prettier --write \"**/*.{css,js,jsx}\"",
|
|
42
40
|
"lefthook:install": "lefthook install",
|
|
43
41
|
"lefthook:uninstall": "lefthook uninstall"
|
|
44
42
|
},
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// core
|
|
2
|
+
import { addLeadingZero } from './util/addLeadingZero.js';
|
|
2
3
|
import { capitalize } from './util/capitalize.js';
|
|
3
4
|
import { getObjValueByPath } from './util/getObjValueByPath.js';
|
|
4
5
|
import { getRandomInt } from './util/getRandomInt.js';
|
|
@@ -8,6 +9,7 @@ import { setObjValueByPath } from './util/setObjValueByPath.js';
|
|
|
8
9
|
import { underscoreToCamelCase } from './util/underscoreToCamelCase.js';
|
|
9
10
|
// exports
|
|
10
11
|
export {
|
|
12
|
+
addLeadingZero,
|
|
11
13
|
capitalize,
|
|
12
14
|
getObjValueByPath,
|
|
13
15
|
getRandomInt,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TBD.
|
|
3
|
+
* @param {number|string} value - TBD.
|
|
4
|
+
* @param {number} size - TBD.
|
|
5
|
+
* @returns {string} TBD.
|
|
6
|
+
*/
|
|
7
|
+
export function addLeadingZero(value, size = 2) {
|
|
8
|
+
if (value === null || value === undefined) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
value = value.toString();
|
|
12
|
+
while (value.length < size) {
|
|
13
|
+
value = '0' + value;
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { addLeadingZero } from './addLeadingZero.js';
|
|
2
|
+
|
|
3
|
+
test('Tests add leading zero', () => {
|
|
4
|
+
expect(addLeadingZero(1)).toBe('01');
|
|
5
|
+
expect(addLeadingZero('1')).toBe('01');
|
|
6
|
+
expect(addLeadingZero(1, 3)).toBe('001');
|
|
7
|
+
expect(addLeadingZero('21')).toBe('21');
|
|
8
|
+
expect(addLeadingZero(21)).toBe('21');
|
|
9
|
+
expect(addLeadingZero(null)).toBe(null);
|
|
10
|
+
expect(addLeadingZero(undefined)).toBe(undefined);
|
|
11
|
+
});
|