JSON RPC
@alias module:http.RPCBase
@constructor
969878
function RPCBase() {
  if (!(this instanceof RPCBase))
    return new RPCBase();

  EventEmitter.call(this);

  this.logger = Logger.global;
  this.calls = Object.create(null);
  this.mounts = [];
  this.locker = new Lock();
}
473857
function createClient() {
	rpc.emit('createClient', 'test', {
		nick : 'simpleircbot',
		user : 'testuser',
		server : 'localhost',
		realname: 'realbot',
		port: 6667,
		secure: false,
		retryCount: 2,
		retryWait: 3000
	});
}
1239164
function ( json ) {
    pageNotFoundJson = sqsUtil.copy( json );
    pageNotFoundJson.collection = {};
    pageNotFoundJson.error = true;
}
277405
function baseRequest(uri, cb) {
  var url = `${BASE_URL}${uri}`;
  request(url, function (error, response, body) {
    debug(`Url: ${url} statusCode: ${response && response.statusCode}`);
    if(error || (response && response.statusCode === 404)) {
       cb(error || response);
    }
    cb(null, JSON.parse(body));
  });
}
767495
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof SourceDescription)){
    return new SourceDescription(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(SourceDescription.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
702727
function couchdb (json) {
  return {
    prepareEndpoint (endpointOptions, sourceOptions) {
      return prepareEndpoint(json, endpointOptions, sourceOptions)
    },

    async send (request) {
      return send(json, request)
    },

    async serialize (data, request) {
      const serializedData = await serializeData(data, request, json)
      return json.serialize(serializedData, request)
    },

    async normalize (data, request) {
      const normalizedData = await json.normalize(data, request)
      return normalizeData(normalizedData)
    }
  }
}
700169
function requestJson(options, callback) {
  const proto = options.protocol === 'https:' ? https
    : options.protocol === 'http:' ? http
      : null;
  if (!proto) {
    callback(
      new Error(`Unsupported protocol "${options.protocol}" for validator URL`)
    );
    return;
  }

  const req = proto.request(options)
    .once('error', callback)
    .once('response', (res) => {
      res.on('error', callback);
      const bodyData = [];
      res.on('data', (data) => { bodyData.push(data); });
      res.on('end', () => {
        const resBody = Buffer.concat(bodyData);
        let err, resBodyObj;
        try {
          resBodyObj = JSON.parse(resBody.toString());
        } catch (errJson) {
          err = new SyntaxError(
            `Error parsing server response as JSON: ${errJson.message}`
          );
        }

        if (res.statusCode >= 300) {
          let errMessage = `HTTP ${res.statusCode}`;
          if (res.statusMessage) {
            errMessage += `: ${res.statusMessage}`;
          }
          err = new Error(errMessage);
        }

        if (err) {
          err.statusCode = res.statusCode;
          err.statusMessage = res.statusMessage;
          err.headers = res.headers;
          err.trailers = res.trailers;
          err.body = resBodyObj !== undefined ? resBodyObj : resBody;
          callback(err);
        } else {
          callback(null, resBodyObj);
        }
      });
    });

  const {body} = options;
  if (typeof body === 'string' || Buffer.isBuffer(body)) {
    req.end(body);
  } else {
    body.on('error', (err) => {
      req.abort();
      callback(err);
    });
    body.pipe(req);
  }
}
919153
def post_json(path, object_to_post, response_type = nil)
      response_type = SimpleSolrClient::Response::GenericResponse if response_type.nil?
      response_type.new(_post_json(path, object_to_post))
    end
142222
function rJson(path, callback) {

    if (typeof callback === "function") {
        Fs.readFile(path, "utf-8", function (err, data) {
            try {
                data = JSON.parse(data);
            } catch (e) {
                err = err || e;
            }
            callback(err, data);
        });
        return;
    }

    return JSON.parse(Fs.readFileSync(path));
}
1123195
def json_data(self, instance, default=[]):
        
        value = self.get(instance)
        out = map(api.get_url_info, value)
        return out or default
113836
function (json, lib) {

        // Create skeletons and joints
        util$1.each(json.skins, function (skinInfo, idx) {
            var skeleton = new Skeleton({
                name: skinInfo.name
            });
            for (var i = 0; i < skinInfo.joints.length; i++) {
                var nodeIdx = skinInfo.joints[i];
                var node = lib.nodes[nodeIdx];
                var joint = new Joint({
                    name: node.name,
                    node: node,
                    index: skeleton.joints.length
                });
                skeleton.joints.push(joint);
            }
            skeleton.relativeRootNode = lib.nodes[skinInfo.skeleton] || this.rootNode;
            if (skinInfo.inverseBindMatrices) {
                var IBMInfo = json.accessors[skinInfo.inverseBindMatrices];
                var buffer = lib.bufferViews[IBMInfo.bufferView];

                var offset = IBMInfo.byteOffset || 0;
                var size = IBMInfo.count * 16;

                var array = new vendor.Float32Array(buffer, offset, size);

                skeleton.setJointMatricesArray(array);
            }
            else {
                skeleton.updateJointMatrices();
            }
            lib.skeletons[idx] = skeleton;
        }, this);

        function enableSkinningForMesh(mesh, skeleton, jointIndices) {
            mesh.skeleton = skeleton;
            mesh.joints = jointIndices;

            if (!skeleton.boundingBox) {
                skeleton.updateJointsBoundingBoxes(mesh.geometry);
            }
        }

        function getJointIndex(joint) {
            return joint.index;
        }

        util$1.each(json.nodes, function (nodeInfo, nodeIdx) {
            if (nodeInfo.skin != null) {
                var skinIdx = nodeInfo.skin;
                var skeleton = lib.skeletons[skinIdx];

                var node = lib.nodes[nodeIdx];
                var jointIndices = skeleton.joints.map(getJointIndex);
                if (node instanceof Mesh) {
                    enableSkinningForMesh(node, skeleton, jointIndices);
                }
                else {
                    // Mesh have multiple primitives
                    var children = node.children();
                    for (var i = 0; i < children.length; i++) {
                        enableSkinningForMesh(children[i], skeleton, jointIndices);
                    }
                }
            }
        }, this);
    }
1124026
function getJsonResource(url) {

    var protocol = url.match(/^(.*?):/)
    protocol = (protocol && protocol[1]) || 'file'

    const defaultLoader = defaultOptions.loaders[protocol]
    const loader = options.loaders[protocol]

    return Promise.resolve(cache[url])
    .then(cached => {
      if(cached) {
        return cached
      } else {
        return loader(url, defaultOptions.loaders)
          .then(json => cache[url] = {raw: json, parsed: Array.isArray(json) ? [] : {} })
      }
    })
  }
979904
function RequestBase () {
    // `_baseUrl` and `self` are private variables
    var _baseUrl,
        self = this;

    this.getBaseUrl = function () {
      if (_baseUrl) {
        return _baseUrl;
      }
    };

    this.setBaseUrl = function (baseUrl) {
      _baseUrl = baseUrl;
    };

    /**
     * Checks to make sure the request was a success
     * @param  {Object}  res   A response object
     * @return {Boolean}       A boolean denoting whether the request was a success
     */
    this.isSuccess = function (res) {
      var success = function (status) {
        return status >= 200 && status < 300;
      };
      if (res && success(res.statusCode)) {
        return true;
      }
      return false;
    };

    this.buildOptions = function (path, method, payload) {
      var options,
          accessToken = this.getAccessToken(),
          relayIdentifier = this.getRelayIdentifier(),
          baseUrl = self.getBaseUrl(),
          url = self.constructUrl(baseUrl, path);

      options = {
        uri: url,
        method: method,
        headers: {}
      };

      if (accessToken) {
        options.headers.Authorization = 'Access-Token ' + accessToken;
      } else {
        throw new Error('The required Access Token is missing or malformed');
      }

      if (relayIdentifier) {
        options.headers['Relay-Identifier'] = relayIdentifier;
      }

      if (method && method.toUpperCase() === 'GET') {
        options.qs = payload;
      } else {
        options.json = payload;
      }
      return options;
    };

    this.constructUrl = function (url, path) {
      if (url.slice(-1) === '/' && path.slice(0, 1) === '/') {
        return url.slice(0, -1) + path;
      } else if (url.slice(-1) !== '/' && path.slice(0, 1) !== '/') {
        return url + '/' + path;
      }
      return url + path;
    };

    this.sendRequest = function (path, method, payload) {
      var options = self.buildOptions(path, method, payload),
          reqHandle = request(options).spread(function (response, body) {
            var resp = {},
                responseBody;
            try {
              if (typeof body === 'string') {
                responseBody = JSON.parse(body);
              } else {
                responseBody = body;
              }
            } catch (err) {
              throw new Error('An error occurred parsing the following response from the server: ' + body);
            }
            resp.body = responseBody;
            if (self.isSuccess(response)) {
              resp.getData = function () {
                return resp.body.data;
              };
              resp.isEmpty = function () {
                return Object.getOwnPropertyNames(resp.getData()).length === 0;
              };
              resp.getDataLength = function () {
                var data = resp.getData();
                if (resp.isEmpty()) {
                  return 0;
                } else if (!(data instanceof Array)) {
                  return 1;
                } else {
                  return data.length;
                }
              };
              if (method === 'GET' && resp.body.paging) {
                var pageSize, thisPage, prevPage, nextPage, pageFunc;
                pageSize = resp.body.paging['per_page'];
                thisPage = resp.body.paging.page;
                prevPage = (thisPage === 1 ? thisPage : thisPage - 1);
                nextPage = thisPage + 1;
                pageFunc = function (pageNum) {
                  var _pageNum;
                  _pageNum = pageNum;
                  return function () {
                    payload = (payload === undefined || !payload) ? {} : payload;
                    payload.page = _pageNum;
                    payload['per_page'] = pageSize;
                    return self.sendRequest(path, method, payload);
                  };
                };
                resp.nextPage = pageFunc(nextPage);
                resp.prevPage = pageFunc(prevPage);
              }
              return resp;
            } else {
              throw new error.ApiError(resp);
            }
          });
      return reqHandle;
    };
  }
507711
function API(opts) {
  opts = opts || {};

  this.verbose = !!opts.verbose;
  this.request = opts.request || request;
  this.baseUrl = opts.baseUrl || BASE_URL;
  var parsedUrl = url.parse(this.baseUrl);
  this.basePath = parsedUrl.path;
  this.baseHost = parsedUrl.protocol + '//' + parsedUrl.host;
  this.timeout = opts.timeout || 50000;

  if (this.verbose) {
    log.setLevel('debug');
  } else {
    log.setLevel('info');
  }
}
1235479
function callApi(endpoint, schema) {
  const fullUrl = (endpoint.indexOf(API_ROOT) === -1) ? API_ROOT + endpoint : endpoint;

  return fetch(fullUrl)
    .then(response =>
      response.json().then(json => ({ json, response }))
    ).then(({ json, response }) => {
      if (json.error) {
        throw new Error(json.error);
      }
      if (!response.ok) {
        throw new Error(json && json.message || response.statusText || response.status + ' http error');
      }

      const camelizedJson = camelizeKeys(json);
      const nextPageUrl = getNextPageUrl(response);

      return Object.assign({},
        normalize(camelizedJson, schema),
        { nextPageUrl }
      );
    })
    .then(
      response => ({response})
    );
}
540608
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof Identifiers)){
    return new Identifiers(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(Identifiers.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
104845
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof ResourceReference)){
    return new ResourceReference(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(ResourceReference.isInstance(json)){
    return json;
  }
  
  this.init(json);
}