Nodejs Array Inject inject

Here you can find the source of inject

Method Source Code

===

Related

  1. inject(callback)
    Array.prototype.inject = function (callback) {
      var accumulator = this[0];
      var body = this.slice(1, this.length);
      body.each(function (el) {
        accumulator = callback(accumulator, el);
      });
      return accumulator;
    };
    var add = function (a, el) {
    ...
    
  2. inject(command, accumulator)
    Array.prototype.inject = function(command, accumulator){
      var start = 0;
      if(!accumulator){
        accumulator = this[0]
        start += 1;
      this.slice(start,this.length).each(function(el){
        accumulator = command(accumulator, el);
      });
    ...
    
  3. inject(element)
    var express = require('express')
      , app = express()
      , server = require('http').createServer(app)
      , io = require('socket.io').listen(server);
    server.listen(3000);
    app.use(express.static(__dirname + '/public'));
    var messages = new Array()
    Array.prototype.inject = function(element) {
        if (this.length >= 5) {
    ...
    
  4. inject(funct)
    Array.prototype.inject = function(funct) {
      var start = this.shift();
      var accum = start;
      var createInjection = function(num){
        if (accum = funct(accum, num));
      };
      this.myEach(createInjection);
      this.unshift(start);
      return accum;
    ...