File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 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) {
7070 return value && typeof value === "object" ;
7171} ;
7272
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+
7386/*
7487 * Any compatible Buffer instance.
7588 * 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