Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@layerzerolabs/evm-sdks-build

Package Overview
Dependencies
Maintainers
0
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@layerzerolabs/evm-sdks-build

  • 3.0.36
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@layerzerolabs/evm-sdks-build

The EVM SDKs Build Tools package provides a set of utilities and tools for building and managing EVM-based SDKs. It includes functions for copying files, populating directories, and managing concurrency with semaphores.

Features

  • File Management: Copy files from source packages to target directories.
  • Directory Population: Populate directories with specified files.
  • Concurrency Control: Manage concurrent operations with semaphores.

Installation

To install the EVM SDKs Build Tools package, you can use npm or yarn:

npm install @layerzerolabs/evm-sdks-build

or

yarn add @layerzerolabs/evm-sdks-build

Usage

File Management

Asynchronously copies files from source packages to a target root directory based on the provided directory structure.

  • packageFiles: An object mapping package names to their directory structures.
  • callerRootFile: The absolute path to the root file of the caller.
  • Returns: A promise that resolves when the operation is complete.
import { copyPackageFiles, PackageFiles } from "@layerzerolabs/evm-sdks-build";

const packageFiles: PackageFiles = {
  "@layerzerolabs/package1": ["file1.js", "file2.js"],
  "@layerzerolabs/package2": {
    dir1: ["file3.js"],
    dir2: ["file4.js", "file5.js"],
  },
};

const callerRootFile = __filename;

copyPackageFiles(packageFiles, callerRootFile).then(() => {
  console.log("Files copied successfully.");
});

Directory Population

Populates the target directory with files from the specified source packages.

  • copyTargets: An object mapping source packages to their respective file patterns.
  • callerRootFile: The absolute path to the root file of the caller.
  • Returns: A promise that resolves when the operation is complete.
import { populate, CopyTargets } from "@layerzerolabs/evm-sdks-build";

const copyTargets: CopyTargets = {
  "@layerzerolabs/package1": {
    artifacts: ["**/*.json"],
    deployments: ["**/*.json"],
  },
  "@layerzerolabs/package2": {
    "artifacts-tron": ["**/*.json"],
    "artifacts-zk": ["**/*.json"],
  },
};

const callerRootFile = __filename;

populate(copyTargets, callerRootFile).then(() => {
  console.log("Directories populated successfully.");
});

Concurrency Control

Semaphore for controlling access to a resource by multiple processes.

  • constructor(max: number): Initializes the semaphore with a maximum number of concurrent locks.
  • acquire(): Acquires a lock on the semaphore.
  • release(): Releases a lock on the semaphore.
import { Semaphore } from '@layerzerolabs/evm-sdks-build'

const semaphore = new Semaphore(3)

async function task(id: number) {
    await semaphore.acquire()
    console.log(`Task ${id} acquired semaphore.`)
    // Simulate async work
    await new Promise((resolve) => setTimeout(resolve, 1000))
    console.log(`Task ${id} releasing semaphore.`)
    semaphore.release()
}

for (let i = 1 i <= 5 i++) {
    task(i)
}

FAQs

Package last updated on 21 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc