Sha256: 1811281d804ab2d749efccfb6e834d7c9e69196152710385887a46bf01e655ed
Contents?: true
Size: 764 Bytes
Versions: 6
Compression:
Stored size: 764 Bytes
Contents
# frozen_string_literal: true require_relative "tools/version" require "async" require "async/notification" require "async/semaphore" require "zeitwerk" loader = Zeitwerk::Loader.new loader.tag = File.basename(__FILE__, ".rb") loader.inflector = Zeitwerk::GemInflector.new(__FILE__) loader.push_dir(File.expand_path("..", __dir__.to_s)) loader.setup module Async # Your code goes here... module Tools # rubocop:disable Style/ClassAndModuleChildren class Error < StandardError end end def self.map(collection, concurrency: nil, parent: Async::Task.current, &) Async::Semaphore.new(concurrency || collection.count, parent:).then do |s| collection.map do |item| s.async { yield(item) } end.map(&:wait) end end end
Version data entries
6 entries across 6 versions & 1 rubygems