Skip to content

Commit f5fd112

Browse files
committed
fix: 'keys' method now returns empty array for non-object inputs
1 parent 6f4dc6a commit f5fd112

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

defaultMethods.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ const defaultMethods = {
369369
'!': (value) => Array.isArray(value) ? !value[0] : !value,
370370
'!!': (value) => Boolean(Array.isArray(value) ? value[0] : value),
371371
cat: (arr) => (typeof arr === 'string' ? arr : arr.join('')),
372-
keys: (obj) => Object.keys(obj),
372+
keys: (obj) => typeof obj === 'object' ? Object.keys(obj) : [],
373373
eachKey: {
374374
traverse: false,
375375
method: (object, context, above, engine) => {

0 commit comments

Comments
 (0)