
Security News
Node.js Moves Toward Stable TypeScript Support with Amaro 1.0
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
gitlab.mai.ru/library/async
Используется для асинхронной обработки слайса данных. Функция использует паттерн асинхронной обработка данных fan-out/fan-in.
В данной реализации, что все возникшие ошибки будут логироваться в функции action.
Входные параметры:
Выходные параметры:
Примеры использования:
func EntityList() []Entity {
entities := GetEntitiesFromDB() // []Entity
input := make(chan Entity, chanBufferSize)
go func() {
defer close(input)
for idx := range entities {
input <- entities[idx]
}
}()
output := SliceAction(goroutinesCount, chanBufferSize, input, func(entity Entity) Entity {
title, err := GetTitleFromOtherSource(entity.ID)
if err != nil {
logrus.Errorf("failed to get title from other source: %v", err)
} else {
entity.Title = title
}
return entity
})
entitiesResponse := make([]Entity, 0, len(entities))
for entity := range output {
entitiesResponse = append(entitiesResponse, entity)
}
return entitiesResponse
}
Также есть пример, когда мы передаем канал с id, а на выходе получаем канал сущностей.
func EntityList() []Entity {
entityIDs := GetEntitiesFromDB() // []uint64
input := make(chan uint64, chanBufferSize)
go func() {
defer close(input)
for idx := range entityIDs {
input <- entityIDs[idx]
}
}()
output := SliceAction(goroutinesCount, chanBufferSize, input, func(entityID uint64) Entity {
entity, err := GetEntityFromOtherSource(entityID)
if err != nil {
logrus.Errorf("failed to get entity from other source: %v", err)
}
return entity
})
entitiesResponse := make([]Entity, 0, len(entityIDs))
for entity := range output {
entitiesResponse = append(entitiesResponse, entity)
}
return entitiesResponse
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.