from CommonsChunkPlugin (async methods):
342572
function extractOriginsOfChunkWithExtractedModules(chunk, reason = 'async commons') {
  return chunk.origins.map((origins, origin) => Object.assign({}, origin, {
    reasons: (origin.reasons || []).concat(reason)
  }))
}
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)
        })
    })
}
534694
async function(filename, compress, result) {
  const content = JSON.stringify(result);

  const data = compress ? await gzip(content) : content;
  return await writeFile(filename + (compress ? ".gz" : ""), data);
}
1168517
async def chunks(source, n):
    
    async with streamcontext(source) as streamer:
        async for first in streamer:
            xs = select.take(create.preserve(streamer), n-1)
            yield [first] + await aggregate.list(xs)
967116
function hotDownloadUpdateChunk(chunkId) {
		var script = document.createElement("script");
		script.charset = "utf-8";
		script.src = $require$.p + $hotChunkFilename$;
		if ($crossOriginLoading$) script.crossOrigin = $crossOriginLoading$;
		document.head.appendChild(script);
	}
1319807
def get_async(cls, blob_key, **ctx_options):
    """"""
    if not isinstance(blob_key, (BlobKey, basestring)):
      raise TypeError('Expected blob key, got %r' % (blob_key,))
    if 'parent' in ctx_options:
      raise TypeError('Parent is not supported')
    return cls.get_by_id_async(str(blob_key), **ctx_options)
1040144
function commonStartupOperations() {
    if (options.stayUp) {
      process.on('uncaughtException', app.log); // prints stack trace
    }
    startupMessage.call(this, options);
  }
476497
public alluxio.grpc.Chunk getChunk() {
    return chunk_ == null ? alluxio.grpc.Chunk.getDefaultInstance() : chunk_;
  }
801701
@Override
    protected WsByteBuffer createChunkHeader(byte[] length) {
        if (!getLink().isReconnectAllowed()) {
            // use the "shared" chunk header object
            return super.createChunkHeader(length);
        }

        // must make a unique buffer to avoid data corruption during a
        // reconnect pass
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "OSC creating chunk length buffer");
        }
        WsByteBuffer header = allocateBuffer(32);
        header.put(length);
        header.put(BNFHeaders.EOL);
        header.flip();
        return header;
    }
32407
function transformChunkContents(chunk) {
    var contents = String(chunk.contents);
    try {
      if (chunk.isMarkdown) {
        contents = options.renderMarkdown(contents);
      }
      if (chunk.isTemplate) {
        contents = options.renderTemplate(contents, chunk.data, chunk.data.srcPath);
      }
      chunk.contents = new Buffer(contents);
      if (chunk.data.layout) applyLayout(chunk);
    } catch (err) {
      this.emit('error', new PluginError(logFlag, err.stack || err));
    }
    return chunk;
  }
1285210
private static ChunkOutput writeChunkOutput(
      Compiler compiler, Flags flags, List<JSModule> chunks) {
    ArrayList<File> outputFiles = new ArrayList<>();
    ChunkOutput output = new ChunkOutput();

    Map<String, String> parsedModuleWrappers =
        parseModuleWrappers(Arrays.asList(getStringArray(flags, "chunkWrapper")), chunks);

    for (JSModule c : chunks) {
      if (flags.createSourceMap != null && !flags.createSourceMap.equals(false)) {
        compiler.resetAndIntitializeSourceMap();
      }

      File file = new File();
      file.path = flags.chunkOutputPathPrefix + c.getName() + ".js";

      String code = compiler.toSource(c);

      int lastSeparatorIndex = file.path.lastIndexOf('/');
      if (lastSeparatorIndex < 0) {
        lastSeparatorIndex = file.path.lastIndexOf('\\');
      }
      String baseName = file.path.substring(Math.max(0, lastSeparatorIndex));
      String wrapper = parsedModuleWrappers.get(c.getName()).replace("%basename%", baseName);
      StringBuilder out = new StringBuilder();
      int pos = wrapper.indexOf("%s");
      if (pos != -1) {
        String prefix = "";

        if (pos > 0) {
          prefix = wrapper.substring(0, pos);
          out.append(prefix);
        }

        out.append(code);

        int suffixStart = pos + "%s".length();
        if (suffixStart != wrapper.length()) {
          // Something after placeholder?
          out.append(wrapper, suffixStart, wrapper.length());
        }
        // Make sure we always end output with a line feed.
        out.append('\n');

        // If we have a source map, adjust its offsets to match
        // the code WITHIN the wrapper.
        if (compiler != null && compiler.getSourceMap() != null) {
          compiler.getSourceMap().setWrapperPrefix(prefix);
        }

      } else {
        out.append(code);
        out.append('\n');
      }

      file.src = out.toString();

      if (flags.createSourceMap != null && !flags.createSourceMap.equals(false)) {
        StringBuilder b = new StringBuilder();
        try {
          compiler.getSourceMap().appendTo(b, file.path);
        } catch (IOException e) {
          // ignore
        }
        file.sourceMap = b.toString();
      }
      outputFiles.add(file);
    }

    output.compiledFiles = outputFiles.toArray(new File[0]);
    return output;
  }
1049343
@Override
    protected WsByteBuffer createChunkTrailer() {
        if (!getLink().isReconnectAllowed()) {
            // use the "shared" chunk trailer object
            return super.createChunkTrailer();
        }

        // if reconnects are allowed, then these buffers must be unique
        // per chunk, otherwise we get data corruption
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "OSC creating chunk trailer");
        }
        WsByteBuffer buffer = allocateBuffer(32);
        buffer.put(CHUNK_TRAILER_DATA);
        buffer.flip();
        return buffer;
    }
655124
function createChunkCache(chunks, capacity)
{
  var chunkCache;
  var onLoadComplete;
  var index;
  var length;

  // create a chunk cache
  chunkCache = new ChunkCache(capacity);

  // every time a chunk is loaded, add it to the cache
  // TODO: should the caching be based on most recently 'used' or most recently
  // 'loaded'?
  onLoadComplete = function(err, chunk)
  {
    if (!err)
    {
      chunkCache.put(chunk);
    }
  };

  // subscribe to the 'loadcomplete' event on all the chunks
  for (index = 0, length = chunks.length; index < length; index++)
  {
    chunks[index].on('loadcomplete', onLoadComplete);
  }

  // TODO: do we need to unsubscribe from the loadcomplete event at some point?

  return chunkCache;
}
87894
private ChunkType getChunkType(List<ChunkTaggedToken> tokens, int chunkStartPos) {
    boolean isPlural = false;
    for (int i = chunkStartPos; i < tokens.size(); i++) {
      ChunkTaggedToken token = tokens.get(i);
      if (!isBeginningOfNounPhrase(token) && !isContinuationOfNounPhrase(token)) {
        break;
      }
      if (false && "and".equals(token.getToken())) {   // e.g. "Tarzan and Jane" is a plural noun phrase
        // TODO: "Additionally, there are over 500 college and university chapter."
        isPlural = true;
      } else if (hasNounWithPluralReading(token)) {   // e.g. "ten books" is a plural noun phrase
        isPlural = true;
      }
    }
    return isPlural ? ChunkType.PLURAL : ChunkType.SINGULAR;
  }
738542
function(id, responseParser) {
            var lastChunkIdx = handler._getTotalChunks(id) - 1,
                xhr = handler._getXhr(id, lastChunkIdx);

            if (responseParser) {
                return new qq.Promise().success(responseParser(xhr), xhr);
            }

            return new qq.Promise().success({}, xhr);
        }
733525
public void writeAsyncHeader(@NotNull Wire wire, String csp, long cid) {
        assert outBytesLock().isHeldByCurrentThread();

        wire.writeDocument(true, wireOut -> {
            if (cid == 0)
                wireOut.writeEventName(CoreFields.csp).text(csp);
            else
                wireOut.writeEventName(CoreFields.cid).int64(cid);
        });
    }
230727
function (options, dir, callback) {
  options.logger('Creating contents of package')

  async.parallel([
    async.apply(createDesktop, options, dir),
    async.apply(createIcon, options, dir),
    async.apply(createCopyright, options, dir),
    async.apply(createApplication, options, dir)
  ], function (err) {
    callback(err, dir)
  })
}