Skip to content

Commit 87eecaf

Browse files
update version
1 parent 3cd48eb commit 87eecaf

File tree

4 files changed

+32
-37
lines changed

4 files changed

+32
-37
lines changed

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ Serialize object to object with key and primitive value.
116116
*/
117117
index: null,
118118

119-
/**
120-
* prefix index for form data key
121-
* defaults to null
122-
*/
123-
toString: null,
124-
125119
/**
126120
* callback fn for convert true or false
127121
* defaults true or false to '1' or '0' respectively

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@idapgroup/js-object-utils",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Javascript functions for transform or mutate object",
55
"main": "build/main/index.js",
66
"module": "build/module/index.js",

src/lib/clean-object.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CleanObjectConfig, NonNullableFields} from '../types/clean-object';
1+
import { CleanObjectConfig, NonNullableFields } from '../types/clean-object';
22

33
import { isObject } from './is-object';
44

src/lib/create-url-params.ts

+30-29
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,42 @@ export const createURLParams = <T extends Record<string, any>>(
3535
return acc;
3636
}
3737
const value =
38-
typeof curr === 'boolean'
39-
? booleanMapper(curr)
40-
: String(curr);
38+
typeof curr === 'boolean' ? booleanMapper(curr) : String(curr);
4139
return { ...acc, [`${keyPrefix}[${i}]`]: value };
4240
}, {});
4341
}
4442

45-
return Object.keys(value).reduce((acc: Record<string, string>, key: string) => {
46-
const keyString = getKeyString(keyPrefix, key, index);
47-
const item = value[key as keyof Record<string, string>];
43+
return Object.keys(value).reduce(
44+
(acc: Record<string, string>, key: string) => {
45+
const keyString = getKeyString(keyPrefix, key, index);
46+
const item = value[key as keyof Record<string, string>];
4847

49-
if (Array.isArray(item)) {
50-
return {
51-
...acc,
52-
...createURLParams(item, {
53-
...config,
54-
keyPrefix: keyString,
55-
}),
56-
};
57-
}
48+
if (Array.isArray(item)) {
49+
return {
50+
...acc,
51+
...createURLParams(item, {
52+
...config,
53+
keyPrefix: keyString,
54+
}),
55+
};
56+
}
5857

59-
if(item === null || item === undefined){
60-
return acc;
61-
}
58+
if (item === null || item === undefined) {
59+
return acc;
60+
}
6261

63-
if (typeof item === 'boolean') {
64-
return { ...acc, [`${keyString}`]: booleanMapper(item) };
65-
}
62+
if (typeof item === 'boolean') {
63+
return { ...acc, [`${keyString}`]: booleanMapper(item) };
64+
}
6665

67-
if (typeof item === 'object') {
68-
return {
69-
...acc,
70-
...createURLParams(item, { ...config, keyPrefix: keyString }),
71-
};
72-
}
73-
return { ...acc, [`${keyString}`]: String(item) };
74-
}, {});
66+
if (typeof item === 'object') {
67+
return {
68+
...acc,
69+
...createURLParams(item, { ...config, keyPrefix: keyString }),
70+
};
71+
}
72+
return { ...acc, [`${keyString}`]: String(item) };
73+
},
74+
{}
75+
);
7576
};

0 commit comments

Comments
 (0)