@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.
npm install @multi-kit/protocol
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
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. |
- Combines the given protocol, location, and path into a full URL.
✅ 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)
✅ Modern browsers (Chrome / Firefox / Edge / Safari) ✅ Seamless support for both browser and Node.js environments
- Simple and Easy to Use 🏆
- Flexible Path Generation ✅
- Lightweight and Efficient 🚀
Contributions to this library are welcome. If you encounter any issues or have suggestions for improvements, please submit an issue or pull request.
This project is licensed under the MIT License.