Compose queue

@param {string} [name]
@returns {Use}
@example
usecase('name').use([f1, f2])(param)
usecase('name').use(f1).use(f2)(param)
335568
function usecase(name) {
        let $queue = [];
        let $run;
        return { use };
        function use(arg) {
            let q = [].concat(arg);
            q = $enhancer ? q.map((t) => $enhancer(name, t)) : q;
            q.forEach(t => $queue.push(t));
            return $run || (() => {
                $run = run;
                $run.use = use;
                return $run;
            })();
        }
        function run() {
            next($queue[Symbol.iterator](), arguments[0]);
        }
        ;
    }
910538
function(name) {
			var args = [].slice.call(arguments, 1);
			var factory = this.get(name);
			return factory ? factory.apply(this, args) : null;
		}
1257346
public static function compose($functionA, $functionB)
    {
        return function ($input) use ($functionA, $functionB) {
            return Functions::call($functionA, Functions::call($functionB, $input));
        };
    }
769579
function (name) {
        return this.each(function () {
          if (typeof name == 'object') {
            Event.fire(this, name.type, name);
          } else {
            Event.fire(this, name);
          }
        });
      }
185612
function Queue (name, redisClient) {
  this.hasQuit = false
  this._name = name
  this.redisClient = redisClient
  this._key = Queue.PREFIX + this.name
}
654166
@SuppressWarnings("unchecked")
  public T queue(final String name, Function... funcs) {
    for (final Function f : funcs) {
      for (Element e : elements()) {
        queue(e, name, f);
      }
    }
    return (T) this;
  }
161438
function ActiveRecord(name) {

    var cfg = {};
    
    var ext = {
        format:'txt',
        location:'database'
    };

    function buildFileName(name) {
        return ext.location + '/' + name + '.' + ext.format;
    }

    ActiveRecord._config &&
    _.extend(cfg, ActiveRecord._config);

    cfg.format &&
    (ext.format = cfg.format) &&
    (delete cfg.format);

    cfg.location &&
    (ext.location = cfg.location) &&
    (delete cfg.location);

    if(name) {
        cfg.filename = buildFileName(name);
    } else {
        throw new Error("Required parameter 'name' is not defined!");
    }

    var db = new DB(cfg);

    !cfg.autoload && db.loadDatabase();

    var flow = new Flow();

    /**
     * The exported class is responsible for a specific collection
     *
     * @param params
     * @constructor
     */
    function F(params) {
        params && (_.extend(this, params));
        generateId(this);
    }

    F.prototype.save = function() {
        var buffer = _.clone(this),
            refreshBuffer = function() {
                this.createdAt &&
                (buffer.createdAt = this.createdAt);
            },
            syncData = function(data){
                return _.isArray(data) &&
                    _.extend(this, data[1]) || data;
            };

        return F.pre(refreshBuffer.bind(this))
            .update({_id: this._id}, buffer, { upsert: true })
            .then(syncData.bind(this));
    };

    F.prototype.remove = function() {
        return F.remove({_id: this._id}, {});
    };

    /**
     * Cursor for methods: find, findOne or count
     *
     * @param dbCursor
     * @constructor
     */
    function C(dbCursor) {
        var chain = dbCursor;

        _.each(['sort', 'skip', 'limit', 'projection'], function(fName) {
            this[fName] = function() {
                chain = chain[fName].apply(chain, arguments);
                return this;
            }
        }.bind(this));

        this.exec = function(){
            return convertToPromise(chain, 'exec', [], function(data) {
                if(_.isArray(data)) return dbCallbacks.find(data);
                if(_.isObject(data)) return dbCallbacks.findOne(data);
                return data;
            });
        };
    }

    function generateId(o){
        o && !o._id && (o._id = db.createNewId());
    }

    /**
     * Generator of functions using Cursor API: sort, limit, skip, projection
     *
     * @example {$$sort:{planet: 1}, $$skip:1, $$limit:2, $$projection: { planet: 1, system: 1 }, $not: { planet: 'Earth' }}
     * @param fnName
     * @returns {*}
     */
    function generateCursorApi(fnName) {
        return function (query, projections) {
            var cursorOptions = _.pick(query, '$$sort', '$$skip', '$$limit', '$$projection');
            query = _.omit.apply(_, _.flatten([query, _.keys(cursorOptions)]));

            if (_.keys(cursorOptions).length || projections) {
                projections && (cursorOptions.$$projection = projections);

                var cursor = new C(db[fnName](query));
                _.reduce(_.keys(cursorOptions), function (c, method) {
                    return c[method.replace('$$','')](cursorOptions[method]);
                }, cursor);

                return cursor.exec();
            }

            return convertToPromise(db, fnName, arguments,
                (fnName === 'find' ? dbCallbacks.find : (fnName === 'findOne' ? dbCallbacks.findOne : null)));
        };
    }

    function convertToPromise(ctx, method, args, success) {
        return flow.execute(function(){
            var promise = Q.nfapply(ctx[method].bind(ctx), args);
            return success
                ? promise.then(success)
                : promise;
        });
    }

    function createRecord(doc) {
        return doc ? new F(doc) : null;
    }

    var dbCallbacks = {
        insert: function(docs){
            return _.isArray(docs)
                ? _.map(docs, createRecord)
                : createRecord(docs);
        },

        find: function(docs) {
            return _.map(docs, createRecord);
        },

        findOne: function(doc) {
            return createRecord(doc);
        },

        update: function(data) {
            _.isArray(data) &&
            (data[1] = createRecord(data[1]));
            return data;
        }
    };

    F.pre = function(fn) {
        return flow.execute(fn) && F;
    };

    F.update = function(){
        return convertToPromise(db, 'update', arguments, dbCallbacks.update);
    };

    F.insert = function(){
        return convertToPromise(db, 'insert', arguments, dbCallbacks.insert);
    };

    F.remove = function(){
        return convertToPromise(db, 'remove', arguments);
    };

    F.ensureIndex = function(){
        return convertToPromise(db, 'ensureIndex', arguments);
    };

    F.removeIndex = function(){
        return convertToPromise(db, 'removeIndex', arguments);
    };

    F.find = generateCursorApi('find');

    F.count = generateCursorApi('count');

    F.findOne = generateCursorApi('findOne');

    return F;
}
1181879
function(name,arr){
            if(regAlias.test(name)){
                if($.isUndefined(arr)){
                    return alias[name];
                }else{
                    arr = String(arr);
                    alias[name] = arr;
                    return this;
                }

            }else{
                throw new Error('MixJS.alias name 格式错误');
            }
            return this;
        }
715143
public static <A, B> Predicate<A> compose(Predicate<B> predicate, Function<A, ? extends B> function) {
		return t -> predicate.test(function.apply(t));
	}
513647
function getFunction(name) {
    return new Promise((resolve, reject) => {
        lambda.getFunctionConfiguration({
            FunctionName: name
        }, function(err, data) {
            if (err) return reject(err);
            resolve(data);
        });
    });
}
1093056
function compose(middleware){
	return function *(next){
		var i = middleware.length;
		next = next || function *(){};
		var mw;

		while (i--) {
			mw = middleware[i];
			next = mw.call(this, next);
		}

		yield *next;
	}
}
1128432
public Promise promise(final String name) {
    final Promise.Deferred dfd = Deferred();

    // This is the unique instance of the resolve function which will be added to each element.
    final Function resolve = new Function() {
      // Because it is an inner function, the counter cannot final outside the function
      int count = 1;
      // Inner functions don't have constructors, we use a block to initialize it
      {
        for (Element elem : elements()) {
          // Add this resolve function only to those elements with active queue
          if (queue(elem, name, null) != null) {
            emptyHooks(elem, name).add(this);
            count++;
          }
        }
      }

      public void f() {
        if (--count == 0) {
          dfd.resolve(QueuePlugin.this);
        }
      }
    };

    // Run the function and resolve it in case there are not elements with active queue
    resolve.f(this, name);

    return dfd.promise();
  }
1014005
function(name) {
    var idx, length,
      header = this.headers[Utils.headerize(name)],
      result = [];

    if(!header) {
      return [];
    }

    length = header.length;
    for (idx = 0; idx < length; idx++) {
      result.push(header[idx].raw);
    }

    return result;
  }
900313
function (name) {
            var cssStyle = this.getAttr('style');
            if (!cssStyle) {
                return ''
            }
            var reg = new RegExp('(^|;)\\s*' + name + ':([^;]+)','i');
            var match = cssStyle.match(reg);
            if (match && match[0]) {
                return match[2]
            }
            return '';
        }
829222
function (name) {
		var elem = this.createElement('g');
		return defined(name) ? elem.attr({ 'class': PREFIX + name }) : elem;
	}
427982
public static <A, B> Predicate<A> compose(
      Predicate<B> predicate, Function<A, ? extends B> function) {
    return new CompositionPredicate<A, B>(predicate, function);
  }
1149964
function visit (composition, f) {
  composition = Object.assign({}, composition) // copy
  const combinator = composition['.combinator']()
  if (combinator.components) {
    composition.components = composition.components.map(f)
  }
  for (let arg of combinator.args || []) {
    if (arg.type === undefined && composition[arg.name] !== undefined) {
      composition[arg.name] = f(composition[arg.name], arg.name)
    }
  }
  return new Composition(composition)
}