A upyun receiver for Skipper that writes Upstreams to
upyun at the configured path.

@param  {Object} opts
@return {Stream.Writable}
165134
function buildUpyunReceiverStream(opts) {
  var options = opts || {};

  _.defaults(options, {

    endpoing: 'v0',
    apiVersion: 'legacy',

    // Upload limit (in bytes)
    // defaults to ~15MB
    maxBytes: 15000000,

    // Upload limit for per coming file (in bytes)
    // falsy means no limit
    perMaxBytes: 15000000,

    // Upload limit for per file (in content-type)
    // falsy means accept all the type
    acceptTypes: null,

  });

  var receiver__ = WritableStream({ objectMode: true });

  // if onProgress handler was provided, bind an event automatically:
  if (_.isFunction(options.onProgress)) {
    receiver__.on('progress', options.onProgress);
  }

  // Track the progress of all file uploads that pass through this receiver
  // through one or more attached Upstream(s).
  receiver__._files = [];

  // This `_write` method is invoked each time a new file is received
  // from the Readable stream (Upstream) which is pumping filestreams
  // into this receiver.  (filename === `__newFile.filename`).
  receiver__._write = onFile.bind({ options });

  return receiver__;
}
1199411
function UriDataCharateristic(opts) {
	UriDataCharateristic.super_.call(this, objectAssign({
		uuid: 'ee0c2084-8786-40ba-ab96-99b91ac981d8',
		properties: ['read', 'write']
	}, opts));

	this.on('beforeWrite', function(data, res) {
		res(Results.Success);
	});

	this.toBuffer = encoding.encode;
	this.fromBuffer = encoding.decode;
}
535923
function stream(opts) {
  opts = lo.isObject(opts) ? opts : {}
  config.input = opts.input || process.stdin
  config.output = opts.output || process.stdout
}
1073354
function handler(opts) {
	Object.assign(values, opts);

	const configPath = path.join(os.homedir(), ".moleculer-templates.json");
	return (
		Promise.resolve()
			//check for existing template alias config file
			.then(() => {
				return new Promise((resolve, reject) => {
					fs.exists(configPath, exists => {
						if (exists) {
							fs.readFile(configPath, (err, config) => {
								if (err) {
									reject();
								}
								values.aliasedTemplates = JSON.parse(config);
								resolve();
							});
						} else {
							resolve();
						}
					});
				});
			})
			// check if template name already exists
			.then(() => {
				const { templateName, aliasedTemplates } = values;
				if (aliasedTemplates[templateName]) {
					// if exists ask for overwrite
					return inquirer.prompt([{
						type: "confirm",
						name: "continue",
						message: chalk.yellow.bold(`The alias '${templateName}' already exists with value '${aliasedTemplates[templateName]}'! Overwrite?`),
						default: false
					}]).then(answers => {
						if (!answers.continue)
							process.exit(0);
					});
				}
			})
			// write template name and repo url
			.then(() => {
				const { templateName, templateUrl, aliasedTemplates } = values;
				const newAliases = JSON.stringify(Object.assign(aliasedTemplates, { [templateName]: templateUrl }));
				fs.writeFileSync(configPath, newAliases);
			})
			.catch(err => fail(err))
	);
}
640416
function defineRoute (server, opts) {

    server.route({
        method: 'GET',
        path: '/bomb',
        handler: handler,
        config: {
            jsonp: 'callback',
            validate: {
                query: {
                    count: Hapi.types.Number()
                },
                payload: false
            }
        }
    });

    function handler (req) {
        var count = (req.query.count || opts.defaultBombCount);
        var res = {};
        res[opts.plural] = _.sample(opts.things, count);
        req.reply(res);
    }

}
90709
function writeStreamToFs(opts, stream) {
    var baseDir = path.join(opts.cwd, opts.directory);
    var walker = walk.walk(baseDir);

    walker.on('errors', function (root, stats, next) {
        stream.emit('error', new PluginError(PLUGIN_NAME, stats.error));
        next();
    });
    walker.on('directory', function (root, stats, next) {
        next();
    });

    walker.on('file', function (root, stats, next) {
        var filePath = path.resolve(root, stats.name);

        fs.readFile(filePath, function (error, data) {
            if (error) {
                stream.emit('error', new PluginError(PLUGIN_NAME, error));
            } else {
                stream.write(new Vinyl({
                    path: path.relative(baseDir, filePath),
                    contents: data
                }));
            }

            next();
        });
    });

    walker.on('end', function () {
        stream.emit('end');
        stream.emit('finish');
    });
}
1026430
function Client(opts) {

    this.opts = new clientOptions(opts)
    this.streamData = {}
    this.currentIndex = 0
    this.cachedItems = new lru({maxSize: this.opts.maxCacheSize})
}
1236060
function addService(opts) {
	let values = Object.assign({}, opts);

	return Promise.resolve()
		.then(() => {
			return inquirer.prompt([
				{
					type: "input",
					name: "serviceFolder",
					message: "Service directory",
					default: "./services",
					validate(input) {
						if (!fs.existsSync(path.resolve(input)))
							return `The '${input}' directory is not exists! Full path: ${path.resolve(input)}`;

						return true;
					}
				},
				{
					type: "input",
					name: "serviceName",
					message: "Service name",
					default: "test"
				}
			]).then(answers => {
				Object.assign(values, answers);

				const newServicePath = path.join(values.serviceFolder, values.serviceName + ".service.js");
				values.newServicePath = newServicePath;

				if (fs.existsSync(newServicePath)) {
					return inquirer.prompt([{
						type: "confirm",
						name: "sure",
						message: "The file is exists! Overwrite?",
						default: false
					}]).then(({ sure }) => {
						if (!sure)
							fail("Aborted");
					});
				}
			});
		})
		.then(() => {
			const templatePath = path.join(__dirname, "service.template");
			const template = fs.readFileSync(templatePath, "utf8");

			return new Promise((resolve, reject) => {
				render(template, values, function (err, res) {
					if (err)
						return reject(err);

					const { newServicePath } = values;
					console.log(`Create new service file to '${newServicePath}'...`);
					fs.writeFileSync(path.resolve(newServicePath), res, "utf8");

					resolve();
				});
			});
		})

		// Error handler
		.catch(err => fail(err));
}
1159944
function (opts, id) {
        let uri = this.classUrl
        if (id) {
          uri += '/' + id
        }

        return new Promise(function (resolve, reject) {
          new Requestor({ api_version: instance.api_version }).request({
            method: 'post',
            url: [Conekta.api_base, uri].join(''),
            data: opts.data || {},
            next: function (error, response) {
              if (!error) {
                response = this.listObjectsToArray(response)
                this._json = response
                this._id = response.id
                this.build_children()
              }
              if (opts.next !== undefined) {
                opts.next(error, this)
              } else {
                if (error) {
                  reject(error)
                } else {
                  resolve(this)
                }
              }
            }.bind(this)
          })
        }.bind(this))
      }
903986
function Link (opts) {
  if(!opts) opts = {}
  this.timeout = opts.timeout || 10*SECONDS
  this.localTransmissionId = 0
  this.lastRemoteTransmissionId = null
  this.credentials = opts.credentials
  this.authenticateFn = opts.authenticate
  this.authorizeReadFn = opts.authorizeRead
  this.authorizeWriteFn = opts.authorizeWrite
  this.authenticated
  this.sentEdit
  this.sentRequestInit
  this.queue
  this.linkBuffer = ''

  Duplex.call(this, {allowHalfOpen: false, objectMode: true})

  this.on('error', function(er) {
    debug('Error in link', 'undefined'!=typeof window? er : er.stack || er)
  }.bind(this))

  this.on('editError', function(er) {
    debug('EditError in link', 'undefined'!=typeof window? er : er.stack || er)
  })

  this.reset()
}
462314
function SendStream (req, path, options) {
  Stream.call(this)

  var opts = options || {}

  this.options = opts
  this.path = path
  this.req = req

  this._acceptRanges = opts.acceptRanges !== undefined
    ? Boolean(opts.acceptRanges)
    : true

  this._cacheControl = opts.cacheControl !== undefined
    ? Boolean(opts.cacheControl)
    : true

  this._etag = opts.etag !== undefined
    ? Boolean(opts.etag)
    : true

  this._dotfiles = opts.dotfiles !== undefined
    ? opts.dotfiles
    : 'ignore'

  if (this._dotfiles !== 'ignore' && this._dotfiles !== 'allow' && this._dotfiles !== 'deny') {
    throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"')
  }

  this._hidden = Boolean(opts.hidden)

  if (opts.hidden !== undefined) {
    deprecate('hidden: use dotfiles: \'' + (this._hidden ? 'allow' : 'ignore') + '\' instead')
  }

  // legacy support
  if (opts.dotfiles === undefined) {
    this._dotfiles = undefined
  }

  this._extensions = opts.extensions !== undefined
    ? normalizeList(opts.extensions, 'extensions option')
    : []

  this._immutable = opts.immutable !== undefined
    ? Boolean(opts.immutable)
    : false

  this._index = opts.index !== undefined
    ? normalizeList(opts.index, 'index option')
    : ['index.html']

  this._lastModified = opts.lastModified !== undefined
    ? Boolean(opts.lastModified)
    : true

  this._maxage = opts.maxAge || opts.maxage
  this._maxage = typeof this._maxage === 'string'
    ? ms(this._maxage)
    : Number(this._maxage)
  this._maxage = !isNaN(this._maxage)
    ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE)
    : 0

  this._root = opts.root
    ? resolve(opts.root)
    : null

  if (!this._root && opts.from) {
    this.from(opts.from)
  }
}
63503
function here (rstream, opts) {
    opts = opts || {}

    var resources = []
    var sort = opts.sort
    var namespace = opts.name
    var transform = opts.transform
    var prefix = opts.prefix
    var done // flag for resouce stream
    var waitting

    function collectResources(cb) {
        if (waitting) {
            waitting.push(cb)
        } else if (done) {
            cb(resources)
        } else if (rstream._done) {
            cb(rstream._resources || [])
        } else {
            waitting = []
            rstream.pipe(map(function (file, next) {
                resources.push(file)
                next(null, file)
            })).on('end', function () {
                rstream._done = done = true
                rstream._resources = resources
                cb(resources)
                var queue = waitting
                waitting = null
                setTimeout(function () {
                    queue.forEach(function (c) {
                        c(resources)
                    })
                })
            })
        }
    }
    /**
     * Handle each template file independ
     */
    return es.map(function (tpl, cb) {
        if (tpl.isStream()) {
            this.emit('error', new PluginError(PLUGIN_NAME, 'Stream is not supported for template target!'))
            return cb(null, tpl)
        }
        if (tpl.isNull()) {
            this.emit('error', new PluginError(PLUGIN_NAME, 'Template target should not be null!'))
            return cb(null, tpl)
        }

        var content = tpl.contents.toString()
        var ast = parser(content)

        collectResources(function (resources) {
            var count = 0
            function walk(node, scope) {
                var output = ''
                var isBlock
                switch(node.nodeType) {
                    // root node of ast
                    case 1:
                        output += node.childNodes.map(function (n) {
                            return walk(n, scope)
                        }).join('')
                        break
                    // open tag
                    case 2:
                        isBlock = true
                    // self closing tag
                    case 3:
                        // expression form tag
                        var expression = isBlock ? node.openHTML : node.outerHTML
                        var starttag = isBlock ? expression : expression.replace(/\/-->$/, '-->')
                        var endtag = isBlock ? node.closeHTML : '<!--/here-->'
                        var exprObj = Tag.expr(expression)
                        if (exprObj) {
                            output += starttag
                            if ( 
                                (!namespace && exprObj.namespace) || 
                                (namespace && (exprObj.namespace !== namespace && exprObj.namespace !== '*') ) 
                            ) {
                                if (node.childNodes.length) {
                                    output += node.childNodes.map(function (n) {
                                        return n.toString()
                                    }).join('')
                                }
                                output += endtag
                                break
                            } else {
                                var tagObj = {
                                    inline: exprObj.inline,
                                    wrap: exprObj.wrap,
                                    namespace: exprObj.namespace,
                                    wrapresult: false,
                                    relative: true // default set relative, if not url path
                                }
                                var rs = resources.slice(0)

                                rs = rs.reduce(function (next, file) {
                                    if (exprObj.regexp.test(file.path)) {
                                        next.push(file)
                                    }
                                    return next
                                }, [])


                                if (rs.length > 1 && sort) {
                                    rs = sort(rs, tpl, tagObj)
                                }

                                output += rs.map(function (file) {
                                    var result = true
                                    var opts = _.extend({}, tagObj)

                                    file = file.clone()
                                    // marked as dirty will not set relative path
                                    if (typeof prefix === 'function') {
                                        file.path = prefix(file, tpl, opts)
                                    } else if (typeof prefix === 'string') {
                                        file.path = prefix + file.relative
                                    }
                                    if (transform) {
                                        result = transform(file, tpl, opts)
                                    }
                                    count ++
                                    if (result === true) {
                                        return opts.inline 
                                            ? Tag.inline(file, tpl, opts) 
                                            : Tag.transform(file, tpl, opts)
                                    } else if (result && opts.wrapresult) {
                                        return Tag.transform(result, opts)
                                    } else if (result) {
                                        return result
                                    } else {
                                        count --
                                        return ''
                                    }
                                }).join('')
                            }
                            output += endtag

                        } else {
                            this.emit('error', new PluginError(PLUGIN_NAME, 'Unvalid expression:"' + expression +'"'))
                            break
                        }
                        break
                    case 4:
                        output += node.nodeValue
                }
                return output   
            }
            tpl.contents = new Buffer(walk(ast))
            gutil.log(
                PLUGIN_NAME + ': ' + colors.yellow(count ? '✔ ' : '❗ ') +
                colors.cyan(namespace ? '[' + namespace + '] ' : ' ' ) + 'Release', 
                colors.green(count), 
                'files to', 
                colors.blue(path.basename(tpl.path))
            )
            cb(null, tpl)
        })
    })
}
605667
function readStream(opts) {
    return db.createReadStream(ns.encodeRange(opts)).pipe(decodeStream(opts))
  }
1180266
function stream_open($path, $mode, $options, &$opened_path)
    {
        $path = $this->cleanUpPath($path);

        $this->fp = fopen($path, $mode, $options);

        return $this->fp !== false;
    }
765877
function Stream (options) {

  //check options
  if (!options) {

    throw new Error('Initialization error: missing transport options')
  }

  this._initDefaults() //Initialize default params
  this._updateParams(options)
  this._initTransport(options.transport)

  var self = this

  self.on('error', nop)

  this.subscriptions = []

  this.getSubscriptions = function () {

    return this.subscriptions
  }

  this.addSubscription = function (args, callback) {

    var c = new Subscription(args, callback, this)
    this.subscriptions[c.eid] = c
    return c
  }

  this.getSubscription = function (channel, resource) {

    if (this.subscriptions[channel + this.seperator + resource]) {
      return this.subscriptions[channel + this.seperator + resource]
    }
    return null
  }

  this.getAnySubscription = function (channel, resource) {

    if (this.subscriptions[channel + this.seperator + resource]) {
      return this.subscriptions[channel + this.seperator + resource]
    } else if (this.subscriptions[channel + this.seperator + this.wildcard]) {
      return this.subscriptions[channel + this.seperator + this.wildcard]
    } else {
      return null
    }
  }

  this.removeSubscription = function (channel, resource) {

    resource = resource || this.wildcard
    if (this.subscriptions[channel + this.seperator + resource]) {
      var retval = this.subscriptions[channel + this.seperator + resource]
      delete this.subscriptions[channel + this.seperator + resource]
      return retval
    }

    return null
  }

  this.getSubscriptionWithPermission = function (channel, resource, read, write) {

    var Subscription = this.subscriptions[channel + this.seperator + resource]
    var match = false

    if (Subscription) {

      match = true

      if (read) {
        match = Subscription.hasReadPermission()
      }

      if (write) {
        match = Subscription.hasWritePermission()
      }

      if (match) {
        return Subscription
      }
    } else {

      Subscription = this.subscriptions[channel + this.seperator + this.wildcard]

      if (Subscription) {

        match = true

        if (read) {
          match = Subscription.hasReadPermission()
        }

        if (write) {
          match = Subscription.hasWritePermission()
        }

        if (match) {
          return Subscription
        }
      }
    }

    return null
  }

  this.connection = new this.ConnectionFactory(this)
  this.connect()
}
576866
function (opt, handler) {

			var recquire_t = require('aureooms-node-recursive-require');
			var extend = require('node.extend');

			var dflt = {
				name: undefined,
				src: undefined,
				exports: undefined,
				base: 0,
				index: 'index.js',
				intro: 'intro.js',
				outro: 'outro.js',
				rec: false,
				flat: true,
				debug: false
			};

			opt = extend({}, dflt, opt);

			if (opt.name) opt.name = opt.name.replace(/-/g, '');

			var recquire = recquire_t(opt);

			recquire(opt.src, opt.exports, -opt.base, handler);
		}
120359
function genUrl(opts, path) {
  // If the host already has a path, then we need to have a path delimiter
  // Otherwise, the path delimiter is the empty string
  var pathDel = !opts.path ? '' : '/';

  // If the host already has a path, then we need to have a path delimiter
  // Otherwise, the path delimiter is the empty string
  return opts.protocol + '://' + opts.host +
         (opts.port ? (':' + opts.port) : '') +
         '/' + opts.path + pathDel + path;
}