File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 4
4
"description" : " A way to truncate a json object." ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "precommit" : " npm run standard && npm run build && npm run cover && npm run coverage-check" ,
7
+ "precommit" : " npm run standard && npm run cover && npm run coverage-check" ,
8
8
"commit" : " git-cz" ,
9
9
"standard" : " standard" ,
10
10
"cover" : " nyc npm t && npm run coverage-report" ,
11
11
"coverage-check" : " nyc check-coverage --branches 100 --statements 100 --functions 100 --lines 100" ,
12
12
"coverage-report" : " nyc report --reporter=lcov" ,
13
- "test" : " _mocha --compilers js:babel-register" ,
13
+ "test" : " npm run build && _mocha --compilers js:babel-register" ,
14
14
"prebuild" : " rimraf dist" ,
15
15
"build" : " babel --copy-files --out-dir dist src" ,
16
16
"coveralls" : " nyc report --reporter=text-lcov | coveralls" ,
Original file line number Diff line number Diff line change 2
2
3
3
const flatTypes = [ String , Number , Boolean ]
4
4
5
- const isFlat = val => {
6
- return flatTypes . indexOf ( val . constructor ) !== - 1
7
- }
8
-
9
5
const isDefined = val => {
10
6
return val !== null && val !== undefined
11
7
}
12
8
9
+ const isFlat = val => {
10
+ return ! isDefined ( val ) || flatTypes . indexOf ( val . constructor ) !== - 1
11
+ }
12
+
13
13
const truncate = ( obj , maxDepth , curDepth ) => {
14
14
curDepth = curDepth || 0
15
15
maxDepth = ( isDefined ( maxDepth ) ) ? maxDepth : 10
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ const createDeep = levels => {
20
20
obj . str = 'You are on level ' + level
21
21
obj . arr = [ true , 1 , 'hi' ]
22
22
obj . sub = { }
23
+ obj . null = null
24
+ obj . undefined = undefined
23
25
return obj
24
26
}
25
27
You can’t perform that action at this time.
0 commit comments