File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,19 @@ util.isObject = function isObject(value) {
70
70
return value && typeof value === "object" ;
71
71
} ;
72
72
73
+ /**
74
+ * Checks if a property on a message is considered present.
75
+ * @param {Object } obj Plain object or message instance
76
+ * @param {string } prop Property name
77
+ * @returns {boolean } `true` if considered present, otherwise `false`
78
+ */
79
+ util . isset = function isset ( message , prop ) {
80
+ var value = obj [ prop ] ;
81
+ if ( value != null && obj . hasOwnProperty ( prop ) )
82
+ return typeof value !== 'object' || ( Array . isArray ( value ) ? value . length : Object . keys ( value ) . length ) > 0 ;
83
+ return false ;
84
+ } ;
85
+
73
86
/*
74
87
* Any compatible Buffer instance.
75
88
* This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
You can’t perform that action at this time.
0 commit comments