1.0.3 • Published 1 year ago
@brahimemo/standard-js v1.0.3
Standard-JS Package
The standard-js package provides common types and constants for HTTP methods, status codes, mathematical constants, and date/time formats. It is designed to simplify development in your applications by offering predefined values that can be easily imported and used.
Installation
To install this module, you can use npm, Yarn, Bun, or pnpm:
npm install @brahimemo/standard-jsyarn add @brahimemo/standard-jsbun install @brahimemo/standard-jspnpm add @brahimemo/standard-jsUsage
Importing HTTP Methods
You can import the HTTP methods and use them in your application:
import { HTTPMethods } from "@brahimemo/standard-js/http";
console.log(HTTPMethods.Get); // "GET"
console.log(HTTPMethods.Post); // "POST"Importing HTTP Status Codes
You can also import the HTTP status codes:
import { StatusCodes } from "@brahimemo/standard-js/http";
console.log(StatusCodes.StatusOK); // 200
console.log(StatusCodes.StatusNotFound); // 404Available HTTP Methods
GETHEADPOSTPUTPATCHDELETECONNECTOPTIONSTRACE
Available HTTP Status Codes
1xx Informational
StatusContinue(100)StatusSwitchingProtocols(101)StatusProcessing(102)StatusEarlyHints(103)
2xx Success
StatusOK(200)StatusCreated(201)StatusAccepted(202)StatusNoContent(204)
3xx Redirection
StatusMovedPermanently(301)StatusFound(302)StatusNotModified(304)
4xx Client Errors
StatusBadRequest(400)StatusUnauthorized(401)StatusNotFound(404)
5xx Server Errors
StatusInternalServerError(500)StatusNotImplemented(501)
Importing Mathematical Constants
You can import mathematical constants like this:
import { Math } from "@brahimemo/standard-js/math";
console.log(Math.Pi); // 3.141592653589793
console.log(Math.Expo); // 2.718281828459045Available Mathematical Constants
Math.ExpoMath.PiMath.PhiMath.Sqrt2Math.SlfEMath.Ln2- And more...
Importing Date/Time Formats
You can import date and time formats as follows:
import { Formats } from "@brahimemo/standard-js/time";
console.log(Formats.RFC3339); // "yyyy-MM-ddTHH:mm:ssZ"
console.log(Formats.Kitchen); // "h:mma"Available Date/Time Formats
Formats.LayoutFormats.ANSICFormats.RFC3339Formats.Kitchen- And more...
Contributing
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes and commit them (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.