/******************************************
 ************** END INTERFACE *************
 ******************************************/
// ****************
// HELPER FUNCTIONS
// ****************
330421
func newEntry(priority float64) *Entry {
	result := new(Entry)
	result.degree = 0
	result.marked = false
	result.child = nil
	result.parent = nil
	result.next = result
	result.prev = result
	result.Priority = priority
	return result
}
1002416
function parser (inputs, output, plugins, cb) {
  var data = {
    charset: 'UTF-8',
    headers: DEFAULT_HEADERS,
    translations: {
      context: {}
    }
  }

  var defaultContext = data.translations.context

  var headers = data.headers
  headers['plural-forms'] = headers['plural-forms'] || DEFAULT_HEADERS['plural-forms']
  headers['content-type'] = headers['content-type'] || DEFAULT_HEADERS['content-type']

  var nplurals = /nplurals ?= ?(\d)/.exec(headers['plural-forms'])[1]

  inputs
    .forEach(function (file) {
      var resolvedFilePath = path.join(process.cwd(), file)
      var src = fs.readFileSync(resolvedFilePath, 'utf8')

      try {
        var ast = babelParser.parse(src, {
          sourceType: 'module',
          plugins: ['jsx'].concat(plugins)
        })
      } catch (e) {
        console.error(`SyntaxError in ${file} (line: ${e.loc.line}, column: ${e.loc.column})`)
        process.exit(1)
      }

      walk.simple(ast.program, {
        CallExpression: function (node) {
          if (functionNames.hasOwnProperty(node.callee.name) ||
            node.callee.property && functionNames.hasOwnProperty(node.callee.property.name)) {
            var functionName = functionNames[node.callee.name] || functionNames[node.callee.property.name]
            var translate = {}

            var args = node.arguments
            for (var i = 0, l = args.length; i < l; i++) {
              var name = functionName[i]

              if (name && name !== 'count' && name !== 'domain') {
                var arg = args[i]
                var value = arg.value

                if (value) {
                  var line = node.loc.start.line
                  translate[name] = value
                  translate['comments'] = {
                    reference: file + ':' + line
                  }
                }

                if (name === 'msgid_plural') {
                  translate.msgstr = []
                  for (var p = 0; p < nplurals; p++) {
                    translate.msgstr[p] = ''
                  }
                }
              }
            }

            var context = defaultContext
            var msgctxt = translate.msgctxt

            if (msgctxt) {
              data.translations[msgctxt] = data.translations[msgctxt] || {}
              context = data.translations[msgctxt]
            }

            context[translate.msgid] = translate
          }
        }
      })
    })

  fs.writeFile(output, gettextParser.po.compile(data), function (err) {
    if (err) {
      cb(err)
    }
    cb(null)
  })
}
473709
function makeType(param) {
	//console.log('makeType',param);
	param = Array.isArray(param)? param[0]: param;
	var strarr = [];
	if (param.format) {
	    strarr.push(formatType(param.format));
	    if ( Array.isArray(param.type) && param.type.indexOf('null') !== -1 ) {
            strarr.push('Null');
	    }
	    return strarr.join('/');
	}
	var str = '';
	if (Array.isArray(param.type)) {
        param.type.map(function(type){
            str = type;
            if (str === 'array') {
                str = makeType(param.items)+'[]';
            }
            strarr.push(formatType(str));
        });
        return strarr.join('/');
	} else if (param.type) {
	    str = param.type
	    if (str === 'array') {
    		str = makeType(param.items)+'[]';
    	}
    	return formatType(str);
	}

	return 'Unknown';
}
882077
func main() {
	var modelName, outName string
	flag.StringVar(&modelName, "model", "", "Endpoints definition model")
	flag.StringVar(&outName, "out", "", "File to write generated endpoints to.")
	flag.Parse()

	if len(modelName) == 0 || len(outName) == 0 {
		exitErrorf("model and out both required.")
	}

	modelFile, err := os.Open(modelName)
	if err != nil {
		exitErrorf("failed to open model definition, %v.", err)
	}
	defer modelFile.Close()

	outFile, err := os.Create(outName)
	if err != nil {
		exitErrorf("failed to open out file, %v.", err)
	}
	defer func() {
		if err := outFile.Close(); err != nil {
			exitErrorf("failed to successfully write %q file, %v", outName, err)
		}
	}()

	if err := endpoints.CodeGenModel(modelFile, outFile, func(o *endpoints.CodeGenOptions) {
		o.DisableGenerateServiceIDs = true
	}); err != nil {
		exitErrorf("failed to codegen model, %v", err)
	}
}
1221631
function() {
        if (self._eventEmitter && (self._emittedEnd === false)) {
          self._emittedEnd = true;
          self._eventEmitter.emit('end');
        }
        resolve();
      }
352143
function lintJS (args = []) {
  if (!Array.isArray(args)) {
    throw new TypeError('arguments has to be an array')
  }

  const command = [
    `node ${resolveBin('eslint')}`,
    '--format codeframe',
    '"src/**/*.js"',
    ...args
  ].join(' ')

  console.log(chalk`\nCommand:\n{green ${command}}\n`)

  try {
    execSync(command, { stdio: 'inherit' })
  } catch (error) {
    return false
  }

  return true
}
151364
function CreateSend (auth, options) {
    options = options || {};

    var result = {
        wrapperVersion: '0.8.2',
        auth: auth,
        version: 'v3',
        secure: options.secure === undefined ? true : options.secure,
        baseUri: options.baseUri || 'api.createsend.com',

        getCountries: function (callback) {
            this.get('countries.json', null, null, callback);
        },

        getTimezones: function (callback) {
            this.get('timezones.json', null, null, callback);
        },

        getSystemDate: function (callback) {
            this.get('systemdate.json', null, null, function (err, result) {
                if (err) { return callback(err); }
                result.SystemDate = new Date(result.SystemDate.replace(/-/g, '/'));
                callback(null, result);
            });
        },

        request: function (method, path, qs, params, callback, txBool) {
            var uri = ((this.secure) ? 'https' : 'http') + '://' + this.baseUri + '/api/' + (txBool ? 'v3.1' : this.version) + '/' + path;

            Utils.request(this.secure, this.auth, method, uri, qs, params, callback);
        },

        post:   function (path, qs, params, callback, txBool) { this.request('POST',   path, qs, params, callback, txBool); },
        get:    function (path, qs, params, callback, txBool) { this.request('GET' ,   path, qs, params, callback, txBool); },
        put:    function (path, qs, params, callback, txBool) { this.request('PUT' ,   path, qs, params, callback, txBool); },
        delete: function (path, qs, params, callback, txBool) { this.request('DELETE', path, qs, params, callback, txBool); }
    };

    result.account = new Account(result);
    result.campaigns = new Campaigns(result);
    result.clients = new Clients(result);
    result.lists = new Lists(result);
    result.subscribers = new Subscribers(result);
    result.segments = new Segments(result);
    result.transactional = new Transactional(result);
    return result;
}
1001588
function end () {
  var diff = new Date() - startTime

  log('\n\n')
  log('  ' + SYMBOLS.success + ' ' + (stats.success + ' passing ').green)
  log(('(' + diff + 'ms)').grey)

  if (stats.skipped) {
    log('\n  ' + SYMBOLS.skipped + ' ' + (stats.skipped + ' pending').cyan)
  }

  if (stats.failure) {
    log('\n  ' + SYMBOLS.failure + ' ' + (stats.failure + ' failing').red)

    // Log all accumulated errors
    log('\n\n')
    failures.forEach(logError)
  }

  log('\n\n')
}
982204
function() {
    var i, arg;
    for (i = 0 ; i < arguments.length ; i++) {
      arg = arguments[i];
      if (typeof arg === 'number') arg = "" + arg;
      if (typeof arg === 'undefined' || typeof arg === 'null'
          || (typeof arg !== 'object' && typeof arg !== 'string')) {
        console.error("[Widget.append] Argument #" + i + " is invalid!", arguments);
        console.error("[Widget.append] Is type is: " + (typeof arg));
        continue;
      };
      if (typeof arg === 'string') {
        if (arg.length < 1) arg = " ";
        arg = window.document.createTextNode(arg);
        if (!arg) {
          console.error(
            "[Widget.append] Unable to create a text node with this text: ", arg
          );
          console.error("[wdg] arguments=...", arguments);
          throw Error(
            "[Widget.append] Unable to create a text node with this text: "
              + JSON.stringify(arg)
          );
        }
      }
      if (Array.isArray(arg)) {
        arg.forEach(
          function(item) {
            this.append(item);
          }, this
        );
      }
      else {
        var e = arg;
        if( !(e instanceof Node) ) {
          if( e.$ instanceof Node ) e = e.$;
          else if( typeof e.element === 'function' ) e = e.element();
          else if( e.element ) e = e.element;
        }
        this._element.appendChild(e);
      }
    }
    return this;
  }
515954
function fn(end, cb) {
        if (end || fn.ended) return cb(true)
        fn.ended = true
        if (ref.isMsg(dest) && sbot.get) {
          sbot.get(dest, function (err, value) {
            if (err) cb(true)
            else cb(null, {key: dest, value: value})
          })
        } else {
          cb(true)
        }
      }
1342897
function _gpfHttpGenSend (methodName) {
    return function (httpObj, data) {
        if (data) {
            httpObj[methodName](data);
        } else {
            httpObj[methodName]();
        }
    };
}
969021
function middleware(doIt, req, res) {
  const originalEnd = res.end;

  return new Promise(resolve => {
    res.end = function end(...args) {
      originalEnd.apply(this, args);
      resolve(0);
    };
    doIt(req, res, () => {
      resolve(1);
    });
  });
}
1156251
function() {
    if (!ICAL.debug) {
      return;
    }

    if (typeof (console) !== 'undefined' && 'log' in console) {
      ICAL.helpers.dumpn = function consoleDumpn(input) {
        console.log(input);
      };
    } else {
      ICAL.helpers.dumpn = function geckoDumpn(input) {
        dump(input + '\n');
      };
    }

    ICAL.helpers.dumpn(arguments[0]);
  }
1144252
function get(options, endCallback) {

      var reqOptions = initRequestOptions(options);

      var start = new Date();

      //console.log("ops", ops);
      //console.log("options get", options);
      request.get(reqOptions, function(error,response) {

          var end = new Date() - start;
          if (error) {
              return endCallback({code: error.code}, options);
          }

          var result = {};

          result.url = response.request.href;
          result.statusCode = response.statusCode;
          result.responseTime = end;

          // can be usefull to add the proxy into the response to log
          result.proxy = options.proxy;
          result.headers = response.headers;
          result.body = response.body;
          result.method = options.method;

          if (response.headers['content-encoding'] &&
              response.headers['content-encoding'].toLowerCase().indexOf('gzip') >= 0 ) {
              zlib.gunzip(response.body, function (error, body) {
                  if (error) {
                      result = null;
                      return onContent(error, endCallback, options);
                  }

                  result.body = body;

                  onContent(error, endCallback, options,result);
              });
          }
          else {
              onContent(error, endCallback, options,result);
          }

      }).setMaxListeners(0);
  }
1287620
function Callback (retType, argTypes, abi, func) {
  debug('creating new Callback');

  if (typeof abi === 'function') {
    func = abi;
    abi = undefined;
  }

  // check args
  assert(!!retType, 'expected a return "type" object as the first argument');
  assert(Array.isArray(argTypes), 'expected Array of arg "type" objects as the second argument');
  assert.equal(typeof func, 'function', 'expected a function as the third argument');

  // normalize the "types" (they could be strings, so turn into real type
  // instances)
  retType = ref.coerceType(retType);
  argTypes = argTypes.map(ref.coerceType);

  // create the `ffi_cif *` instance
  const cif = CIF(retType, argTypes, abi);
  const argc = argTypes.length;

  const callback = _Callback(cif, retType.size, argc, errorReportCallback, (retval, params) => {
    debug('Callback function being invoked')
    try {
      const args = [];
      for (var i = 0; i < argc; i++) {
        const type = argTypes[i];
        const argPtr = params.readPointer(i * ref.sizeof.pointer, type.size);
        argPtr.type = type;
        args.push(argPtr.deref());
      }

      // Invoke the user-given function
      const result = func.apply(null, args);
      try {
        ref.set(retval, 0, result, retType);
      } catch (e) {
        e.message = 'error setting return value - ' + e.message;
        throw e;
      }
    } catch (e) {
      return e;
    }
  });

  return callback;
}
1181148
function(fn) {
            asyncjs.each(modelNames, function(name, _fn) {
                // get model definition
                var modelDefinition = modelDefinitions[name];
                modelDefinition.__name = name;

                // get connection info
                var connectionInfo = lib.findConnection(mycro, name);
                if (!connectionInfo) {
                    mycro.log('silly', '[models] Unable to find explicit adapter for model (' + name + ')');
                    if (!defaultConnection ) {
                        return _fn('Unable to find adapter for model (' + name + ')');
                    } else {
                        connectionInfo = defaultConnection;
                    }
                }

                // validate handler exists
                var adapter = connectionInfo.adapter;
                if (!adapter.registerModel || !_.isFunction(adapter.registerModel) || adapter.registerModel.length < 3) {
                    return _fn('Invalid adapter api: adapters should define a `registerModel` method that accepts a connection object, model definition object, and a callback');
                }

                // hand off to adapter
                var registerModelCallback = function(err, model) {
                    if (err) {
                        return _fn(err);
                    }
                    if (!model) {
                        return _fn('No model (' + name + ') returned from `adapter.registerModel`');
                    }
                    mycro.models[name] = model;
                    _fn();
                };
                if (adapter.registerModel.length === 3) {
                    return adapter.registerModel(connectionInfo.connection, modelDefinition, registerModelCallback);
                } else if (adapter.registerModel.length === 4) {
                    return adapter.registerModel(connectionInfo.connection, modelDefinition, name, registerModelCallback);
                } else {
                    return adapter.registerModel(connectionInfo.connection, modelDefinition, name, mycro, registerModelCallback);
                }
            }, fn);
        }
1018887
function end () {
      sent = true;
      // next tick it to avoid express catching runtime error in the callback
      //   getting caught by express and triggering app's error handler
      process.nextTick(function () {
        res.emit('finish');
        cb(null, res);
      });
    }