You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@platformatic/foundation

Package Overview
Dependencies
Maintainers
9
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platformatic/foundation - npm Package Compare versions

Comparing version
3.0.0-alpha.6
to
3.0.0-alpha.7
+5
lib/symbols.js
export const kCanceled = Symbol('plt.foundation.canceled')
export const kFailedImport = Symbol('plt.foundation.failedImport')
export const kHandledError = Symbol('plt.foundation.handledError')
export const kMetadata = Symbol('plt.foundation.metadata')
export const kTimeout = Symbol('plt.foundation.timeout')
+13
-3

@@ -6,4 +6,10 @@ import { FastifyError } from '@fastify/error'

// Symbols
export declare const kCanceled: unique symbol
export declare const kFailedImport: unique symbol
export declare const kHandledError: unique symbol
export declare const kMetadata: unique symbol
export declare const kTimeout: unique symbol
// Configuration types
export declare const kMetadata: unique symbol
export declare const envVariablePattern: RegExp

@@ -121,4 +127,9 @@ export declare const knownConfigurationFilesExtensions: string[]

// Execution types
export declare const kTimeout: unique symbol
export declare function executeWithTimeout<T> (promise: Promise<T>, timeout: number, timeoutValue?: any): Promise<T>
export declare function executeInParallel<T, Args extends any[]> (
fn: (...args: Args) => Promise<T>,
args: Args[],
concurrency?: number,
throwOnRejections?: boolean
): Promise<T[]>

@@ -190,3 +201,2 @@ // File system types

// Module types
export declare const kFailedImport: unique symbol
export declare const defaultPackageManager: string

@@ -193,0 +203,0 @@

@@ -13,1 +13,2 @@ export * from './lib/cli.js'

export * from './lib/string.js'
export * from './lib/symbols.js'
+1
-1

@@ -20,2 +20,3 @@ import toml from '@iarna/toml'

import { loadModule, splitModuleFromVersion } from './module.js'
import { kMetadata } from './symbols.js'

@@ -27,3 +28,2 @@ const { parse: parseJSON5, stringify: rawStringifyJSON5 } = JSON5

export const kMetadata = Symbol('plt.foundation.metadata')
export const envVariablePattern = /(?:\{{1,2})([a-z0-9_]+)(?:\}{1,2})/i

@@ -30,0 +30,0 @@

import { Unpromise } from '@watchable/unpromise'
import { setTimeout as sleep } from 'node:timers/promises'
import { kCanceled, kTimeout } from './symbols.js'
export const kTimeout = Symbol('plt.utils.timeout')
export async function executeWithTimeout (promise, timeout, timeoutValue = kTimeout) {

@@ -14,1 +13,60 @@ const ac = new AbortController()

}
export async function executeInParallel (fn, args, concurrency = 5, throwOnRejections = true, throwAllErrors = false) {
const { promise, resolve } = Promise.withResolvers()
const results = new Map()
let current = 0
let pending = 0
let firstError
let terminated = false
if (args.length === 0) {
return []
}
function scheduleNext () {
// While we have capacity and there are still items to process
while (current < args.length && pending < concurrency) {
const i = current++
pending++
// Perform the async operation
fn(...args[i])
.then(result => {
results.set(i, result)
})
.catch(err => {
results.set(i, err)
firstError = err
})
.finally(() => {
pending--
if (terminated) {
return
}
if ((current === args.length && pending === 0) || (firstError && throwOnRejections)) {
terminated = true
resolve()
} else {
scheduleNext()
}
})
}
}
scheduleNext()
await promise
const returnedValues = []
for (let j = 0; j < args.length; j++) {
returnedValues.push(results.has(j) ? results.get(j) : kCanceled)
}
if (firstError && throwOnRejections) {
throw throwAllErrors ? AggregateError(returnedValues, 'One or more operations failed.') : firstError
}
return returnedValues
}

@@ -7,7 +7,6 @@ import { existsSync } from 'node:fs'

import { hasJavascriptFiles } from './file-system.js'
import { kFailedImport } from './symbols.js'
let platformaticPackageVersion
export const kFailedImport = Symbol('plt.utils.failedImport')
export const defaultPackageManager = 'npm'

@@ -14,0 +13,0 @@

@@ -692,2 +692,9 @@ export function overridableValue (spec, defaultValue) {

health: { ...healthWithoutDefaults },
dependencies: {
type: 'array',
items: {
type: 'string'
},
default: []
},
arguments: {

@@ -807,2 +814,8 @@ type: 'array',

preload,
dependencies: {
type: 'array',
items: {
type: 'string'
}
},
arguments: {

@@ -809,0 +822,0 @@ type: 'array',

{
"name": "@platformatic/foundation",
"version": "3.0.0-alpha.6",
"version": "3.0.0-alpha.7",
"description": "Platformatic Foundation",

@@ -5,0 +5,0 @@ "main": "index.js",