src_common.js.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: src/common.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: src/common.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/**
  20. * @license
  21. * Copyright 2015, Google Inc.
  22. * All rights reserved.
  23. *
  24. * Redistribution and use in source and binary forms, with or without
  25. * modification, are permitted provided that the following conditions are
  26. * met:
  27. *
  28. * * Redistributions of source code must retain the above copyright
  29. * notice, this list of conditions and the following disclaimer.
  30. * * Redistributions in binary form must reproduce the above
  31. * copyright notice, this list of conditions and the following disclaimer
  32. * in the documentation and/or other materials provided with the
  33. * distribution.
  34. * * Neither the name of Google Inc. nor the names of its
  35. * contributors may be used to endorse or promote products derived from
  36. * this software without specific prior written permission.
  37. *
  38. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  39. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  40. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  41. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  42. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  43. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  44. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  45. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  46. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  47. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  48. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. *
  50. */
  51. 'use strict';
  52. var _ = require('lodash');
  53. /**
  54. * Wrap a function to pass null-like values through without calling it. If no
  55. * function is given, just uses the identity.
  56. * @private
  57. * @param {?function} func The function to wrap
  58. * @return {function} The wrapped function
  59. */
  60. exports.wrapIgnoreNull = function wrapIgnoreNull(func) {
  61. if (!func) {
  62. return _.identity;
  63. }
  64. return function(arg) {
  65. if (arg === null || arg === undefined) {
  66. return null;
  67. }
  68. return func(arg);
  69. };
  70. };
  71. /**
  72. * The logger object for the gRPC module. Defaults to console.
  73. * @private
  74. */
  75. exports.logger = console;
  76. /**
  77. * The current logging verbosity. 0 corresponds to logging everything
  78. * @private
  79. */
  80. exports.logVerbosity = 0;
  81. /**
  82. * Log a message if the severity is at least as high as the current verbosity
  83. * @private
  84. * @param {Number} severity A value of the grpc.logVerbosity map
  85. * @param {String} message The message to log
  86. */
  87. exports.log = function log(severity, message) {
  88. if (severity >= exports.logVerbosity) {
  89. exports.logger.error(message);
  90. }
  91. };
  92. /**
  93. * Default options for loading proto files into gRPC
  94. * @alias grpc~defaultLoadOptions
  95. */
  96. exports.defaultGrpcOptions = {
  97. convertFieldsToCamelCase: false,
  98. binaryAsBase64: false,
  99. longsAsStrings: true,
  100. enumsAsStrings: true,
  101. deprecatedArgumentOrder: false
  102. };
  103. // JSDoc definitions that are used in multiple other modules
  104. /**
  105. * Represents the status of a completed request. If `code` is
  106. * {@link grpc.status}.OK, then the request has completed successfully.
  107. * Otherwise, the request has failed, `details` will contain a description of
  108. * the error. Either way, `metadata` contains the trailing response metadata
  109. * sent by the server when it finishes processing the call.
  110. * @typedef {object} grpc~StatusObject
  111. * @property {number} code The error code, a key of {@link grpc.status}
  112. * @property {string} details Human-readable description of the status
  113. * @property {grpc.Metadata} metadata Trailing metadata sent with the status,
  114. * if applicable
  115. */
  116. /**
  117. * Describes how a request has failed. The member `message` will be the same as
  118. * `details` in {@link grpc~StatusObject}, and `code` and `metadata` are the
  119. * same as in that object.
  120. * @typedef {Error} grpc~ServiceError
  121. * @property {number} code The error code, a key of {@link grpc.status} that is
  122. * not `grpc.status.OK`
  123. * @property {grpc.Metadata} metadata Trailing metadata sent with the status,
  124. * if applicable
  125. */
  126. /**
  127. * The EventEmitter class in the event standard module
  128. * @external EventEmitter
  129. * @see https://nodejs.org/api/events.html#events_class_eventemitter
  130. */
  131. /**
  132. * The Readable class in the stream standard module
  133. * @external Readable
  134. * @see https://nodejs.org/api/stream.html#stream_readable_streams
  135. */
  136. /**
  137. * The Writable class in the stream standard module
  138. * @external Writable
  139. * @see https://nodejs.org/api/stream.html#stream_writable_streams
  140. */
  141. /**
  142. * The Duplex class in the stream standard module
  143. * @external Duplex
  144. * @see https://nodejs.org/api/stream.html#stream_class_stream_duplex
  145. */
  146. /**
  147. * A serialization function
  148. * @callback grpc~serialize
  149. * @param {*} value The value to serialize
  150. * @return {Buffer} The value serialized as a byte sequence
  151. */
  152. /**
  153. * A deserialization function
  154. * @callback grpc~deserialize
  155. * @param {Buffer} data The byte sequence to deserialize
  156. * @return {*} The data deserialized as a value
  157. */
  158. /**
  159. * The deadline of an operation. If it is a date, the deadline is reached at
  160. * the date and time specified. If it is a finite number, it is treated as
  161. * a number of milliseconds since the Unix Epoch. If it is Infinity, the
  162. * deadline will never be reached. If it is -Infinity, the deadline has already
  163. * passed.
  164. * @typedef {(number|date)} grpc~Deadline
  165. */
  166. /**
  167. * An object that completely defines a service method signature.
  168. * @typedef {Object} grpc~MethodDefinition
  169. * @property {string} path The method's URL path
  170. * @property {boolean} requestStream Indicates whether the method accepts
  171. * a stream of requests
  172. * @property {boolean} responseStream Indicates whether the method returns
  173. * a stream of responses
  174. * @property {grpc~serialize} requestSerialize Serialization
  175. * function for request values
  176. * @property {grpc~serialize} responseSerialize Serialization
  177. * function for response values
  178. * @property {grpc~deserialize} requestDeserialize Deserialization
  179. * function for request data
  180. * @property {grpc~deserialize} responseDeserialize Deserialization
  181. * function for repsonse data
  182. */
  183. /**
  184. * An object that completely defines a service.
  185. * @typedef {Object.&lt;string, grpc~MethodDefinition>} grpc~ServiceDefinition
  186. */
  187. </code></pre>
  188. </article>
  189. </section>
  190. </div>
  191. <nav>
  192. <h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-Duplex.html">Duplex</a></li><li><a href="external-EventEmitter.html">EventEmitter</a></li><li><a href="external-GoogleCredential.html">GoogleCredential</a></li><li><a href="external-Readable.html">Readable</a></li><li><a href="external-Writable.html">Writable</a></li></ul><h3>Classes</h3><ul><li><a href="grpc.Client.html">Client</a></li><li><a href="grpc.credentials-CallCredentials.html">CallCredentials</a></li><li><a href="grpc.credentials-ChannelCredentials.html">ChannelCredentials</a></li><li><a href="grpc.Metadata.html">Metadata</a></li><li><a href="grpc.Server.html">Server</a></li><li><a href="grpc.ServerCredentials.html">ServerCredentials</a></li><li><a href="grpc-ClientDuplexStream.html">ClientDuplexStream</a></li><li><a href="grpc-ClientReadableStream.html">ClientReadableStream</a></li><li><a href="grpc-ClientUnaryCall.html">ClientUnaryCall</a></li><li><a href="grpc-ClientWritableStream.html">ClientWritableStream</a></li><li><a href="grpc-ServerDuplexStream.html">ServerDuplexStream</a></li><li><a href="grpc-ServerReadableStream.html">ServerReadableStream</a></li><li><a href="grpc-ServerUnaryCall.html">ServerUnaryCall</a></li><li><a href="grpc-ServerWritableStream.html">ServerWritableStream</a></li></ul><h3>Events</h3><ul><li><a href="grpc-ClientDuplexStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientDuplexStream.html#event:status">status</a></li><li><a href="grpc-ClientReadableStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientReadableStream.html#event:status">status</a></li><li><a href="grpc-ClientUnaryCall.html#event:metadata">metadata</a></li><li><a href="grpc-ClientUnaryCall.html#event:status">status</a></li><li><a href="grpc-ClientWritableStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientWritableStream.html#event:status">status</a></li><li><a href="grpc-ServerDuplexStream.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerReadableStream.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerUnaryCall.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerWritableStream.html#~event:cancelled">cancelled</a></li></ul><h3>Namespaces</h3><ul><li><a href="grpc.html">grpc</a></li><li><a href="grpc.credentials.html">credentials</a></li></ul>
  193. </nav>
  194. <br class="clear">
  195. <footer>
  196. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Wed Jun 28 2017 09:44:06 GMT-0700 (PDT)
  197. </footer>
  198. <script> prettyPrint(); </script>
  199. <script src="scripts/linenumber.js"> </script>
  200. </body>
  201. </html>