@multi-kit/protocol
TypeScript icon, indicating that this package has built-in type declarations

0.0.23 • Public • Published

Introduction

@multi-kit/protocol is a simple currying function library that transforms a function that takes multiple arguments into a series of functions, each accepting a single argument. Currying enhances the flexibility of functions and facilitates their composition and reuse.

Installation

npm install @multi-kit/protocol

Usage

import { customPath, httpPath, httpsPath, wsPath, wssPath, ftpPath } from '@multi-kit/protocol';

// Using currying functions
console.log(httpPath('www.example.com', '/path/to/resource')); // Output: http://www.example.com/path/to/resource
console.log(httpsPath('www.example.com', '/path/to/resource')); // Output: https://www.example.com/path/to/resource
console.log(wsPath('www.example.com', '/path/to/resource')); // Output: ws://www.example.com/path/to/resource
console.log(wssPath('www.example.com', '/path/to/resource')); // Output: wss://www.example.com/path/to/resource
console.log(ftpPath('www.example.com', '/path/to/resource')); // Output: ftp://www.example.com/path/to/resource

API

Method Name Description
resolvePath(protocol, location, path) Combine protocol, location, and path into a full URL.
customPath,httpPath,httpsPath,wsPath,wssPath,ftpPath Curried path generation functions for different protocols.

resolvePath(protocol: string, location: string, path: string): string

  • Combines the given protocol, location, and path into a full URL.

Use Cases

Functional Programming (Simplify function composition and reuse) ✅ Path Generator (Quickly generate path functions for different protocols using currying) ✅ Flexibility (Easily combine different functions via currying and parameter passing)

Compatibility

✅ Modern browsers (Chrome / Firefox / Edge / Safari) ✅ Seamless support for both browser and Node.js environments

🎯 Why Choose @multi-kit/dispatcher?

  • Simple and Easy to Use 🏆
  • Flexible Path Generation
  • Lightweight and Efficient 🚀

Contributing

Contributions to this library are welcome. If you encounter any issues or have suggestions for improvements, please submit an issue or pull request.

License

This project is licensed under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @multi-kit/protocol

Weekly Downloads

9

Version

0.0.23

License

ISC

Unpacked Size

8.59 kB

Total Files

8

Last publish

Collaborators

  • wanglizhi