@quanxiaoxiao/datav 0.3.2 → 0.4.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/eslint.config.mjs +51 -2
- package/package.json +6 -5
- package/src/checkout.mjs +1 -4
- package/src/checkout.test.mjs +2 -1
- package/src/index.mjs +1 -1
- package/src/select/check.test.mjs +1 -0
- package/src/select/index.mjs +3 -2
- package/src/select/index.test.mjs +32 -7
package/eslint.config.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import js from '@eslint/js';
|
|
2
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
2
3
|
import globals from 'globals';
|
|
3
4
|
|
|
4
5
|
export default [
|
|
5
6
|
{
|
|
6
7
|
ignores: [
|
|
7
|
-
'_resources/*',
|
|
8
|
-
'static/*',
|
|
9
8
|
'node_modules/*',
|
|
10
9
|
],
|
|
11
10
|
},
|
|
12
11
|
js.configs.recommended,
|
|
13
12
|
{
|
|
13
|
+
plugins: {
|
|
14
|
+
'simple-import-sort': simpleImportSort,
|
|
15
|
+
},
|
|
14
16
|
files: [
|
|
15
17
|
'src/**/*.mjs',
|
|
16
18
|
'_index.mjs',
|
|
@@ -25,6 +27,53 @@ export default [
|
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
rules: {
|
|
30
|
+
'simple-import-sort/imports': 'error',
|
|
31
|
+
'simple-import-sort/exports': 'error',
|
|
32
|
+
'no-duplicate-imports': 2,
|
|
33
|
+
'array-callback-return': 2,
|
|
34
|
+
'prefer-const': 2,
|
|
35
|
+
'no-multi-spaces': 2,
|
|
36
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
37
|
+
'block-scoped-var': 2,
|
|
38
|
+
'consistent-return': 2,
|
|
39
|
+
'default-case': 2,
|
|
40
|
+
'no-shadow': 2,
|
|
41
|
+
'object-shorthand': 2,
|
|
42
|
+
'quote-props': ['error', 'as-needed'],
|
|
43
|
+
quotes: [
|
|
44
|
+
'error',
|
|
45
|
+
'single',
|
|
46
|
+
],
|
|
47
|
+
'object-curly-newline': 2,
|
|
48
|
+
'no-multi-assign': 2,
|
|
49
|
+
'no-else-return': 2,
|
|
50
|
+
indent: [
|
|
51
|
+
'error',
|
|
52
|
+
2,
|
|
53
|
+
],
|
|
54
|
+
'keyword-spacing': 2,
|
|
55
|
+
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
|
|
56
|
+
'space-infix-ops': 2,
|
|
57
|
+
'eol-last': 2,
|
|
58
|
+
'space-in-parens': 2,
|
|
59
|
+
'array-bracket-spacing': 2,
|
|
60
|
+
'object-curly-spacing': ['error', 'always'],
|
|
61
|
+
'block-spacing': 2,
|
|
62
|
+
'key-spacing': 2,
|
|
63
|
+
'no-trailing-spaces': 2,
|
|
64
|
+
'comma-style': 2,
|
|
65
|
+
'no-use-before-define': 2,
|
|
66
|
+
'comma-dangle': [
|
|
67
|
+
'error',
|
|
68
|
+
{
|
|
69
|
+
arrays: 'always-multiline',
|
|
70
|
+
objects: 'always-multiline',
|
|
71
|
+
imports: 'always-multiline',
|
|
72
|
+
exports: 'always-multiline',
|
|
73
|
+
functions: 'always-multiline',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
semi: 2,
|
|
28
77
|
'no-console': 0,
|
|
29
78
|
'max-len': 0,
|
|
30
79
|
'no-continue': 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quanxiaoxiao/datav",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
"./package.json": "./package.json"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@eslint/js": "^9.
|
|
15
|
-
"eslint": "^9.
|
|
16
|
-
"
|
|
14
|
+
"@eslint/js": "^9.22.0",
|
|
15
|
+
"eslint": "^9.22.0",
|
|
16
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
17
|
+
"globals": "^15.15.0"
|
|
17
18
|
},
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"registry": "https://registry.npmjs.org"
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
"node": ">= 20.0.0"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@quanxiaoxiao/utils": "^0.
|
|
26
|
+
"@quanxiaoxiao/utils": "^0.16.0",
|
|
26
27
|
"ajv": "^8.12.0",
|
|
27
28
|
"lodash": "^4.17.21"
|
|
28
29
|
}
|
package/src/checkout.mjs
CHANGED
|
@@ -106,10 +106,7 @@ export default (value, type) => {
|
|
|
106
106
|
throw new Error(`\`${type}\` invalid data type`);
|
|
107
107
|
}
|
|
108
108
|
if (value == null) {
|
|
109
|
-
|
|
110
|
-
return [];
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
109
|
+
return type === DATA_TYPE_ARRAY ? [] : null;
|
|
113
110
|
}
|
|
114
111
|
const valueType = typeof value;
|
|
115
112
|
if (valueType !== 'string') {
|
package/src/checkout.test.mjs
CHANGED
package/src/index.mjs
CHANGED
package/src/select/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* eslint no-use-before-define: 0 */
|
|
2
|
-
import _ from 'lodash';
|
|
3
2
|
import { getValueOfPathname } from '@quanxiaoxiao/utils';
|
|
4
|
-
import
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
|
|
5
5
|
import checkout from '../checkout.mjs';
|
|
6
|
+
import check from './check.mjs';
|
|
6
7
|
|
|
7
8
|
function walkWithObject(properties) {
|
|
8
9
|
const keys = Object.keys(properties);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
1
|
import assert from 'node:assert';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
3
4
|
import select from './index.mjs';
|
|
4
5
|
|
|
5
6
|
test('select > index', () => {
|
|
@@ -895,6 +896,30 @@ test('select > index, resolve pathList 2', () => {
|
|
|
895
896
|
});
|
|
896
897
|
});
|
|
897
898
|
|
|
899
|
+
test('select array222', () => {
|
|
900
|
+
const data = {
|
|
901
|
+
data: [
|
|
902
|
+
{
|
|
903
|
+
name: 'aa',
|
|
904
|
+
age: 22,
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
name: 'bb',
|
|
908
|
+
age: 33,
|
|
909
|
+
},
|
|
910
|
+
],
|
|
911
|
+
};
|
|
912
|
+
const ret = select(['.data', {
|
|
913
|
+
type: 'array',
|
|
914
|
+
properties: {
|
|
915
|
+
name: {
|
|
916
|
+
type: 'string',
|
|
917
|
+
},
|
|
918
|
+
},
|
|
919
|
+
}])(data);
|
|
920
|
+
assert.deepEqual(ret, [{ name: 'aa' }, { name: 'bb' }]);
|
|
921
|
+
});
|
|
922
|
+
|
|
898
923
|
test('select array array array', () => {
|
|
899
924
|
const array = [[['11', 22], ['33', 44]], [[1], [2]]];
|
|
900
925
|
const ret = select({
|
|
@@ -1071,18 +1096,18 @@ test('select 888', () => {
|
|
|
1071
1096
|
data: [
|
|
1072
1097
|
{
|
|
1073
1098
|
dir: 'QzpcVmlkZW9ccXExMjM0XDIwMTctMDYtMTlccmVjb3JkXDE=',
|
|
1074
|
-
name: 'qq1234-170619-000000-002000-01p401000000.264'
|
|
1099
|
+
name: 'qq1234-170619-000000-002000-01p401000000.264',
|
|
1075
1100
|
},
|
|
1076
1101
|
{
|
|
1077
1102
|
dir: 'QzpcVmlkZW9ccXExMjM0XDIwMTctMDYtMTlccmVjb3JkXDE=',
|
|
1078
|
-
name: 'qq1234-170619-000000-002000-01p401000000.mp4'
|
|
1079
|
-
}
|
|
1103
|
+
name: 'qq1234-170619-000000-002000-01p401000000.mp4',
|
|
1104
|
+
},
|
|
1080
1105
|
],
|
|
1081
|
-
errorcode: 200
|
|
1106
|
+
errorcode: 200,
|
|
1082
1107
|
});
|
|
1083
1108
|
assert.deepEqual(ret, {
|
|
1084
1109
|
dir: 'QzpcVmlkZW9ccXExMjM0XDIwMTctMDYtMTlccmVjb3JkXDE=',
|
|
1085
|
-
name: 'qq1234-170619-000000-002000-01p401000000.264'
|
|
1110
|
+
name: 'qq1234-170619-000000-002000-01p401000000.264',
|
|
1086
1111
|
});
|
|
1087
1112
|
});
|
|
1088
1113
|
|
|
@@ -1090,7 +1115,7 @@ test('select object empty properties', () => {
|
|
|
1090
1115
|
const data = {
|
|
1091
1116
|
code: 0,
|
|
1092
1117
|
data: {
|
|
1093
|
-
|
|
1118
|
+
name: 'data111',
|
|
1094
1119
|
'/aaa': {
|
|
1095
1120
|
name: '123',
|
|
1096
1121
|
'/ccc': {
|