| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 | <!DOCTYPE html><html lang="en"><head>    <meta charset="utf-8">    <title>JSDoc: Source: src/common.js</title>    <script src="scripts/prettify/prettify.js"> </script>    <script src="scripts/prettify/lang-css.js"> </script>    <!--[if lt IE 9]>      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>    <![endif]-->    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"></head><body><div id="main">    <h1 class="page-title">Source: src/common.js</h1>            <section>        <article>            <pre class="prettyprint source linenums"><code>/** * @license * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */'use strict';var _ = require('lodash');/** * Wrap a function to pass null-like values through without calling it. If no * function is given, just uses the identity. * @private * @param {?function} func The function to wrap * @return {function} The wrapped function */exports.wrapIgnoreNull = function wrapIgnoreNull(func) {  if (!func) {    return _.identity;  }  return function(arg) {    if (arg === null || arg === undefined) {      return null;    }    return func(arg);  };};/** * The logger object for the gRPC module. Defaults to console. * @private */exports.logger = console;/** * The current logging verbosity. 0 corresponds to logging everything * @private */exports.logVerbosity = 0;/** * Log a message if the severity is at least as high as the current verbosity * @private * @param {Number} severity A value of the grpc.logVerbosity map * @param {String} message The message to log */exports.log = function log(severity, message) {  if (severity >= exports.logVerbosity) {    exports.logger.error(message);  }};/** * Default options for loading proto files into gRPC * @alias grpc~defaultLoadOptions */exports.defaultGrpcOptions = {  convertFieldsToCamelCase: false,  binaryAsBase64: false,  longsAsStrings: true,  enumsAsStrings: true,  deprecatedArgumentOrder: false};// JSDoc definitions that are used in multiple other modules/** * Represents the status of a completed request. If `code` is * {@link grpc.status}.OK, then the request has completed successfully. * Otherwise, the request has failed, `details` will contain a description of * the error. Either way, `metadata` contains the trailing response metadata * sent by the server when it finishes processing the call. * @typedef {object} grpc~StatusObject * @property {number} code The error code, a key of {@link grpc.status} * @property {string} details Human-readable description of the status * @property {grpc.Metadata} metadata Trailing metadata sent with the status, *     if applicable *//** * Describes how a request has failed. The member `message` will be the same as * `details` in {@link grpc~StatusObject}, and `code` and `metadata` are the * same as in that object. * @typedef {Error} grpc~ServiceError * @property {number} code The error code, a key of {@link grpc.status} that is *     not `grpc.status.OK` * @property {grpc.Metadata} metadata Trailing metadata sent with the status, *     if applicable *//** * The EventEmitter class in the event standard module * @external EventEmitter * @see https://nodejs.org/api/events.html#events_class_eventemitter *//** * The Readable class in the stream standard module * @external Readable * @see https://nodejs.org/api/stream.html#stream_readable_streams *//** * The Writable class in the stream standard module * @external Writable * @see https://nodejs.org/api/stream.html#stream_writable_streams *//** * The Duplex class in the stream standard module * @external Duplex * @see https://nodejs.org/api/stream.html#stream_class_stream_duplex *//** * A serialization function * @callback grpc~serialize * @param {*} value The value to serialize * @return {Buffer} The value serialized as a byte sequence *//** * A deserialization function * @callback grpc~deserialize * @param {Buffer} data The byte sequence to deserialize * @return {*} The data deserialized as a value *//** * The deadline of an operation. If it is a date, the deadline is reached at * the date and time specified. If it is a finite number, it is treated as * a number of milliseconds since the Unix Epoch. If it is Infinity, the * deadline will never be reached. If it is -Infinity, the deadline has already * passed. * @typedef {(number|date)} grpc~Deadline *//** * An object that completely defines a service method signature. * @typedef {Object} grpc~MethodDefinition * @property {string} path The method's URL path * @property {boolean} requestStream Indicates whether the method accepts *     a stream of requests * @property {boolean} responseStream Indicates whether the method returns *     a stream of responses * @property {grpc~serialize} requestSerialize Serialization *     function for request values * @property {grpc~serialize} responseSerialize Serialization *     function for response values * @property {grpc~deserialize} requestDeserialize Deserialization *     function for request data * @property {grpc~deserialize} responseDeserialize Deserialization *     function for repsonse data *//** * An object that completely defines a service. * @typedef {Object.<string, grpc~MethodDefinition>} grpc~ServiceDefinition */</code></pre>        </article>    </section></div><nav>    <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></nav><br class="clear"><footer>    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Sep 08 2017 11:10:31 GMT-0700 (PDT)</footer><script> prettyPrint(); </script><script src="scripts/linenumber.js"> </script></body></html>
 |